[pve-devel] [PATCH] iscsi : qemu-img convert workaround

Alexandre DERUMIER aderumier at odiso.com
Wed Oct 24 10:42:19 CEST 2012


host_device block driver have same implementation (qemu-img convert /dev/....)

So, I don't think it's wrong to do it in same way for iscsi block driver.....



block/raw-posix.c

static BlockDriver bdrv_host_device = {
    .format_name        = "host_device",
    .protocol_name        = "host_device",
    .instance_size      = sizeof(BDRVRawState),
    .bdrv_probe_device  = hdev_probe_device,
    .bdrv_file_open     = hdev_open,
    .bdrv_close         = raw_close,
    .bdrv_create        = hdev_create,
    .create_options     = raw_create_options,
    .bdrv_has_zero_init = hdev_has_zero_init,

    .bdrv_aio_readv     = raw_aio_readv,
    .bdrv_aio_writev    = raw_aio_writev,
    .bdrv_aio_flush     = raw_aio_flush,

    .bdrv_truncate      = raw_truncate,
    .bdrv_getlength     = raw_getlength,
    .bdrv_get_allocated_file_size
                        = raw_get_allocated_file_size,

    /* generic scsi device */
#ifdef __linux__
    .bdrv_ioctl         = hdev_ioctl,
    .bdrv_aio_ioctl     = hdev_aio_ioctl,
#endif
};


static int hdev_create(const char *filename, QEMUOptionParameter *options)
{
    int fd;
    int ret = 0;
    struct stat stat_buf;
    int64_t total_size = 0;

    /* Read out options */
    while (options && options->name) {
        if (!strcmp(options->name, "size")) {
            total_size = options->value.n / BDRV_SECTOR_SIZE;
        }
        options++;
    }

    fd = qemu_open(filename, O_WRONLY | O_BINARY);
    if (fd < 0)
        return -errno;

    if (fstat(fd, &stat_buf) < 0)
        ret = -errno;
    else if (!S_ISBLK(stat_buf.st_mode) && !S_ISCHR(stat_buf.st_mode))
        ret = -ENODEV;
    else if (lseek(fd, 0, SEEK_END) < total_size * BDRV_SECTOR_SIZE)
        ret = -ENOSPC;

    qemu_close(fd);
    return ret;
}



----- Mail original ----- 

De: "Dietmar Maurer" <dietmar at proxmox.com> 
À: "Alexandre Derumier" <aderumier at odiso.com>, pve-devel at pve.proxmox.com 
Envoyé: Mercredi 24 Octobre 2012 10:22:01 
Objet: RE: [pve-devel] [PATCH] iscsi : qemu-img convert workaround 

We can't create iscsi device, so that fix looks somehow wrong to me. 

Can't we simply avoid to call to bdrv_create() in qemu-img.c? 

Maybe by adding an option -n ('no-create') to the convert command? 

> -----Original Message----- 
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel- 
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier 
> Sent: Dienstag, 23. Oktober 2012 14:20 
> To: pve-devel at pve.proxmox.com 
> Subject: [pve-devel] [PATCH] iscsi : qemu-img convert workaround 
> 
> basic workaround to use qemu-img convert. 



More information about the pve-devel mailing list