Hello,
I'm looking to use qemu-img convert to write to iscsi block device (iscsi://..)
As iscsi doesn't have .bdrv_create, qemu-img convert hang on
/* Create the new image */
ret = bdrv_create(drv, out_filename, param);
if (ret < 0) {
if (ret == -ENOTSUP) {
error_report("Formatting not supported for file format '%s'",
out_fmt);
} else if (ret == -EFBIG) {
error_report("The image size is too large for file format '%s'",
out_fmt);
} else {
error_report("%s: error while converting %s: %s",
out_filename, out_fmt, strerror(-ret));
}
goto out;
}
What is the best way to get it working ?
1)add a .bdrv_create in block/iscsi.c ?
(like host_device block driver, only open/close the device and check if size if
big enough)
block/raw-posix.c
.bdrv_create = hdev_create,
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;
}
2)or add a fallback in qemu-img, if bdrv_create doesn't exist, use bdrv_open to
see if the backend device is pre-existing ?
Regards,
Alexandre Derumier