qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Override the driver in the filename with the user-specified one
@ 2015-08-24 13:05 Alberto Garcia
  2015-08-24 18:54 ` Max Reitz
  0 siblings, 1 reply; 5+ messages in thread
From: Alberto Garcia @ 2015-08-24 13:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Alberto Garcia, qemu-block, Max Reitz

If an image is opened with driver-specific options then attempting to
use snapshot_blkdev will fail with "Driver specified twice".

The reason is that bs->filename is replaced with a full JSON object by
bdrv_refresh_filename() when such options are present:

   -drive if=virtio,file=hd0.qcow2,lazy-refcounts=on

   (qemu) info block
   virtio0: json:{"lazy-refcounts": "on", "driver": "qcow2", "file":
                  {"driver": "file", "filename": "hd0.qcow2"}} (qcow2)

A snapshot of that image will try to inherit its options, and that
includes parsing its filename when it is in the "json:" format.

Since the JSON object includes a driver name, it will clash with
the one requested by the user in snapshot_blkdev, producing the
aforementioned error.

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 block.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/block.c b/block.c
index d088ee0..b09de04 100644
--- a/block.c
+++ b/block.c
@@ -1014,6 +1014,12 @@ static int bdrv_fill_options(QDict **options, const char **pfilename,
             return -EINVAL;
         }
 
+        /* We shouldn't use the driver from the filename if there is
+         * one explicitly specified already */
+        if (drv) {
+            qdict_del(json_options, "driver");
+        }
+
         /* Options given in the filename have lower priority than options
          * specified directly */
         qdict_join(*options, json_options, false);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-26 19:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 13:05 [Qemu-devel] [PATCH] block: Override the driver in the filename with the user-specified one Alberto Garcia
2015-08-24 18:54 ` Max Reitz
2015-08-25  7:03   ` Alberto Garcia
2015-08-26 14:53     ` Max Reitz
2015-08-26 19:29       ` Alberto Garcia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).