cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-Bugfix-format-and-snapshot-used-in-drive-optio.patch

218e99
From 3cae2bf94bf3ef300facbd31214dbeae7b2ad7b7 Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Mon, 4 Nov 2013 22:31:57 +0100
218e99
Subject: [PATCH 04/87] block: Bugfix 'format' and 'snapshot' used in drive option
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383604354-12743-7-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55306
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 06/43] block: Bugfix 'format' and 'snapshot' used in drive option
218e99
Bugzilla: 1026524
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
218e99
From: Mike Qiu <qiudayu@linux.vnet.ibm.com>
218e99
218e99
BZ: 1026524
218e99
218e99
When use -drive file='xxx',format=qcow2,snapshot=on the error
218e99
message "Can't use snapshot=on with driver-specific options"
218e99
can be show, and fail to start the qemu.
218e99
218e99
This should not be happened, and there is no file.driver option
218e99
in qemu command line.
218e99
218e99
It is because the commit 74fe54f2a1b5c4f4498a8fe521e1dfc936656cd4,
218e99
it puts 'driver' option if the command line use 'format' option.
218e99
218e99
This patch is to solve this bug.
218e99
218e99
Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit 6db5f5d68e2ffc430ba0511e23fc36c7363510f1)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
---
218e99
 blockdev.c | 12 +++++++++---
218e99
 1 file changed, 9 insertions(+), 3 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 blockdev.c |   12 +++++++++---
218e99
 1 files changed, 9 insertions(+), 3 deletions(-)
218e99
218e99
diff --git a/blockdev.c b/blockdev.c
218e99
index 6710f61..a6563fa 100644
218e99
--- a/blockdev.c
218e99
+++ b/blockdev.c
218e99
@@ -342,6 +342,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
218e99
     QDict *bs_opts;
218e99
     const char *id;
218e99
     bool has_driver_specific_opts;
218e99
+    BlockDriver *drv = NULL;
218e99
 
218e99
     translation = BIOS_ATA_TRANSLATION_AUTO;
218e99
     media = MEDIA_DISK;
218e99
@@ -487,7 +488,11 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
218e99
             return NULL;
218e99
         }
218e99
 
218e99
-        qdict_put(bs_opts, "driver", qstring_from_str(buf));
218e99
+        drv = bdrv_find_whitelisted_format(buf, ro);
218e99
+        if (!drv) {
218e99
+            error_report("'%s' invalid format", buf);
218e99
+            return NULL;
218e99
+        }
218e99
     }
218e99
 
218e99
     /* disk I/O throttling */
218e99
@@ -702,12 +707,13 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
218e99
     }
218e99
 
218e99
     QINCREF(bs_opts);
218e99
-    ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, NULL);
218e99
+    ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv);
218e99
 
218e99
     if (ret < 0) {
218e99
         if (ret == -EMEDIUMTYPE) {
218e99
             error_report("could not open disk image %s: not in %s format",
218e99
-                         file ?: dinfo->id, qdict_get_str(bs_opts, "driver"));
218e99
+                         file ?: dinfo->id, drv ? drv->format_name :
218e99
+                         qdict_get_str(bs_opts, "driver"));
218e99
         } else {
218e99
             error_report("could not open disk image %s: %s",
218e99
                          file ?: dinfo->id, strerror(-ret));
218e99
-- 
218e99
1.7.1
218e99