From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrZdQ-0000SI-9m for qemu-devel@nongnu.org; Fri, 13 Dec 2013 15:46:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrZdK-0006ty-9V for qemu-devel@nongnu.org; Fri, 13 Dec 2013 15:46:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrZdK-0006tj-22 for qemu-devel@nongnu.org; Fri, 13 Dec 2013 15:46:50 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBDKkniq024899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 15:46:49 -0500 Date: Fri, 13 Dec 2013 21:46:47 +0100 From: Kevin Wolf Message-ID: <20131213204647.GE3916@dhcp-200-207.str.redhat.com> References: <1386954633-28905-1-git-send-email-mreitz@redhat.com> <1386954633-28905-18-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1386954633-28905-18-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 17/22] blkverify: Allow command-line configuration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi 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 > --- > 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. Kevin