qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 17/22] blkverify: Allow command-line configuration
Date: Sat, 14 Dec 2013 01:22:22 +0100	[thread overview]
Message-ID: <52ABA4BE.3070401@redhat.com> (raw)
In-Reply-To: <20131213204647.GE3916@dhcp-200-207.str.redhat.com>

On 13.12.2013 21:46, Kevin Wolf wrote:
> Am 13.12.2013 um 18:10 hat Max Reitz geschrieben:
>> Introduce the "test" and "raw" options for specifying images.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   block/blkverify.c | 59 ++++++++++++++++++++++++++++++++++++-------------------
>>   1 file changed, 39 insertions(+), 20 deletions(-)
>>
>> diff --git a/block/blkverify.c b/block/blkverify.c
>> index c6eb287..8bf81b5 100644
>> --- a/block/blkverify.c
>> +++ b/block/blkverify.c
>> @@ -116,13 +116,46 @@ 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);
>> +
>> +    if (fname) {
>> +        /* If a filename is given, use bdrv_open() in order to use the correct
>> +           block driver (instead of just opening the raw image). */
>> +
>> +        if (qdict_get_try_str(options, bdref_key)) {
>> +            error_setg(errp, "Cannot reference an existing block device while "
>> +                       "giving a filename");
>> +            ret = -EINVAL;
>> +            goto fail;
>> +        }
>> +
>> +        *pbs = bdrv_new("");
>> +        ret = bdrv_open(*pbs, fname, image_options, flags, NULL, errp);
>> +    } else {
>> +        ret = bdrv_file_open(pbs, NULL, qdict_get_try_str(options, bdref_key),
>> +                             image_options, flags, errp);
>> +    }
>> +
>> +fail:
>> +    qdict_del(options, bdref_key);
>> +    return ret;
>> +}
>> +
>>   static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
>>                             Error **errp)
>>   {
>>       BDRVBlkverifyState *s = bs->opaque;
>>       QemuOpts *opts;
>>       Error *local_err = NULL;
>> -    const char *filename, *raw;
>>       int ret;
>>   
>>       opts = qemu_opts_create_nofail(&runtime_opts);
>> @@ -133,33 +166,19 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
>>           goto fail;
>>       }
>>   
>> -    /* Parse the raw image filename */
>> -    raw = qemu_opt_get(opts, "x-raw");
>> -    if (raw == NULL) {
>> -        error_setg(errp, "Could not retrieve raw image filename");
>> -        ret = -EINVAL;
>> -        goto fail;
>> -    }
>> -
>> -    ret = bdrv_file_open(&bs->file, raw, NULL, NULL, flags, &local_err);
>> +    /* Open the raw file */
>> +    ret = open_image(&bs->file, qemu_opt_get(opts, "x-raw"), options, "raw",
>> +                     flags, &local_err);
> This changes the behaviour: We now do format probing, and probably
> insert a raw block driver between blkverify and the protocol driver.
>
> If you had a generalised open_image() that is shared with blkdebug, you
> could specify no probing here, and enable probing for the main image.

My main problem with a shared open_image() was finding a nice global 
name. ;-)

I think I'll add a flag for now. With that flag, we could easily make it 
global, but finding a nice name still remains a problem.

Max

  reply	other threads:[~2013-12-14  0:21 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13 17:10 [Qemu-devel] [PATCH v3 00/21] blkdebug/blkverify: Allow QMP configuration Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 01/22] blkdebug: Use errp for read_config() Max Reitz
2013-12-13 18:59   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 02/22] blkdebug: Don't require sophisticated filename Max Reitz
2013-12-13 19:00   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 03/22] qdict: Add qdict_array_split() Max Reitz
2013-12-13 19:00   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 04/22] qapi: extend qdict_flatten() for QLists Max Reitz
2013-12-13 19:01   ` Kevin Wolf
2013-12-13 20:04   ` Eric Blake
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 05/22] qdict: Remove delete from qdict_flatten_qdict() Max Reitz
2013-12-13 18:58   ` Kevin Wolf
2013-12-14  0:05     ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 06/22] qemu-option: Add qemu_config_parse_qdict() Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 07/22] blkdebug: Always call read_config() Max Reitz
2013-12-13 19:04   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 08/22] blkdebug: Use command-line in read_config() Max Reitz
2013-12-13 19:48   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 09/22] block: Allow reference for bdrv_file_open() Max Reitz
2013-12-13 19:54   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 10/22] block: Pass reference to bdrv_file_open() Max Reitz
2013-12-13 19:56   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 11/22] block: Allow block devices without files Max Reitz
2013-12-13 20:06   ` Kevin Wolf
2013-12-14  0:10     ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 12/22] block: Allow recursive "file"s Max Reitz
2013-12-13 20:19   ` Kevin Wolf
2013-12-13 20:36     ` Eric Blake
2013-12-13 21:21       ` Kevin Wolf
2013-12-14  0:16     ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 13/22] qemu-iotests: Fix output of test 051 Max Reitz
2013-12-13 20:21   ` Eric Blake
2013-12-13 20:21   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 14/22] blockdev: Move "file" to legacy_opts Max Reitz
2013-12-13 20:27   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 15/22] blkdebug: Allow command-line file configuration Max Reitz
2013-12-13 20:36   ` Kevin Wolf
2013-12-13 23:57     ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 16/22] blkdebug: Make filename optional Max Reitz
2013-12-13 20:43   ` Kevin Wolf
2013-12-14  0:27     ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 17/22] blkverify: Allow command-line configuration Max Reitz
2013-12-13 20:46   ` Kevin Wolf
2013-12-14  0:22     ` Max Reitz [this message]
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 18/22] blkverify: Don't require protocol filename Max Reitz
2013-12-13 20:47   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 19/22] blkdebug: Alias "errno" as "error" Max Reitz
2013-12-13 20:49   ` Kevin Wolf
2013-12-13 21:00     ` Eric Blake
2013-12-13 21:23       ` Kevin Wolf
2013-12-13 23:59       ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 20/22] qapi: QMP interface for blkdebug and blkverify Max Reitz
2013-12-13 20:54   ` Kevin Wolf
2013-12-13 21:03     ` Eric Blake
2013-12-14  0:20     ` Max Reitz
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 21/22] qemu-io: Make filename optional Max Reitz
2013-12-13 20:57   ` Kevin Wolf
2013-12-13 17:10 ` [Qemu-devel] [PATCH v5 22/22] iotests: Test new blkdebug/blkverify interface Max Reitz
2013-12-13 21:08   ` Kevin Wolf
2013-12-14  0:01     ` Max Reitz
2013-12-13 17:15 ` [Qemu-devel] [PATCH v3 00/21] blkdebug/blkverify: Allow QMP configuration Max Reitz

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=52ABA4BE.3070401@redhat.com \
    --to=mreitz@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).