From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8Cq7-0006pS-7B for qemu-devel@nongnu.org; Fri, 18 Jul 2014 14:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8Cq0-0006S7-VC for qemu-devel@nongnu.org; Fri, 18 Jul 2014 14:25:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8Cq0-0006S3-Mf for qemu-devel@nongnu.org; Fri, 18 Jul 2014 14:24:56 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6IIOulh005906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Jul 2014 14:24:56 -0400 From: Max Reitz Date: Fri, 18 Jul 2014 20:25:00 +0200 Message-Id: <1405707901-8253-6-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 5/6] quorum: 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/quorum.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index d5ee9c0..0de07bb 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -16,7 +16,12 @@ #include #include #include "block/block_int.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qstring.h" #include "qapi-event.h" #define HASH_LENGTH 32 @@ -945,6 +950,39 @@ static void quorum_attach_aio_context(BlockDriverState *bs, } } +static void quorum_refresh_filename(BlockDriverState *bs) +{ + BDRVQuorumState *s = bs->opaque; + QDict *opts; + QList *children; + int i; + + for (i = 0; i < s->num_children; i++) { + bdrv_refresh_filename(s->bs[i]); + if (!s->bs[i]->full_open_options) { + return; + } + } + + children = qlist_new(); + for (i = 0; i < s->num_children; i++) { + QINCREF(s->bs[i]->full_open_options); + qlist_append_obj(children, QOBJECT(s->bs[i]->full_open_options)); + } + + opts = qdict_new(); + qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("quorum"))); + qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD, + QOBJECT(qint_from_int(s->threshold))); + qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY, + QOBJECT(qbool_from_int(s->is_blkverify))); + qdict_put_obj(opts, QUORUM_OPT_REWRITE, + QOBJECT(qbool_from_int(s->rewrite_corrupted))); + qdict_put_obj(opts, "children", QOBJECT(children)); + + bs->full_open_options = opts; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", @@ -953,6 +991,7 @@ static BlockDriver bdrv_quorum = { .bdrv_file_open = quorum_open, .bdrv_close = quorum_close, + .bdrv_refresh_filename = quorum_refresh_filename, .bdrv_co_flush_to_disk = quorum_co_flush, -- 2.0.1