From: Alberto Garcia <berto@igalia.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH] block: Override the driver in the filename with the user-specified one
Date: Mon, 24 Aug 2015 16:05:37 +0300 [thread overview]
Message-ID: <1440421537-26477-1-git-send-email-berto@igalia.com> (raw)
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
next reply other threads:[~2015-08-24 13:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 13:05 Alberto Garcia [this message]
2015-08-24 18:54 ` [Qemu-devel] [PATCH] block: Override the driver in the filename with the user-specified one Max Reitz
2015-08-25 7:03 ` Alberto Garcia
2015-08-26 14:53 ` Max Reitz
2015-08-26 19:29 ` Alberto Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440421537-26477-1-git-send-email-berto@igalia.com \
--to=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).