From nobody Wed May 14 10:40:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294553552917.3818122589398; Mon, 14 May 2018 03:42:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5980630D7A3A; Mon, 14 May 2018 10:42:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11BB3300165E; Mon, 14 May 2018 10:42:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 956763FCF9; Mon, 14 May 2018 10:42:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgJsW003639 for ; Mon, 14 May 2018 06:42:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 541202026DFD; Mon, 14 May 2018 10:42:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFEE52026E0E; Mon, 14 May 2018 10:42:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:56 +0200 Message-Id: <28711b0f32c873a870eae3fcbfd953c04b7dbc85.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/13] util: storage: Drop pointless 'enabled' form PR definition X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 14 May 2018 10:42:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Everything can be disabled by not using the parent element. There's no need to store this explicitly. Additionally it does not add any value since any configuration is dropped if enabled=3D'no' is configured. Drop the attribute and adjust the code accordingly.t Signed-off-by: Peter Krempa --- docs/formatdomain.html.in | 21 ++-- docs/schemas/storagecommon.rng | 3 - src/util/virstoragefile.c | 117 +++++++++--------= ---- src/util/virstoragefile.h | 1 - .../disk-virtio-scsi-reservations.xml | 4 +- 5 files changed, 59 insertions(+), 87 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 80172c18d0..d69a669259 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2583,7 +2583,7 @@ <disk type=3D'block' device=3D'lun'> <driver name=3D'qemu' type=3D'raw'/> <source dev=3D'/dev/sda'> - <reservations enabled=3D'yes' managed=3D'no'> + <reservations managed=3D'no'> <source type=3D'unix' path=3D'/path/to/qemu-pr-helper' mode=3D'= client'/> </reservations> <target dev=3D'sda' bus=3D'scsi'/> @@ -2952,17 +2952,16 @@
Since libvirt 4.4.0, the reservations can be a sub-element of the source element for storage sources (QEMU driver o= nly). - If present (and enabled) it enables persistent reservations fo= r SCSI + If present it enables persistent reservations for SCSI based disks. The element has one mandatory attribute - enabled with accepted values yes and - no. If the feature is enabled, then there's anoth= er - mandatory attribute managed (accepted values are = the - same as for enabled) that enables or disables lib= virt - spawning a helper process. When the PR is unmanaged, then hype= rvisor - acts as a client and path to server socket must be provided in= child - element source, which currently accepts only the - following attributes: type with one value - unix, path with path the socket, and + managed with accepted values yes and + no. If managed is enabled libvirt pr= epares + and manages any resources needed for the feature. When the PR = is + unmanaged, then hypervisor acts as a client and path to server + socket must be provided in child element source, + which currently accepts only the following attributes: + type with one value unix, + path with path the socket, and finally mode which accepts one value client and specifies the role of hypervisor. It's recommended to allow libvirt manage the persistent diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index eed0b33347..cb4f14f52f 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -75,9 +75,6 @@ - - - diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 87c3499561..d6907e47bb 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1906,8 +1906,8 @@ virStoragePRDefFree(virStoragePRDefPtr prd) virStoragePRDefPtr virStoragePRDefParseXML(xmlXPathContextPtr ctxt) { - virStoragePRDefPtr prd, ret =3D NULL; - char *enabled =3D NULL; + virStoragePRDefPtr prd; + virStoragePRDefPtr ret =3D NULL; char *managed =3D NULL; char *type =3D NULL; char *path =3D NULL; @@ -1916,81 +1916,65 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) if (VIR_ALLOC(prd) < 0) return NULL; - if (!(enabled =3D virXPathString("string(./@enabled)", ctxt))) { + if (!(managed =3D virXPathString("string(./@managed)", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing @enabled attribute for ")= ); + _("missing @managed attribute for ")= ); goto cleanup; } - if ((prd->enabled =3D virTristateBoolTypeFromString(enabled)) <=3D 0) { + if ((prd->managed =3D virTristateBoolTypeFromString(managed)) <=3D 0) { virReportError(VIR_ERR_XML_ERROR, - _("invalid value for 'enabled': %s"), enabled); + _("invalid value for 'managed': %s"), managed); goto cleanup; } - if (prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - if (!(managed =3D virXPathString("string(./@managed)", ctxt))) { + if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { + type =3D virXPathString("string(./source[1]/@type)", ctxt); + path =3D virXPathString("string(./source[1]/@path)", ctxt); + mode =3D virXPathString("string(./source[1]/@mode)", ctxt); + + if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing @managed attribute for ")); + _("missing connection type for "= )); goto cleanup; } - if ((prd->managed =3D virTristateBoolTypeFromString(managed)) <=3D= 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid value for 'managed': %s"), managed); + if (!path) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing path for ")); goto cleanup; } - if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { - type =3D virXPathString("string(./source[1]/@type)", ctxt); - path =3D virXPathString("string(./source[1]/@path)", ctxt); - mode =3D virXPathString("string(./source[1]/@mode)", ctxt); - - if (!type) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing connection type for ")); - goto cleanup; - } - - if (!path) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing path for ")); - goto cleanup; - } - - if (!mode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing connection mode for ")); - goto cleanup; - } - - if (STRNEQ(type, "unix")) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported connection type for : %s"), - type); - goto cleanup; - } + if (!mode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing connection mode for "= )); + goto cleanup; + } - if (STRNEQ(mode, "client")) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported connection mode for : %s"), - mode); - goto cleanup; - } + if (STRNEQ(type, "unix")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported connection type for : %s"), + type); + goto cleanup; + } - VIR_STEAL_PTR(prd->path, path); + if (STRNEQ(mode, "client")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported connection mode for : %s"), + mode); + goto cleanup; } + + VIR_STEAL_PTR(prd->path, path); } - ret =3D prd; - prd =3D NULL; + VIR_STEAL_PTR(ret, prd); cleanup: VIR_FREE(mode); VIR_FREE(path); VIR_FREE(type); VIR_FREE(managed); - VIR_FREE(enabled); virStoragePRDefFree(prd); return ret; } @@ -2000,22 +1984,16 @@ void virStoragePRDefFormat(virBufferPtr buf, virStoragePRDefPtr prd) { - virBufferAsprintf(buf, "enabled)); - if (prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(prd->managed)); - if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAddLit(buf, "path); - virBufferAddLit(buf, " mode=3D'client'/>\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } + virBufferAsprintf(buf, "managed)); + if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAddLit(buf, "path); + virBufferAddLit(buf, " mode=3D'client'/>\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); } @@ -2032,8 +2010,7 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a, if (!a || !b) return false; - if (a->enabled !=3D b->enabled || - a->managed !=3D b->managed || + if (a->managed !=3D b->managed || STRNEQ_NULLABLE(a->path, b->path)) return false; @@ -2044,7 +2021,7 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a, bool virStoragePRDefIsEnabled(virStoragePRDefPtr prd) { - return prd && prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES; + return !!prd; } diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 0bba016e4e..ec49152880 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -219,7 +219,6 @@ struct _virStorageAuthDef { typedef struct _virStoragePRDef virStoragePRDef; typedef virStoragePRDef *virStoragePRDefPtr; struct _virStoragePRDef { - int enabled; /* enum virTristateBool */ int managed; /* enum virTristateBool */ char *path; }; diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml b/tes= ts/qemuxml2argvdata/disk-virtio-scsi-reservations.xml index 036c6e3c25..acad600ef8 100644 --- a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml +++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml @@ -17,7 +17,7 @@ - +
@@ -25,7 +25,7 @@ - + --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list