From patchwork Tue Feb 11 14:45:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 319307 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0245F2C0098 for ; Wed, 12 Feb 2014 01:46:17 +1100 (EST) Received: from localhost ([::1]:33957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDEbG-0001Zf-Mj for incoming@patchwork.ozlabs.org; Tue, 11 Feb 2014 09:46:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDEaW-0001ZK-NX for qemu-devel@nongnu.org; Tue, 11 Feb 2014 09:45:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDEaR-00053u-AA for qemu-devel@nongnu.org; Tue, 11 Feb 2014 09:45:28 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDEaQ-00053f-P5 for qemu-devel@nongnu.org; Tue, 11 Feb 2014 09:45:23 -0500 Received: from localhost.localdomain (laure.irqsave.net [192.168.77.2]) by paradis.irqsave.net (Postfix) with ESMTP id 73B9F618F6; Tue, 11 Feb 2014 16:22:36 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Tue, 11 Feb 2014 15:45:09 +0100 Message-Id: <1392129919-7764-3-git-send-email-benoit.canet@irqsave.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392129919-7764-1-git-send-email-benoit.canet@irqsave.net> References: <1392129919-7764-1-git-send-email-benoit.canet@irqsave.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 62.212.105.220 Cc: kwolf@redhat.com, famz@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH V16 02/12] quorum: Create BDRVQuorumState and BlkDriver and do init. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: BenoƮt Canet Create the structure holding the quorum settings and write the minimal block driver instanciation boilerplate. Signed-off-by: Benoit Canet Reviewed-by: Max Reitz --- block/quorum.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 173584b..1bc3390 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -15,6 +15,23 @@ #include "block/block_int.h" +/* the following structure holds the state of one quorum instance */ +typedef struct BDRVQuorumState { + BlockDriverState **bs; /* children BlockDriverStates */ + int num_children; /* children count */ + int threshold; /* if less than threshold children reads gave the + * same result a quorum error occurs. + */ + bool is_blkverify; /* true if the driver is in blkverify mode + * Writes are mirrored on two children devices. + * On reads the two children devices contents are + * compared and when a difference is spotted its + * location is printed and the code abort. + * It is useful to debug other block drivers by + * comparing them with a reference one. + */ +} BDRVQuorumState; + typedef struct QuorumAIOCB QuorumAIOCB; /* Quorum will create one instance of the following structure per operation it @@ -51,3 +68,17 @@ struct QuorumAIOCB { bool is_read; int vote_ret; }; + +static BlockDriver bdrv_quorum = { + .format_name = "quorum", + .protocol_name = "quorum", + + .instance_size = sizeof(BDRVQuorumState), +}; + +static void bdrv_quorum_init(void) +{ + bdrv_register(&bdrv_quorum); +} + +block_init(bdrv_quorum_init);