def _zfs_image_create(vm_name,
                      pool,
                      disk_name,
                      hostname_property_name,
                      sparse_volume,
                      disk_size,
                      disk_image_name):
    '''
    Clones an existing image, or creates a new one.

    When cloning an image, disk_image_name refers to the source
    of the clone. If not specified, disk_size is used for creating
    a new zvol, and sparse_volume determines whether to create
    a thin provisioned volume.

    The cloned or new volume can have a ZFS property set containing
    the vm_name. Use hostname_property_name for specifying the key
    of this ZFS property.
    '''
    if not disk_image_name and not disk_size:
        raise CommandExecutionError(
            'Unable to create new disk {0}, please specify'
            ' the disk image name or disk size argument'
            .format(disk_name)
        )

    if not pool:
        raise CommandExecutionError(
            'Unable to create new disk {0}, please specify'
            ' the disk pool name'.format(disk_name))

    destination_fs = os.path.join(pool,
                                  '{0}.{1}'.format(vm_name, disk_name))
    log.debug('Image destination will be %s', destination_fs)

    existing_disk = __salt__['zfs.list'](name=pool)
    if 'error' in existing_disk:
        raise CommandExecutionError(
            'Unable to create new disk {0}. {1}'
            .format(destination_fs, existing_disk['error'])
        )
    elif destination_fs in existing_disk:
        log.info('ZFS filesystem %s already exists. Skipping creation', destination_fs)
        blockdevice_path = os.path.join('/dev/zvol', pool, vm_name)
        return blockdevice_path

    properties = {}
    if hostname_property_name:
        properties[hostname_property_name] = vm_name

    if disk_image_name:
        __salt__['zfs.clone'](
                  name_a=disk_image_name,
                  name_b=destination_fs,
                  properties=properties)

    elif disk_size:
        __salt__['zfs.create'](
                name=destination_fs,
                properties=properties,
                volume_size=disk_size,
                sparse=sparse_volume)

    blockdevice_path = os.path.join('/dev/zvol', pool, '{0}.{1}'
                                    .format(vm_name, disk_name))
    log.debug('Image path will be %s', blockdevice_path)
    return blockdevice_path