From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRHpU-0008QR-7x for qemu-devel@nongnu.org; Thu, 25 Oct 2012 03:26:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRHpO-00086v-Eq for qemu-devel@nongnu.org; Thu, 25 Oct 2012 03:26:12 -0400 Received: from mailpro.odiso.net ([89.248.209.98]:48749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRHpO-00086X-6I for qemu-devel@nongnu.org; Thu, 25 Oct 2012 03:26:06 -0400 Date: Thu, 25 Oct 2012 09:25:35 +0200 (CEST) From: Alexandre DERUMIER Message-ID: <93cf825d-ecca-4367-8b74-4a69c53b5801@mailpro> In-Reply-To: <37f26e36-0239-4598-bfc3-477e7dcf3787@mailpro> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Subject: [Qemu-devel] qemu-img convert with block driver without .bdrv_create (like iscsi) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: kwolf@redhat.com, pbonzini@redhat.com, ronnie sahlberg 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