From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8Cq5-0006li-51 for qemu-devel@nongnu.org; Fri, 18 Jul 2014 14:25:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8Cpw-0006R0-Cf for qemu-devel@nongnu.org; Fri, 18 Jul 2014 14:25:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50977) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8Cpv-0006Qs-VP for qemu-devel@nongnu.org; Fri, 18 Jul 2014 14:24:52 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6IIOovu005545 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Jul 2014 14:24:51 -0400 From: Max Reitz Date: Fri, 18 Jul 2014 20:24:58 +0200 Message-Id: <1405707901-8253-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1405707901-8253-1-git-send-email-mreitz@redhat.com> References: <1405707901-8253-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 3/6] blkverify: Implement bdrv_refresh_filename() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Signed-off-by: Max Reitz --- block/blkverify.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/block/blkverify.c b/block/blkverify.c index 621b785..7c78ca4 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -10,6 +10,8 @@ #include #include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "block/block_int.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qstring.h" typedef struct { BlockDriverState *test_file; @@ -320,6 +322,32 @@ static void blkverify_attach_aio_context(BlockDriverState *bs, bdrv_attach_aio_context(s->test_file, new_context); } +static void blkverify_refresh_filename(BlockDriverState *bs) +{ + BDRVBlkverifyState *s = bs->opaque; + + /* bs->file has already been refreshed */ + bdrv_refresh_filename(s->test_file); + + if (bs->file->full_open_options && s->test_file->full_open_options) { + QDict *opts = qdict_new(); + qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify"))); + + QINCREF(bs->file->full_open_options); + qdict_put_obj(opts, "raw", QOBJECT(bs->file->full_open_options)); + QINCREF(s->test_file->full_open_options); + qdict_put_obj(opts, "test", QOBJECT(s->test_file->full_open_options)); + + bs->full_open_options = opts; + } + + if (bs->file->exact_filename[0] && s->test_file->exact_filename[0]) { + snprintf(bs->exact_filename, sizeof(bs->exact_filename), + "blkverify:%s:%s", + bs->file->exact_filename, s->test_file->exact_filename); + } +} + static BlockDriver bdrv_blkverify = { .format_name = "blkverify", .protocol_name = "blkverify", @@ -329,6 +357,7 @@ static BlockDriver bdrv_blkverify = { .bdrv_file_open = blkverify_open, .bdrv_close = blkverify_close, .bdrv_getlength = blkverify_getlength, + .bdrv_refresh_filename = blkverify_refresh_filename, .bdrv_aio_readv = blkverify_aio_readv, .bdrv_aio_writev = blkverify_aio_writev, -- 2.0.1