Received: from eggs.gnu.org ([2001:4830:134:3::10]:39570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7RTE-0001iF-Q0 for qemu-devel@nongnu.org; Thu, 08 Aug 2013 10:45:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7RT4-0003k2-TY for qemu-devel@nongnu.org; Thu, 08 Aug 2013 10:45:44 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:47151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7RT4-0003jC-2C for qemu-devel@nongnu.org; Thu, 08 Aug 2013 10:45:34 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Aug 2013 20:07:01 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 6638B394004D for ; Thu, 8 Aug 2013 20:15:17 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r78EkbhJ17301574 for ; Thu, 8 Aug 2013 20:16:38 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r78EjOQ6018949 for ; Thu, 8 Aug 2013 20:15:24 +0530 From: Mike Qiu Date: Thu, 8 Aug 2013 10:45:16 -0400 Message-Id: <1375973116-8458-1-git-send-email-qiudayu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] block: Bugfix 'format' and 'snapshot' used in drive option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Mike Qiu , stefanha@redhat.com When use -drive file='xxx',format=qcow2,snapshot=on the error message "Can't use snapshot=on with driver-specific options" can be show, and fail to start the qemu. This should not be happened, and there is no file.driver option in qemu command line. It is because the commit 74fe54f2a1b5c4f4498a8fe521e1dfc936656cd4, it puts 'driver' option if the command line use 'format' option. This patch is to solve this bug. Signed-off-by: Mike Qiu --- blockdev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 41b0a49..e174b7d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -340,6 +340,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, QDict *bs_opts; const char *id; bool has_driver_specific_opts; + BlockDriver *drv = NULL; translation = BIOS_ATA_TRANSLATION_AUTO; media = MEDIA_DISK; @@ -485,7 +486,11 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, return NULL; } - qdict_put(bs_opts, "driver", qstring_from_str(buf)); + drv = bdrv_find_whitelisted_format(buf, ro); + if (!drv) { + error_report("'%s' invalid format", buf); + return NULL; + } } /* disk I/O throttling */ @@ -700,12 +705,13 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, } QINCREF(bs_opts); - ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, NULL); + ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv); if (ret < 0) { if (ret == -EMEDIUMTYPE) { error_report("could not open disk image %s: not in %s format", - file ?: dinfo->id, qdict_get_str(bs_opts, "driver")); + file ?: dinfo->id, drv ? drv->format_name : + qdict_get_str(bs_opts, "driver")); } else { error_report("could not open disk image %s: %s", file ?: dinfo->id, strerror(-ret)); -- 1.8.3.1