[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 14/21] blkdebug: Allow command-line file configur
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v3 14/21] blkdebug: Allow command-line file configuration |
Date: |
Wed, 11 Dec 2013 19:11:06 +0100 |
Introduce the "image" option as an alternative to specifying the image
through the filename.
Signed-off-by: Max Reitz <address@hidden>
---
block/blkdebug.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 35c2dae..b032fff 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -368,13 +368,35 @@ static QemuOptsList runtime_opts = {
},
};
+static int open_image(BlockDriverState **pbs, const char *fname, QDict
*options,
+ const char *bdref_key, int flags, Error **errp)
+{
+ QDict *image_options;
+ int ret;
+ char *bdref_key_dot;
+
+ bdref_key_dot = g_strdup_printf("%s.", bdref_key);
+ qdict_extract_subqdict(options, &image_options, bdref_key_dot);
+ g_free(bdref_key_dot);
+
+ /* Never use bdrv_open() here; if just a filename is given without further
+ options, bdrv_open() will try to open it with the block driver we are
+ about to test. bdrv_file_open() never does this. */
+ ret = bdrv_file_open(pbs, fname, qdict_get_try_str(options, bdref_key),
+ image_options, flags, errp);
+
+ qdict_del(options, bdref_key);
+
+ return ret;
+}
+
static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVBlkdebugState *s = bs->opaque;
QemuOpts *opts;
Error *local_err = NULL;
- const char *filename, *config;
+ const char *config;
int ret;
opts = qemu_opts_create_nofail(&runtime_opts);
@@ -396,14 +418,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict
*options, int flags,
s->state = 1;
/* Open the backing file */
- filename = qemu_opt_get(opts, "x-image");
- if (filename == NULL) {
- error_setg(errp, "Could not retrieve image file name");
- ret = -EINVAL;
- goto fail;
- }
-
- ret = bdrv_file_open(&bs->file, filename, NULL, NULL, flags, &local_err);
+ ret = open_image(&bs->file, qemu_opt_get(opts, "x-image"), options,
"image",
+ flags, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto fail;
--
1.8.5.1
- [Qemu-devel] [PATCH v3 06/21] blkdebug: Always call read_config(), (continued)
- [Qemu-devel] [PATCH v3 06/21] blkdebug: Always call read_config(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 07/21] blkdebug: Use command-line in read_config(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 08/21] block: Allow reference for bdrv_file_open(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 09/21] block: Pass reference to bdrv_file_open(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 10/21] block: Allow block devices without files, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 11/21] block: Allow recursive "file"s, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 12/21] qemu-iotests: Fix output of test 051, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 13/21] blockdev: Move "file" to legacy_opts, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 14/21] blkdebug: Allow command-line file configuration,
Max Reitz <=
- [Qemu-devel] [PATCH v3 15/21] blkdebug: Make filename optional, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 16/21] blkverify: Allow command-line configuration, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 17/21] blkverify: Don't require protocol filename, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 19/21] qapi: QMP interface for blkdebug and blkverify, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 18/21] blkdebug: Alias "errno" as "error", Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 20/21] qemu-io: Make filename optional, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 21/21] iotests: Test new blkdebug/blkverify interface, Max Reitz, 2013/12/11
- Re: [Qemu-devel] [PATCH v3 00/21] blkdebug/blkverify: Allow QMP configuration, Fam Zheng, 2013/12/12