From nobody Tue Nov 4 13:06:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504272553816562.4903989633166; Fri, 1 Sep 2017 06:29:13 -0700 (PDT) Received: from localhost ([::1]:40271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnm0W-0005AY-Oj for importer@patchew.org; Fri, 01 Sep 2017 09:29:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnlUu-0000W6-UB for qemu-devel@nongnu.org; Fri, 01 Sep 2017 08:56:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnlUo-0007Rf-BI for qemu-devel@nongnu.org; Fri, 01 Sep 2017 08:56:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnlUo-0007R5-4S for qemu-devel@nongnu.org; Fri, 01 Sep 2017 08:56:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A61491FE8; Fri, 1 Sep 2017 12:56:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 431C77BB4F; Fri, 1 Sep 2017 12:56:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B643D1132F48; Fri, 1 Sep 2017 14:56:12 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A61491FE8 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 1 Sep 2017 14:56:03 +0200 Message-Id: <20170901125611.29295-40-armbru@redhat.com> In-Reply-To: <20170901125611.29295-1-armbru@redhat.com> References: <20170901125611.29295-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 01 Sep 2017 12:56:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 39/47] quorum: Use qapi_enum_parse() in quorum_open() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20170822132255.23945-12-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Rebased, qemu_opt_get() factored out, commit message tweaked] Cc: Alberto Garcia Reviewed-by: Alberto Garcia Signed-off-by: Markus Armbruster Message-Id: <1503564371-26090-9-git-send-email-armbru@redhat.com> --- block/quorum.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index d04da4f430..cb6617703c 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -22,6 +22,7 @@ #include "qapi/qmp/qjson.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qstring.h" +#include "qapi/util.h" #include "qapi-event.h" #include "crypto/hash.h" =20 @@ -867,30 +868,13 @@ static QemuOptsList quorum_runtime_opts =3D { }, }; =20 -static int parse_read_pattern(const char *opt) -{ - int i; - - if (!opt) { - /* Set quorum as default */ - return QUORUM_READ_PATTERN_QUORUM; - } - - for (i =3D 0; i < QUORUM_READ_PATTERN__MAX; i++) { - if (!strcmp(opt, QuorumReadPattern_lookup[i])) { - return i; - } - } - - return -EINVAL; -} - static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQuorumState *s =3D bs->opaque; Error *local_err =3D NULL; QemuOpts *opts =3D NULL; + const char *pattern_str; bool *opened; int i; int ret =3D 0; @@ -925,7 +909,13 @@ static int quorum_open(BlockDriverState *bs, QDict *op= tions, int flags, goto exit; } =20 - ret =3D parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN)= ); + pattern_str =3D qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN); + if (!pattern_str) { + ret =3D QUORUM_READ_PATTERN_QUORUM; + } else { + ret =3D qapi_enum_parse(QuorumReadPattern_lookup, pattern_str, + -EINVAL, NULL); + } if (ret < 0) { error_setg(&local_err, "Please set read-pattern as fifo or quorum"= ); goto exit; --=20 2.13.5