From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291534225180.43131483934212; Thu, 18 Jan 2018 08:05:34 -0800 (PST) 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 948A199DDF; Thu, 18 Jan 2018 16:05:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60DDA4A2; Thu, 18 Jan 2018 16:05:32 +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 2259A18033E0; Thu, 18 Jan 2018 16:05:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG4vH4023652 for ; Thu, 18 Jan 2018 11:04:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 47FEF4C1; Thu, 18 Jan 2018 16:04:57 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9BF44B4; Thu, 18 Jan 2018 16:04:55 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:33 +0100 Message-Id: <5d7e0dc9b10c0aa3195111202271212574ba4ce2.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 01/14] virstoragefile: Introduce virStoragePRDef 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.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.38]); Thu, 18 Jan 2018 16:05:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is a definition that holds information on SCSI persistent reservation settings. The XML part looks like this: If @managed is set to 'yes' then the is not parsed. This design was agreed on here: https://www.redhat.com/archives/libvir-list/2017-November/msg01005.html Signed-off-by: Michal Privoznik --- docs/formatdomain.html.in | 25 +++- docs/schemas/domaincommon.rng | 19 +-- docs/schemas/storagecommon.rng | 34 +++++ src/conf/domain_conf.c | 36 +++++ src/libvirt_private.syms | 3 + src/util/virstoragefile.c | 148 +++++++++++++++++= ++++ src/util/virstoragefile.h | 15 +++ .../disk-virtio-scsi-reservations-not-managed.xml | 40 ++++++ .../disk-virtio-scsi-reservations.xml | 38 ++++++ .../disk-virtio-scsi-reservations-not-managed.xml | 1 + .../disk-virtio-scsi-reservations.xml | 1 + tests/qemuxml2xmltest.c | 4 + 12 files changed, 348 insertions(+), 16 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations-no= t-managed.xml create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml create mode 120000 tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations-= not-managed.xml create mode 120000 tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations.= xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d272cc1ba..23c5f071e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2457,7 +2457,10 @@ </disk> <disk type=3D'block' device=3D'lun'> <driver name=3D'qemu' type=3D'raw'/> - <source dev=3D'/dev/sda'/> + <source dev=3D'/dev/sda'> + <reservations enabled=3D'yes' 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'/> <address type=3D'drive' controller=3D'0' bus=3D'0' target=3D'3' uni= t=3D'0'/> </disk> @@ -2819,6 +2822,26 @@ Storage Encryption page for more information. +
reservations
+
Since libvirt 3.10.0, the + reservations can be a sub-element of the + source element for storage sources (QEMU driver o= nly). + If present (and enabled) it enabled 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 any helper process (should one be needed). However, if + libvirt is not enabled spawning helper process (i.e. hypervisor + should just use one which is already running), path to its soc= ket + 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 either + server or client and specifies the r= ole + of hypervisor. +
=20

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f22c932f6..884081bd7 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1498,6 +1498,9 @@ + + + @@ -2447,21 +2450,7 @@ vhostuser - - - unix - - - - - - - server - client - - - - + diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index edee1b084..9071667b0 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -39,6 +39,40 @@ =20 + + + + unix + + + + + + + server + client + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a1c25060f..222c6dd15 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5163,6 +5163,13 @@ virDomainDiskDefValidate(const virDomainDiskDef *dis= k) } } =20 + if (disk->src->pr && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_LUN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _(" allowed only for lun disks")); + return -1; + } + /* Reject disks with a bus type that is not compatible with the * given address type. The function considers only buses that are * handled in common code. For other bus types it's not possible @@ -8579,6 +8586,29 @@ virDomainDiskSourcePrivateDataParse(xmlXPathContextP= tr ctxt, } =20 =20 +static int +virDomainDiskSourcePRParse(xmlNodePtr node, + virStoragePRDefPtr *prsrc) +{ + xmlNodePtr child; + virStoragePRDefPtr pr =3D NULL; + + for (child =3D node->children; child; child =3D child->next) { + if (child->type =3D=3D XML_ELEMENT_NODE && + virXMLNodeNameEqual(child, "reservations")) { + + if (!(pr =3D virStoragePRDefParseNode(node->doc, child))) + return -1; + + *prsrc =3D pr; + return 0; + } + } + + return 0; +} + + int virDomainDiskSourceParse(xmlNodePtr node, xmlXPathContextPtr ctxt, @@ -8623,6 +8653,9 @@ virDomainDiskSourceParse(xmlNodePtr node, if (virDomainDiskSourceEncryptionParse(node, &src->encryption) < 0) goto cleanup; =20 + if (virDomainDiskSourcePRParse(node, &src->pr) < 0) + goto cleanup; + if (virDomainDiskSourcePrivateDataParse(ctxt, src, flags, xmlopt) < 0) goto cleanup; =20 @@ -22519,6 +22552,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, virStorageEncryptionFormat(&childBuf, src->encryption) < 0) return -1; =20 + if (src->pr) + virStoragePRDefFormat(&childBuf, src->pr); + if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xm= lopt) < 0) return -1; =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bc8cc1fba..b0dc76b91 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2717,6 +2717,9 @@ virStorageNetHostDefFree; virStorageNetHostTransportTypeFromString; virStorageNetHostTransportTypeToString; virStorageNetProtocolTypeToString; +virStoragePRDefFormat; +virStoragePRDefFree; +virStoragePRDefParseNode; virStorageSourceBackingStoreClear; virStorageSourceClear; virStorageSourceCopy; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5780180a9..fda6617f7 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1913,6 +1913,153 @@ virStorageAuthDefFormat(virBufferPtr buf, } =20 =20 +void +virStoragePRDefFree(virStoragePRDefPtr prd) +{ + if (!prd) + return; + + VIR_FREE(prd->path); + VIR_FREE(prd); +} + + +static virStoragePRDefPtr +virStoragePRDefParseXML(xmlXPathContextPtr ctxt) +{ + virStoragePRDefPtr prd, ret =3D NULL; + char *enabled =3D NULL; + char *managed =3D NULL; + char *type =3D NULL; + char *path =3D NULL; + char *mode =3D NULL; + + if (VIR_ALLOC(prd) < 0) + return NULL; + + if (!(enabled =3D virXPathString("string(./@enabled)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing @enabled attribute for ")= ); + goto cleanup; + } + + if ((prd->enabled =3D virTristateBoolTypeFromString(enabled)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid value for 'enabled': %s"), NULLSTR(enabl= ed)); + goto cleanup; + } + + if (prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { + managed =3D virXPathString("string(./@managed)", ctxt); + if ((prd->managed =3D virTristateBoolTypeFromString(managed)) <=3D= 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid value for 'managed': %s"), NULLSTR(m= anaged)); + 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")); + goto cleanup; + } + + if (!path) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing path")); + goto cleanup; + } + + if (!mode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing connection mode")); + goto cleanup; + } + + if (STRNEQ(type, "unix")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported type: %s"), type); + goto cleanup; + } + + if (STRNEQ(mode, "client")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported mode: %s"), mode); + goto cleanup; + } + + prd->path =3D path; + path =3D NULL; + + } + } + + ret =3D prd; + prd =3D NULL; + + cleanup: + VIR_FREE(mode); + VIR_FREE(path); + VIR_FREE(type); + VIR_FREE(managed); + VIR_FREE(enabled); + virStoragePRDefFree(prd); + return ret; +} + + +virStoragePRDefPtr +virStoragePRDefParseNode(xmlDocPtr xml, + xmlNodePtr root) +{ + xmlXPathContextPtr ctxt =3D NULL; + virStoragePRDefPtr prd =3D NULL; + + ctxt =3D xmlXPathNewContext(xml); + if (ctxt =3D=3D NULL) { + virReportOOMError(); + goto cleanup; + } + + ctxt->node =3D root; + prd =3D virStoragePRDefParseXML(ctxt); + + cleanup: + xmlXPathFreeContext(ctxt); + return prd; +} + + +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"); + } + } else { + virBufferAddLit(buf, "/>\n"); + } +} + + virSecurityDeviceLabelDefPtr virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src, const char *model) @@ -2291,6 +2438,7 @@ virStorageSourceClear(virStorageSourcePtr def) virBitmapFree(def->features); VIR_FREE(def->compat); virStorageEncryptionFree(def->encryption); + virStoragePRDefFree(def->pr); virStorageSourceSeclabelsClear(def); virStoragePermsFree(def->perms); VIR_FREE(def->timestamps); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index ecd806c93..f82c20cf4 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -216,6 +216,14 @@ struct _virStorageAuthDef { virSecretLookupTypeDef seclookupdef; }; =20 +typedef struct _virStoragePRDef virStoragePRDef; +typedef virStoragePRDef *virStoragePRDefPtr; +struct _virStoragePRDef { + int enabled; /* enum virTristateBool */ + int managed; /* enum virTristateBool */ + char *path; +}; + typedef struct _virStorageDriverData virStorageDriverData; typedef virStorageDriverData *virStorageDriverDataPtr; =20 @@ -243,6 +251,7 @@ struct _virStorageSource { bool authInherited; virStorageEncryptionPtr encryption; bool encryptionInherited; + virStoragePRDefPtr pr; =20 virObjectPtr privateData; =20 @@ -369,6 +378,12 @@ virStorageAuthDefPtr virStorageAuthDefCopy(const virSt= orageAuthDef *src); virStorageAuthDefPtr virStorageAuthDefParse(xmlDocPtr xml, xmlNodePtr root= ); int virStorageAuthDefFormat(virBufferPtr buf, virStorageAuthDefPtr authdef= ); =20 +void virStoragePRDefFree(virStoragePRDefPtr prd); +virStoragePRDefPtr virStoragePRDefParseNode(xmlDocPtr xml, + xmlNodePtr root); +void virStoragePRDefFormat(virBufferPtr buf, + virStoragePRDefPtr prd); + virSecurityDeviceLabelDefPtr virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src, const char *model); diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-manag= ed.xml b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.x= ml new file mode 100644 index 000000000..8ee623a70 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.xml @@ -0,0 +1,40 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 8 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + +

+ + +
+ + + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml b/tes= ts/qemuxml2argvdata/disk-virtio-scsi-reservations.xml new file mode 100644 index 000000000..874446f7b --- /dev/null +++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 8 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + +
+ + +
+ + + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations-not-man= aged.xml b/tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations-not-manag= ed.xml new file mode 120000 index 000000000..f96d62cb6 --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations-not-managed.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations.xml b/t= ests/qemuxml2xmloutdata/disk-virtio-scsi-reservations.xml new file mode 120000 index 000000000..dde52fd1d --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/disk-virtio-scsi-reservations.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 2be8eb2c1..3d70f13c8 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -531,6 +531,10 @@ mymain(void) QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-virtio-scsi-num_queues", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); + DO_TEST("disk-virtio-scsi-reservations", + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); + DO_TEST("disk-virtio-scsi-reservations-not-managed", + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-virtio-scsi-cmd_per_lun", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-virtio-scsi-max_sectors", --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291505294354.81071549764533; Thu, 18 Jan 2018 08:05:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EE6B9B2EE; Thu, 18 Jan 2018 16:05:03 +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 3FE615DD6C; Thu, 18 Jan 2018 16:05:03 +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 69A6E5FBD9; Thu, 18 Jan 2018 16:05:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG50C6023675 for ; Thu, 18 Jan 2018 11:05:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id D85B54A8; Thu, 18 Jan 2018 16:05:00 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id D22484C2; Thu, 18 Jan 2018 16:04:57 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:34 +0100 Message-Id: <307c509332ed8df854d0daf6b91adf6eef8fd907.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 02/14] qemuDomainDiskChangeSupported: Deny changing reservations 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 18 Jan 2018 16:05:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Couple of reasons for that: a) there's no monitor command to change path where the pr-helper connects to, or b) there's no monitor command to introduce a new pr-helper for a disk that already exists. Signed-off-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 8 ++++++++ src/util/virstoragefile.c | 18 ++++++++++++++++++ src/util/virstoragefile.h | 2 ++ 4 files changed, 29 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b0dc76b91..424f2ef64 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2719,6 +2719,7 @@ virStorageNetHostTransportTypeToString; virStorageNetProtocolTypeToString; virStoragePRDefFormat; virStoragePRDefFree; +virStoragePRDefIsEqual; virStoragePRDefParseNode; virStorageSourceBackingStoreClear; virStorageSourceClear; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 441bf5935..e8539dcab 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6865,6 +6865,14 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr di= sk, CHECK_EQ(src->readonly, "readonly", true); CHECK_EQ(src->shared, "shared", true); =20 + if (!virStoragePRDefIsEqual(disk->src->pr, + orig_disk->src->pr)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot modify field '%s' of the disk"), + "reservations"); + return false; + } + #undef CHECK_EQ =20 return true; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index fda6617f7..469f7c97b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2060,6 +2060,24 @@ virStoragePRDefFormat(virBufferPtr buf, } =20 =20 +bool +virStoragePRDefIsEqual(virStoragePRDefPtr a, + virStoragePRDefPtr b) +{ + if (!a && !b) + return true; + + if (!a || !b) + return false; + + if (a->enabled !=3D b->enabled || + a->managed !=3D b->managed || + STRNEQ_NULLABLE(a->path, b->path)) + return false; + + return true; +} + virSecurityDeviceLabelDefPtr virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src, const char *model) diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index f82c20cf4..d07035d65 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -383,6 +383,8 @@ virStoragePRDefPtr virStoragePRDefParseNode(xmlDocPtr x= ml, xmlNodePtr root); void virStoragePRDefFormat(virBufferPtr buf, virStoragePRDefPtr prd); +bool virStoragePRDefIsEqual(virStoragePRDefPtr a, + virStoragePRDefPtr b); =20 virSecurityDeviceLabelDefPtr virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291555620528.1682777631049; Thu, 18 Jan 2018 08:05:55 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 210D4C07F9B0; Thu, 18 Jan 2018 16:05:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E473518A37; Thu, 18 Jan 2018 16:05:53 +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 A972618033E9; Thu, 18 Jan 2018 16:05:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG513M023686 for ; Thu, 18 Jan 2018 11:05:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id CEB264A8; Thu, 18 Jan 2018 16:05:01 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 312F84A2; Thu, 18 Jan 2018 16:05:01 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:35 +0100 Message-Id: <6c93ef07a56fcf4ca14fa02ed3e4e6c72d8fe8c7.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 03/14] qemu: Introduce pr-manager-helper capability 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 Jan 2018 16:05:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The capability tracks if qemu has pr-manager-helper object. Signed-off-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ab0ea8ec0..f6abc33ce 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -457,6 +457,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 280 */ "pl011", "machine.pseries.max-cpu-compat", + "pr-manager-helper", ); =20 =20 @@ -1690,6 +1691,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE }, { "isa-serial", QEMU_CAPS_DEVICE_ISA_SERIAL }, { "pl011", QEMU_CAPS_DEVICE_PL011 }, + { "pr-manager-helper", QEMU_CAPS_PR_MANAGER_HELPER }, }; =20 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[]= =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3dfc77f87..44eba98ec 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -443,6 +443,7 @@ typedef enum { /* 280 */ QEMU_CAPS_DEVICE_PL011, /* -device pl011 (not user-instantiable) */ QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT, /* -machine pseries,max-cpu-= compat=3D */ + QEMU_CAPS_PR_MANAGER_HELPER, /* -object pr-manager-helper */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291516015675.3979949414585; Thu, 18 Jan 2018 08:05:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 404F14E918; Thu, 18 Jan 2018 16:05:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14DD318A5F; Thu, 18 Jan 2018 16:05:14 +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 CEBBB18033DB; Thu, 18 Jan 2018 16:05:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG5Cws023717 for ; Thu, 18 Jan 2018 11:05:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0254A171E5; Thu, 18 Jan 2018 16:05:12 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84CA851895; Thu, 18 Jan 2018 16:05:01 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:36 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 04/14] qemu_domain: Introduce qemuDomainDiskPRObject 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 18 Jan 2018 16:05:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is an extended definition of virStoragePRDef because it contains runtime information (like path to pr helper socket, its pid and alias). Since these are driver dependant we should have a driver specific structure instead of putting all of that into driver agnostic structure. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 120 +++++++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_domain.h | 18 ++++++++ 2 files changed, 138 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e8539dcab..7fa8c93b7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -65,6 +65,7 @@ #endif #include #include +#include #if defined(HAVE_SYS_MOUNT_H) # include #endif @@ -1829,6 +1830,9 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) =20 virBitmapFree(priv->migrationCaps); priv->migrationCaps =3D NULL; + + virHashFree(priv->prHelpers); + priv->prHelpers =3D NULL; } =20 =20 @@ -10917,6 +10921,122 @@ qemuDomainCheckMigrationCapabilities(virQEMUDrive= rPtr driver, } =20 =20 +static void +qemuDomainDiskPRObjectHashFree(void *payload, + const void *name) +{ + qemuDomainDiskPRObjectPtr tmp =3D payload; + + if (tmp->managed && + tmp->pid !=3D (pid_t) -1) { + VIR_DEBUG("Forcibly killing pr-manager: %s", (const char *) name); + virProcessKillPainfully(tmp->pid, true); + } + VIR_FREE(tmp->path); + VIR_FREE(tmp); +} + + +/** + * qemuDomainDiskPRObjectRegister: + * @priv: Domain private data + * @alias: alias of the pr-manager object + * @managed: true if pr-managed object is manged by libvirt + * @path: socket path for the pr-manager object + * + * Records [alias, managed, path] tuple for pr-manager objects. + * On successful return @path is stolen and set to NULL. + * + * Returns 0 on success (with @path stolen), + * -1 otherwise (with error reported). + */ +int +qemuDomainDiskPRObjectRegister(qemuDomainObjPrivatePtr priv, + const char *alias, + bool managed, + char **path) +{ + qemuDomainDiskPRObjectPtr tmp; + int ret =3D -1; + + if (!priv->prHelpers && + !(priv->prHelpers =3D virHashCreate(10, qemuDomainDiskPRObjectHash= Free))) + return -1; + + if ((tmp =3D virHashLookup(priv->prHelpers, alias))) { + /* Entry exists, check if it matches path. This shouldn't + * happen, but it's better to be safe than sorry. */ + if (STRNEQ(tmp->path, *path)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("trying to change path for pr helper object")= ); + + return -1; + } + + /* Claim success */ + VIR_FREE(*path); + return 0; + } + + if (VIR_ALLOC(tmp) < 0) + goto cleanup; + + tmp->managed =3D managed, + tmp->path =3D *path; + tmp->pid =3D (pid_t) -1; + + if (virHashAddEntry(priv->prHelpers, alias, tmp) < 0) + goto cleanup; + + *path =3D NULL; + tmp =3D NULL; + ret =3D 0; + cleanup: + VIR_FREE(tmp); + return ret; +} + + +static int +qemuDomainDiskPRObjectKillOne(void *payload, + const void *name, + void *data ATTRIBUTE_UNUSED) +{ + qemuDomainDiskPRObjectPtr tmp =3D payload; + + if (!tmp->managed) + return 0; + + VIR_DEBUG("Killing pr-manager: %s", (const char *) name); + if (tmp->pid !=3D (pid_t) -1 && + virProcessKill(tmp->pid, SIGTERM) < 0) { + virReportSystemError(errno, + _("Unable to kill pr-manager: %s"), + (const char *) name); + /* Don't return error; we want to kill as many as + * possible. */ + } else { + tmp->pid =3D (pid_t) -1; + } + + return 0; +} + + +void +qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivatePtr priv) +{ + if (!priv->prHelpers) + return; + + virHashForEach(priv->prHelpers, + qemuDomainDiskPRObjectKillOne, NULL); + + virHashFree(priv->prHelpers); + priv->prHelpers =3D NULL; +} + + int qemuDomainPrepareDiskSource(virConnectPtr conn, virDomainDiskDefPtr disk, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ddfc46dcd..f741f3039 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -329,6 +329,8 @@ struct _qemuDomainObjPrivate { /* Migration capabilities. Rechecked on reconnect, not to be saved in * private XML. */ virBitmapPtr migrationCaps; + + virHashTablePtr prHelpers; }; =20 # define QEMU_DOMAIN_PRIVATE(vm) \ @@ -990,4 +992,20 @@ qemuDomainPrepareDiskSource(virConnectPtr conn, qemuDomainObjPrivatePtr priv, virQEMUDriverConfigPtr cfg); =20 +typedef struct _qemuDomainDiskPRObject qemuDomainDiskPRObject; +typedef qemuDomainDiskPRObject *qemuDomainDiskPRObjectPtr; +struct _qemuDomainDiskPRObject { + bool managed; + char *path; /* socket path */ + pid_t pid; /* daemon pid */ +}; + +int +qemuDomainDiskPRObjectRegister(qemuDomainObjPrivatePtr priv, + const char *alias, + bool managed, + char **path); +void +qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivatePtr priv); + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291533182728.3218026805941; Thu, 18 Jan 2018 08:05:33 -0800 (PST) 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 DA084D77F5; Thu, 18 Jan 2018 16:05: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 B45A751895; Thu, 18 Jan 2018 16:05: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 7D4365FBDF; Thu, 18 Jan 2018 16:05:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG5Pmv023743 for ; Thu, 18 Jan 2018 11:05:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id D0A3D4D8; Thu, 18 Jan 2018 16:05:25 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 976864C3; Thu, 18 Jan 2018 16:05:12 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:37 +0100 Message-Id: <8d785dde5fc0def2dbb78671003e2907bac7f980.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 05/14] qemu: Generate alias for pr-helper 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.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.38]); Thu, 18 Jan 2018 16:05:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While we're not generating the command line just yet (look for the next commit), we can generate the alias for pr-manager. A domain can have up to one managed pr-manager (in which case socket path is decided by libvirt and pr-helper is spawned by libvirt too), but up to ndisks of unmanaged ones (one per disk basically). In case of the former we can generate a simple alias and be sure it'll not conflict. But in case of the latter to avoid any conflicts let's generate alias that's based on something unique - like disk target. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 64 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7fa8c93b7..e8d2adf56 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -972,6 +972,8 @@ qemuDomainStorageSourcePrivateDispose(void *obj) =20 qemuDomainSecretInfoFree(&priv->secinfo); qemuDomainSecretInfoFree(&priv->encinfo); + + VIR_FREE(priv->prAlias); } =20 =20 @@ -11037,6 +11039,62 @@ qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivate= Ptr priv) } =20 =20 +static int +qemuDomainPrepareDiskPR(qemuDomainObjPrivatePtr priv, + virDomainDiskDefPtr disk) +{ + qemuDomainStorageSourcePrivatePtr srcPriv; + virStoragePRDefPtr prd =3D disk->src->pr; + char *prPath =3D NULL; + bool managed; + int ret =3D -1; + + if (!prd || + prd->enabled !=3D VIR_TRISTATE_BOOL_YES) + return 0; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("reservations not supported with this QEMU binary= ")); + goto cleanup; + } + + if (!disk->src->privateData && + !(disk->src->privateData =3D qemuDomainStorageSourcePrivateNew())) + return -1; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + managed =3D prd->managed =3D=3D VIR_TRISTATE_BOOL_YES; + + if (managed) { + /* Generate PR helper socket path & alias that are same + * for each disk in the domain. */ + + if (VIR_STRDUP(srcPriv->prAlias, "pr-helper0") < 0) + return -1; + + if (virAsprintf(&prPath, "%s/pr-helper0.sock", priv->libDir) < 0) + return -1; + + } else { + if (virAsprintf(&srcPriv->prAlias, "pr-helper-%s", disk->dst) < 0) + return -1; + + if (VIR_STRDUP(prPath, prd->path) < 0) + return -1; + } + + if (qemuDomainDiskPRObjectRegister(priv, srcPriv->prAlias, + managed, &prPath) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + VIR_FREE(prPath); + return ret; +} + + int qemuDomainPrepareDiskSource(virConnectPtr conn, virDomainDiskDefPtr disk, @@ -11049,6 +11107,9 @@ qemuDomainPrepareDiskSource(virConnectPtr conn, if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0) return -1; =20 + if (qemuDomainPrepareDiskPR(priv, disk) < 0) + return -1; + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f741f3039..5fdb5b931 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -375,6 +375,9 @@ struct _qemuDomainStorageSourcePrivate { =20 /* data required for decryption of encrypted storage source */ qemuDomainSecretInfoPtr encinfo; + + /* alias for pr-manager-helper */ + char *prAlias; }; =20 virObjectPtr qemuDomainStorageSourcePrivateNew(void); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291539752222.7692544860805; Thu, 18 Jan 2018 08:05:39 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 996DC7109E; Thu, 18 Jan 2018 16:05:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71FF21815E; Thu, 18 Jan 2018 16:05:35 +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 3BCF518033E2; Thu, 18 Jan 2018 16:05:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG5Sw9023756 for ; Thu, 18 Jan 2018 11:05:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id DC78951895; Thu, 18 Jan 2018 16:05:28 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 403BD17109; Thu, 18 Jan 2018 16:05:25 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:38 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 06/14] qemu: Store prAlias and prPath in status XML 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 18 Jan 2018 16:05:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we generate pr-manger alias and socket path store them in status XML so that they are preserved across daemon restarts. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e8d2adf56..97996b053 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2449,6 +2449,74 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, } =20 =20 +static int +qemuStorageSourcePrivateDataParsePR(xmlXPathContextPtr ctxt, + virStorageSourcePtr src) +{ + qemuDomainStorageSourcePrivatePtr srcPriv; + + if (!src->pr || + src->pr->enabled !=3D VIR_TRISTATE_BOOL_YES) + return 0; + + if (!src->privateData && + !(src->privateData =3D qemuDomainStorageSourcePrivateNew())) + return -1; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); + + if (!(srcPriv->prAlias =3D virXPathString("string(./prAlias)", ctxt))) + return -1; + + return 0; +} + + +static int +qemuStorageSourcePrivateDataFormatPR(virStorageSourcePtr src, + virBufferPtr buf) +{ + qemuDomainStorageSourcePrivatePtr srcPriv; + + if (!src->pr || + src->pr->enabled !=3D VIR_TRISTATE_BOOL_YES) + return 0; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); + + virBufferAsprintf(buf, "%s\n", srcPriv->prAlias); + return 0; +} + + +static int +qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt, + virStorageSourcePtr src) +{ + if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0) + return -1; + + if (qemuStorageSourcePrivateDataParsePR(ctxt, src) < 0) + return -1; + + return 0; +} + + +static int +qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src, + virBufferPtr buf) +{ + if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0) + return -1; + + if (qemuStorageSourcePrivateDataFormatPR(src, buf) < 0) + return -1; + + return 0; +} + + virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks =3D { .alloc =3D qemuDomainObjPrivateAlloc, .free =3D qemuDomainObjPrivateFree, @@ -2457,8 +2525,8 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivate= DataCallbacks =3D { .chrSourceNew =3D qemuDomainChrSourcePrivateNew, .parse =3D qemuDomainObjPrivateXMLParse, .format =3D qemuDomainObjPrivateXMLFormat, - .storageParse =3D virStorageSourcePrivateDataParseRelPath, - .storageFormat =3D virStorageSourcePrivateDataFormatRelPath, + .storageParse =3D qemuStorageSourcePrivateDataParse, + .storageFormat =3D qemuStorageSourcePrivateDataFormat, }; =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291588433476.69946619455027; Thu, 18 Jan 2018 08:06:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92DD0C05972A; Thu, 18 Jan 2018 16:06:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45D7A18AC3; Thu, 18 Jan 2018 16:06:15 +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 9B62218033EE; Thu, 18 Jan 2018 16:06:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG5W1Z023768 for ; Thu, 18 Jan 2018 11:05:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 01F324A8; Thu, 18 Jan 2018 16:05:32 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59D2A51893; Thu, 18 Jan 2018 16:05:29 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:39 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 07/14] qemu: Generate cmd line at startup 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Jan 2018 16:06:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is the easier part. All we need to do here is put -object pr-manger-helper,id=3D$alias,path=3D$socketPath and then just reference the object in -drive file.pr-manger=3D$alias. Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 59 ++++++++++++++++++= ++++ .../disk-virtio-scsi-reservations-not-managed.args | 28 ++++++++++ .../disk-virtio-scsi-reservations.args | 29 +++++++++++ tests/qemuxml2argvtest.c | 8 +++ 4 files changed, 124 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations-no= t-managed.args create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations.ar= gs diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b8aede32d..13f2e4fd0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1515,6 +1515,20 @@ qemuDiskSourceGetProps(virStorageSourcePtr src) } =20 =20 +static void +qemuBuildDriveSourcePR(virBufferPtr buf, + virStorageSourcePtr src) +{ + qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + + if (!src->pr || + src->pr->enabled !=3D VIR_TRISTATE_BOOL_YES) + return; + + virBufferAsprintf(buf, ",file.pr-manager=3D%s", srcPriv->prAlias); +} + + static int qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, @@ -1591,6 +1605,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, =20 if (disk->src->debug) virBufferAsprintf(buf, ",file.debug=3D%d", disk->src->debugLev= el); + + qemuBuildDriveSourcePR(buf, disk->src); } else { if (!(source =3D virQEMUBuildDriveCommandlineFromJSON(srcprops))) goto cleanup; @@ -10033,6 +10049,46 @@ qemuBuildPanicCommandLine(virCommandPtr cmd, } =20 =20 +struct qemuBuildMasterPRCommandLineData { + virCommandPtr cmd; +}; + + +static int +qemuBuildMasterPRCommandLineHelper(void *payload, + const void *name, + void *opaque) +{ + qemuDomainDiskPRObjectPtr obj =3D payload; + struct qemuBuildMasterPRCommandLineData *data =3D opaque; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + const char *alias =3D name; + + virBufferAsprintf(&buf, "pr-manager-helper,id=3D%s,path=3D%s", alias, = obj->path); + virCommandAddArg(data->cmd, "-object"); + virCommandAddArgBuffer(data->cmd, &buf); + return 0; +} + + +static int +qemuBuildMasterPRCommandLine(virCommandPtr cmd, + qemuDomainObjPrivatePtr priv) +{ + struct qemuBuildMasterPRCommandLineData data =3D {.cmd =3D cmd }; + int ret =3D -1; + + if (priv->prHelpers && + virHashForEach(priv->prHelpers, + qemuBuildMasterPRCommandLineHelper, &data) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + return ret; +} + + /** * qemuBuildCommandLineValidate: * @@ -10185,6 +10241,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0) goto error; =20 + if (qemuBuildMasterPRCommandLine(cmd, priv) < 0) + goto error; + if (enableFips) virCommandAddArg(cmd, "-enable-fips"); =20 diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-manag= ed.args b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.= args new file mode 100644 index 000000000..387432c18 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.args @@ -0,0 +1,28 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-object pr-manager-helper,id=3Dpr-helper-sdb,path=3D/path/to/qemu-pr-helpe= r.sock \ +-M pc \ +-m 214 \ +-smp 8,sockets=3D8,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-device virtio-scsi-pci,id=3Dscsi0,num_queues=3D8,bus=3Dpci.0,addr=3D0x3 \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,file.pr-manager=3Dpr-helper-sdb,forma= t=3Draw,\ +if=3Dnone,id=3Ddrive-scsi0-0-0-0,boot=3Don \ +-device scsi-block,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +drive=3Ddrive-scsi0-0-0-0,id=3Dscsi0-0-0-0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.args b/te= sts/qemuxml2argvdata/disk-virtio-scsi-reservations.args new file mode 100644 index 000000000..2dc53cf05 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.args @@ -0,0 +1,29 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-object pr-manager-helper,id=3Dpr-helper0,\ +path=3D/tmp/lib/domain--1-QEMUGuest1/pr-helper0.sock \ +-M pc \ +-m 214 \ +-smp 8,sockets=3D8,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-device virtio-scsi-pci,id=3Dscsi0,num_queues=3D8,bus=3Dpci.0,addr=3D0x3 \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,file.pr-manager=3Dpr-helper0,format= =3Draw,\ +if=3Dnone,id=3Ddrive-scsi0-0-0-0,boot=3Don \ +-device scsi-block,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +drive=3Ddrive-scsi0-0-0-0,id=3Dscsi0-0-0-0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index be32d891e..153098e8c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2959,6 +2959,14 @@ mymain(void) QEMU_CAPS_HDA_DUPLEX); DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI= ); =20 + DO_TEST("disk-virtio-scsi-reservations", + QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_PR_MANAGER_HELPER); + + DO_TEST("disk-virtio-scsi-reservations-not-managed", + QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_PR_MANAGER_HELPER); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291554421423.0246837146551; Thu, 18 Jan 2018 08:05:54 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13D7B8B113; Thu, 18 Jan 2018 16:05:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7FFD60F84; Thu, 18 Jan 2018 16:05:52 +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 9C96618033E6; Thu, 18 Jan 2018 16:05:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG5WfS023775 for ; Thu, 18 Jan 2018 11:05:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id EA45751893; Thu, 18 Jan 2018 16:05:32 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D39517195; Thu, 18 Jan 2018 16:05:32 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:40 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 08/14] qemu: Introduce pr_helper to qemu.conf 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 18 Jan 2018 16:05:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Just like we allow users overriding path to bridge-helper detected at compile time we can allow them to override path to qemu-pr-helper. Signed-off-by: Michal Privoznik --- m4/virt-driver-qemu.m4 | 5 +++++ src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 4 ++++ src/qemu/qemu_conf.c | 7 ++++++- src/qemu/qemu_conf.h | 1 + src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/m4/virt-driver-qemu.m4 b/m4/virt-driver-qemu.m4 index b9bafdab9..0e0f261d6 100644 --- a/m4/virt-driver-qemu.m4 +++ b/m4/virt-driver-qemu.m4 @@ -57,6 +57,11 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [ [/usr/libexec:/usr/lib/qemu:/usr/lib]) AC_DEFINE_UNQUOTED([QEMU_BRIDGE_HELPER], ["$QEMU_BRIDGE_HELPER"], [QEMU bridge helper]) + AC_PATH_PROG([QEMU_PR_HELPER], [qemu-pr-helper], + [/usr/libexec/qemu-pr-helper], + [/usr/libexec:/usr/lib/qemu:/usr/lib]) + AC_DEFINE_UNQUOTED([QEMU_PR_HELPER], ["$QEMU_PR_HELPER"], + [QEMU PR helper]) ]) =20 AC_DEFUN([LIBVIRT_DRIVER_RESULT_QEMU], [ diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index c19bf3a43..2dc16e91f 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -86,6 +86,7 @@ module Libvirtd_qemu =3D let process_entry =3D str_entry "hugetlbfs_mount" | bool_entry "clear_emulator_capabilities" | str_entry "bridge_helper" + | str_entry "pr_helper" | bool_entry "set_process_name" | int_entry "max_processes" | int_entry "max_files" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 43dd561cc..4bc668406 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -775,3 +775,7 @@ # This directory is used for memoryBacking source if configured as file. # NOTE: big files will be stored here #memory_backing_dir =3D "/var/lib/libvirt/qemu/ram" + +# Path to the SCSI persistent reservations helper. This helper is +# used whenever are enabled for SCSI disks. +#pr_helper =3D "/usr/libexec/qemu-pr-helper" diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index af503d31c..b842fb4ab 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -307,7 +307,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) goto error; } =20 - if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0) + if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0 || + VIR_STRDUP(cfg->prHelperName, QEMU_PR_HELPER) < 0) goto error; =20 cfg->clearEmulatorCapabilities =3D true; @@ -392,6 +393,7 @@ static void virQEMUDriverConfigDispose(void *obj) } VIR_FREE(cfg->hugetlbfs); VIR_FREE(cfg->bridgeHelperName); + VIR_FREE(cfg->prHelperName); =20 VIR_FREE(cfg->saveImageFormat); VIR_FREE(cfg->dumpImageFormat); @@ -759,6 +761,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, if (virConfGetValueString(conf, "bridge_helper", &cfg->bridgeHelperNam= e) < 0) goto cleanup; =20 + if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0) + goto cleanup; + if (virConfGetValueBool(conf, "mac_filter", &cfg->macFilter) < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a553e30e2..11d986a53 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -153,6 +153,7 @@ struct _virQEMUDriverConfig { size_t nhugetlbfs; =20 char *bridgeHelperName; + char *prHelperName; =20 bool macFilter; =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 688e5b9fd..c0efae47b 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -100,3 +100,4 @@ module Test_libvirtd_qemu =3D { "1" =3D "mount" } } { "memory_backing_dir" =3D "/var/lib/libvirt/qemu/ram" } +{ "pr_helper" =3D "/usr/libexec/qemu-pr-helper" } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291558121176.24380006793137; Thu, 18 Jan 2018 08:05:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A232E7486D; Thu, 18 Jan 2018 16:05:56 +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 742B85C6CE; Thu, 18 Jan 2018 16:05:56 +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 41E675FBDF; Thu, 18 Jan 2018 16:05:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG5XGe023783 for ; Thu, 18 Jan 2018 11:05:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id DEB8C51895; Thu, 18 Jan 2018 16:05:33 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FF1A4A2; Thu, 18 Jan 2018 16:05:33 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:41 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 09/14] qemu: Start PR daemons on domain startup 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 18 Jan 2018 16:05:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Before we exec() qemu we have to spawn pr-helper processes for all managed reservations (well, technically there can only one). The only caveat there is that we should place the process into the same namespace and cgroup as qemu (so that it shares the same view of the system). But we can do that only after we've forked. That means calling the setup function between fork() and exec(). Signed-off-by: Michal Privoznik --- src/qemu/qemu_process.c | 151 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 151 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 25ec464d3..02608c1f3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2507,6 +2507,151 @@ qemuProcessSetupEmulator(virDomainObjPtr vm) } =20 =20 +static int +qemuProcessSetupOnePRDaemonHook(void *opaque) +{ + virDomainObjPtr vm =3D opaque; + size_t i, nfds =3D 0; + int *fds =3D NULL; + int ret =3D -1; + + if (virProcessGetNamespaces(vm->pid, &nfds, &fds) < 0) + return ret; + + if (virProcessSetNamespaces(nfds, fds) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + for (i =3D 0; i < nfds; i++) + VIR_FORCE_CLOSE(fds[i]); + VIR_FREE(fds); + return ret; +} + + +static int +qemuProcessSetupOnePRDaemon(void *payload, + const void *name, + void *opaque) +{ + qemuDomainDiskPRObjectPtr prObj =3D payload; + virDomainObjPtr vm =3D opaque; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + char *pidfile =3D NULL; + pid_t cpid =3D -1; + virCommandPtr cmd =3D NULL; + virTimeBackOffVar timebackoff; + const unsigned long long timeout =3D 500000; /* ms */ + int ret =3D -1; + + if (!prObj->managed) + return 0; + + if (!virFileIsExecutable(cfg->prHelperName)) { + virReportSystemError(errno, _("'%s' is not a suitable pr helper"), + cfg->prHelperName); + goto cleanup; + } + + if (!(pidfile =3D virPidFileBuildPath(cfg->stateDir, name))) + goto cleanup; + + if (unlink(pidfile) < 0 && + errno !=3D ENOENT) { + virReportSystemError(errno, + _("Cannot remove stale PID file %s"), + pidfile); + goto cleanup; + } + + if (!(cmd =3D virCommandNewArgList(cfg->prHelperName, + "-k", prObj->path, + NULL))) + goto cleanup; + + virCommandDaemonize(cmd); + virCommandSetPidFile(cmd, pidfile); + virCommandSetPreExecHook(cmd, qemuProcessSetupOnePRDaemonHook, vm); + +#ifdef CAP_SYS_RAWIO + virCommandAllowCap(cmd, CAP_SYS_RAWIO); +#else + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Raw I/O is not supported on this platform")); + goto cleanup; +#endif + + if (virCommandRun(cmd, NULL) < 0) + goto cleanup; + + if (virPidFileReadPath(pidfile, &cpid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pr helper %s didn't show up"), (const char *) na= me); + goto cleanup; + } + + if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0) + goto cleanup; + while (virTimeBackOffWait(&timebackoff)) { + if (virFileExists(prObj->path)) + break; + + if (virProcessKill(cpid, 0) =3D=3D 0) + continue; + + virReportSystemError(errno, "%s", + _("pr helper died unexpectedly")); + goto cleanup; + } + + if (priv->cgroup && + virCgroupAddMachineTask(priv->cgroup, cpid) < 0) + goto cleanup; + + if (qemuSecurityDomainSetPathLabel(driver->securityManager, + vm->def, prObj->path, true) < 0) + goto cleanup; + + prObj->pid =3D cpid; + ret =3D 0; + cleanup: + if (ret < 0) { + virCommandAbort(cmd); + virProcessKillPainfully(cpid, true); + } + virCommandFree(cmd); + if (unlink(pidfile) < 0 && + errno !=3D ENOENT && + !virGetLastError()) + virReportSystemError(errno, + _("Cannot remove stale PID file %s"), + pidfile); + VIR_FREE(pidfile); + virObjectUnref(cfg); + return ret; +} + + +static int +qemuProcessSetupPRDaemons(virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int ret =3D -1; + + if (priv->prHelpers && + virHashForEach(priv->prHelpers, + qemuProcessSetupOnePRDaemon, vm) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + return ret; +} + + static int qemuProcessInitPasswords(virConnectPtr conn, virQEMUDriverPtr driver, @@ -5896,6 +6041,10 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessSetupEmulator(vm) < 0) goto cleanup; =20 + VIR_DEBUG("Setting up PR daemons"); + if (qemuProcessSetupPRDaemons(vm) < 0) + goto cleanup; + VIR_DEBUG("Setting domain security labels"); if (qemuSecuritySetAllLabel(driver, vm, @@ -6475,6 +6624,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, VIR_FREE(vm->def->seclabels[i]->imagelabel); } =20 + qemuDomainDiskPRObjectKillAll(priv); + qemuHostdevReAttachDomainDevices(driver, vm->def); =20 def =3D vm->def; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291606662107.85820194787948; Thu, 18 Jan 2018 08:06:46 -0800 (PST) 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 64E9ED7815; Thu, 18 Jan 2018 16:06:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FC094A2; Thu, 18 Jan 2018 16:06:45 +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 5FA1C18033E6; Thu, 18 Jan 2018 16:06:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG6U19024037 for ; Thu, 18 Jan 2018 11:06:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A9804A2; Thu, 18 Jan 2018 16:06:30 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E0F67FD52; Thu, 18 Jan 2018 16:05:34 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:42 +0100 Message-Id: <3591fb9cd0cb24dd6b937421dc5f7da9680f2c75.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 10/14] qemu: Track PR daemons PIDs in status XML 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.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.38]); Thu, 18 Jan 2018 16:06:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to keep track of spawned processes so that we can kill them when qemu process dies. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 130 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 130 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 97996b053..4079165f9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -131,6 +131,10 @@ static virClassPtr qemuDomainSaveCookieClass; static void qemuDomainLogContextDispose(void *obj); static void qemuDomainSaveCookieDispose(void *obj); =20 +static void +qemuDomainDiskPRObjectHashFree(void *payload, + const void *name); + static int qemuDomainOnceInit(void) { @@ -1954,6 +1958,46 @@ qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPt= r buf, } =20 =20 +static int +qemuDomainObjPrivateXMLFormatOnePR(void *payload, + const void *name, + void *data) +{ + qemuDomainDiskPRObjectPtr prObj =3D payload; + virBufferPtr buf =3D data; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%s\n", (const char *) name); + virBufferAsprintf(buf, "%s\n", + virTristateBoolTypeToString(virTristateBoolFromBool(= prObj->managed))); + virBufferEscapeString(buf, "%s\n", prObj->path); + virBufferAsprintf(buf, "%lld\n", (long long) prObj->pid); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + return 0; +} + + +static void +qemuDomainObjPrivateXMLFormatPRs(virBufferPtr buf, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (!priv->prHelpers) + return; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virHashForEach(priv->prHelpers, + qemuDomainObjPrivateXMLFormatOnePR, buf); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); +} + + static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virDomainObjPtr vm) @@ -2081,6 +2125,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (qemuDomainObjPrivateXMLFormatBlockjobs(buf, vm) < 0) return -1; =20 + qemuDomainObjPrivateXMLFormatPRs(buf, vm); + return 0; } =20 @@ -2213,6 +2259,87 @@ qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathCont= extPtr ctxt, } =20 =20 +static qemuDomainDiskPRObjectPtr +qemuDomainObjPrivateXMLParseOnePR(xmlXPathContextPtr ctxt, + char **alias) +{ + qemuDomainDiskPRObjectPtr ret; + char *managedStr =3D NULL; + int managed; + char *path =3D NULL; + long long cpid; + + if (VIR_ALLOC(ret) < 0) + return NULL; + + if (!(managedStr =3D virXPathString("string(./managed)", ctxt)) || + !(*alias =3D virXPathString("string(./alias)", ctxt)) || + !(path =3D virXPathString("string(./path)", ctxt)) || + virXPathLongLong("string(./pid)", ctxt, &cpid) < 0 || + (managed =3D virTristateBoolTypeFromString(managedStr)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed status XML in ")); + goto error; + } + + VIR_FREE(managedStr); + ret->managed =3D managed =3D=3D VIR_TRISTATE_BOOL_YES; + ret->path =3D path; + ret->pid =3D cpid; + path =3D NULL; + + return ret; + + error: + VIR_FREE(managedStr); + VIR_FREE(*alias); + VIR_FREE(path); + VIR_FREE(ret); + return NULL; +} + + +static int +qemuDomainObjPrivateXMLParsePRs(qemuDomainObjPrivatePtr priv, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr saveNode =3D ctxt->node; + xmlNodePtr *nodeset =3D NULL; + virHashTablePtr prHelpers =3D NULL; + size_t i, n; + int ret =3D -1; + + if ((n =3D virXPathNodeSet("./prManagers/manager", ctxt, &nodeset)) > = 0) { + if (!(prHelpers =3D virHashCreate(10, qemuDomainDiskPRObjectHashFr= ee))) + goto cleanup; + + for (i =3D 0; i < n; i++) { + qemuDomainDiskPRObjectPtr tmp; + char *alias =3D NULL; + + ctxt->node =3D nodeset[i]; + if (!(tmp =3D qemuDomainObjPrivateXMLParseOnePR(ctxt, &alias))) + goto cleanup; + + if (virHashAddEntry(prHelpers, alias, tmp) < 0) { + qemuDomainDiskPRObjectHashFree(tmp, alias); + VIR_FREE(alias); + goto cleanup; + } + } + } + + priv->prHelpers =3D prHelpers; + prHelpers =3D NULL; + ret =3D 0; + cleanup: + virHashFree(prHelpers); + VIR_FREE(nodeset); + ctxt->node =3D saveNode; + return ret; +} + + static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, virDomainObjPtr vm, @@ -2433,6 +2560,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if (qemuDomainObjPrivateXMLParseBlockjobs(priv, ctxt) < 0) goto error; =20 + if (qemuDomainObjPrivateXMLParsePRs(priv, ctxt) < 0) + goto error; + return 0; =20 error: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291618323776.444978968207; Thu, 18 Jan 2018 08:06:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BCA92F9451; Thu, 18 Jan 2018 16:06:55 +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 1B0C618140; Thu, 18 Jan 2018 16:06:54 +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 B1B735FBDD; Thu, 18 Jan 2018 16:06:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG6qNr024444 for ; Thu, 18 Jan 2018 11:06:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 861F9177E3; Thu, 18 Jan 2018 16:06:52 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF5B04C5; Thu, 18 Jan 2018 16:06:30 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:43 +0100 Message-Id: <04df5053f4e7501e07bd22be502d34fad57c0883.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 11/14] qemu_domain: Introduce qemuDomainGetPRUsageCount 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Jan 2018 16:06:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For hotplug, we will need to know how many disks use given pr-manager so that we know if to plug it too (for the first usage) or unlpug it (for the last one). Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4079165f9..c327dfc86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11236,6 +11236,32 @@ qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivate= Ptr priv) priv->prHelpers =3D NULL; } =20 +size_t +qemuDomainGetPRUsageCount(const virDomainDef *def, + const char *prAlias) +{ + size_t used =3D 0; + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + const virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainStorageSourcePrivatePtr srcPriv; + + if (!disk->src || + !disk->src->pr) + continue; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + + if (STRNEQ(srcPriv->prAlias, prAlias)) + continue; + + used++; + } + + return used; +} + =20 static int qemuDomainPrepareDiskPR(qemuDomainObjPrivatePtr priv, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5fdb5b931..231583256 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1011,4 +1011,8 @@ qemuDomainDiskPRObjectRegister(qemuDomainObjPrivatePt= r priv, void qemuDomainDiskPRObjectKillAll(qemuDomainObjPrivatePtr priv); =20 +size_t +qemuDomainGetPRUsageCount(const virDomainDef *def, + const char *prAlias); + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291649077925.5122015417093; Thu, 18 Jan 2018 08:07:29 -0800 (PST) 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 B556DD7E9A; Thu, 18 Jan 2018 16:07:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B58080DA6; Thu, 18 Jan 2018 16:07:27 +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 44DCD18033F1; Thu, 18 Jan 2018 16:07:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG7PLT024537 for ; Thu, 18 Jan 2018 11:07:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7FECD80D90; Thu, 18 Jan 2018 16:07:25 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DE3A80D97; Thu, 18 Jan 2018 16:06:52 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:44 +0100 Message-Id: <1ff891976b962d96544ef99a6621bebccd7d6f02.1516290874.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 12/14] qemu_process.c: Introduce qemuProcessSetupPRDaemon 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.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.38]); Thu, 18 Jan 2018 16:07:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Again, for hotplug we need to be able to spawn just one process. Not all of them. Expose the static function we already have for that. Signed-off-by: Michal Privoznik --- src/qemu/qemu_process.c | 9 +++++++++ src/qemu/qemu_process.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 02608c1f3..b4c4c64fa 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2635,6 +2635,15 @@ qemuProcessSetupOnePRDaemon(void *payload, } =20 =20 +int +qemuProcessSetupPRDaemon(virDomainObjPtr vm, + qemuDomainDiskPRObjectPtr prObj, + const char *prAlias) +{ + return qemuProcessSetupOnePRDaemon(prObj, prAlias, vm); +} + + static int qemuProcessSetupPRDaemons(virDomainObjPtr vm) { diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index cd9a72031..50946e16d 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -199,4 +199,8 @@ int qemuProcessRefreshDisks(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob); =20 +int qemuProcessSetupPRDaemon(virDomainObjPtr vm, + qemuDomainDiskPRObjectPtr prObj, + const char *prAlias); + #endif /* __QEMU_PROCESS_H__ */ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291673238181.39870249301498; Thu, 18 Jan 2018 08:07:53 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1075D9623; Thu, 18 Jan 2018 16:07:51 +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 B103D18A2C; Thu, 18 Jan 2018 16:07:51 +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 6EB525FBDC; Thu, 18 Jan 2018 16:07:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG7nPx024645 for ; Thu, 18 Jan 2018 11:07:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id DC9AC7E24B; Thu, 18 Jan 2018 16:07:49 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DC4680DAE; Thu, 18 Jan 2018 16:07:25 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:45 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 13/14] qemu_hotplug: Hotplug of reservations 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 18 Jan 2018 16:07:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Surprisingly, nothing special is happening here. If we are the first to use the managed helper then spawn it. If not, we're almost done. Signed-off-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 97 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 97 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6b245bd6a..ded666633 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -350,6 +350,84 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, } =20 =20 +static int +qemuBuildPRDefInfoProps(virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virJSONValuePtr *prmgrProps, + const char **prAlias) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainStorageSourcePrivatePtr srcPriv; + qemuDomainDiskPRObjectPtr tmp; + virJSONValuePtr props =3D NULL; + int ret =3D -1; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + + *prmgrProps =3D NULL; + + if (!priv->prHelpers || + !srcPriv->prAlias || + !(tmp =3D virHashLookup(priv->prHelpers, srcPriv->prAlias))) + return 0; + + if (qemuDomainGetPRUsageCount(vm->def, srcPriv->prAlias) !=3D 0) { + /* We're not the first ones to use pr-manager with that + * alias. Return early and leave @prmgrProps NULL so + * that caller knows this. */ + return 0; + } + + if (virJSONValueObjectCreate(&props, + "s:path", tmp->path, + NULL) < 0) + goto cleanup; + + if (qemuProcessSetupPRDaemon(vm, tmp, srcPriv->prAlias) < 0) + goto cleanup; + + *prAlias =3D srcPriv->prAlias; + *prmgrProps =3D props; + props =3D NULL; + ret =3D 0; + cleanup: + virJSONValueFree(props); + return ret; +} + + +static void +qemuDestroyPRDefObject(virDomainObjPtr vm, + virDomainDiskDefPtr disk) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainStorageSourcePrivatePtr srcPriv; + qemuDomainDiskPRObjectPtr tmp; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + + if (!priv->prHelpers || + !srcPriv->prAlias || + !(tmp =3D virHashLookup(priv->prHelpers, srcPriv->prAlias))) + return; + + if (qemuDomainGetPRUsageCount(vm->def, srcPriv->prAlias) > 1) { + /* The function might return one or even zero if the + * pr-manager is unused depending whether the disk was + * added to domain def already or not. Anyway, if the + * return value is greater than one we are certain that + * there's another disk using it so return early. */ + return; + } + + /* This also kills the pr-manager daemon. See + * qemuDomainDiskPRObjectHashFree. */ + virHashRemoveEntry(priv->prHelpers, srcPriv->prAlias); + + VIR_FREE(srcPriv->prAlias); +} + + /** * qemuDomainAttachDiskGeneric: * @@ -368,12 +446,15 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, char *devstr =3D NULL; char *drivestr =3D NULL; char *drivealias =3D NULL; + const char *prAlias =3D NULL; bool driveAdded =3D false; bool secobjAdded =3D false; bool encobjAdded =3D false; + bool prmgrAdded =3D false; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virJSONValuePtr secobjProps =3D NULL; virJSONValuePtr encobjProps =3D NULL; + virJSONValuePtr prmgrProps =3D NULL; qemuDomainStorageSourcePrivatePtr srcPriv; qemuDomainSecretInfoPtr secinfo =3D NULL; qemuDomainSecretInfoPtr encinfo =3D NULL; @@ -406,6 +487,9 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, disk->info.alias) < 0) goto error; =20 + if (qemuBuildPRDefInfoProps(vm, disk, &prmgrProps, &prAlias) < 0) + goto error; + if (!(drivestr =3D qemuBuildDriveStr(disk, false, priv->qemuCaps))) goto error; =20 @@ -438,6 +522,15 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, encobjAdded =3D true; } =20 + if (prmgrProps) { + rv =3D qemuMonitorAddObject(priv->mon, "pr-manager-helper", prAlia= s, + prmgrProps); + prmgrProps =3D NULL; /* qemuMonitorAddObject consumes */ + if (rv < 0) + goto exit_monitor; + prmgrAdded =3D true; + } + if (qemuMonitorAddDrive(priv->mon, drivestr) < 0) goto exit_monitor; driveAdded =3D true; @@ -458,6 +551,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, cleanup: virJSONValueFree(secobjProps); virJSONValueFree(encobjProps); + virJSONValueFree(prmgrProps); qemuDomainSecretDiskDestroy(disk); VIR_FREE(devstr); VIR_FREE(drivestr); @@ -475,6 +569,8 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, ignore_value(qemuMonitorDelObject(priv->mon, secinfo->s.aes.alias)= ); if (encobjAdded) ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias)= ); + if (prmgrAdded) + ignore_value(qemuMonitorDelObject(priv->mon, prAlias)); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -2; virErrorRestore(&orig_err); @@ -484,6 +580,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, error: qemuDomainDelDiskSrcTLSObject(driver, vm, disk->src); ignore_value(qemuHotplugPrepareDiskAccess(driver, vm, disk, NULL, true= )); + qemuDestroyPRDefObject(vm, disk); goto cleanup; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 01:08:34 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516291695692870.572303299464; Thu, 18 Jan 2018 08:08:15 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3B432F86FC; Thu, 18 Jan 2018 16:08:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A3AA17C4F; Thu, 18 Jan 2018 16:08:13 +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 5993518033F3; Thu, 18 Jan 2018 16:08:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0IG8CRI024712 for ; Thu, 18 Jan 2018 11:08:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D9BA17195; Thu, 18 Jan 2018 16:08:12 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id A429E4C5; Thu, 18 Jan 2018 16:07:50 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Jan 2018 17:04:46 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: pbonzini@redhat.com Subject: [libvirt] [PATCH 14/14] qemu_hotplug: Hotunplug of reservations 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Jan 2018 16:08:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Just line in previous commit, if we are the last ones that are using the pr-manager delete it and also kill the pr-helper process. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 18 ++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_hotplug.c | 13 +++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c327dfc86..d15c29f4a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11263,6 +11263,24 @@ qemuDomainGetPRUsageCount(const virDomainDef *def, } =20 =20 +bool +qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, + virDomainDiskDefPtr disk) +{ + qemuDomainStorageSourcePrivatePtr srcPriv; + + if (!disk->src) + return false; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + if (!srcPriv || + !srcPriv->prAlias) + return false; + + return qemuDomainGetPRUsageCount(vm->def, srcPriv->prAlias) =3D=3D 1; +} + + static int qemuDomainPrepareDiskPR(qemuDomainObjPrivatePtr priv, virDomainDiskDefPtr disk) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 231583256..6f33d3f36 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1015,4 +1015,8 @@ size_t qemuDomainGetPRUsageCount(const virDomainDef *def, const char *prAlias); =20 +bool +qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, + virDomainDiskDefPtr disk); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ded666633..e2064648b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3825,6 +3825,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, char *drivestr; char *objAlias =3D NULL; char *encAlias =3D NULL; + const char *prAlias =3D NULL; =20 VIR_DEBUG("Removing disk %s from domain %p %s", disk->info.alias, vm, vm->def->name); @@ -3862,6 +3863,13 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } =20 + if (qemuDomainDiskNeedRemovePR(vm, disk)) { + qemuDomainStorageSourcePrivatePtr srcPriv; + + srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + prAlias =3D srcPriv->prAlias; + } + qemuDomainObjEnterMonitor(driver, vm); =20 qemuMonitorDriveDel(priv->mon, drivestr); @@ -3877,6 +3885,9 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, ignore_value(qemuMonitorDelObject(priv->mon, encAlias)); VIR_FREE(encAlias); =20 + if (prAlias) + ignore_value(qemuMonitorDelObject(priv->mon, prAlias)); + if (disk->src->haveTLS) ignore_value(qemuMonitorDelObject(priv->mon, disk->src->tlsAlias)); =20 @@ -3895,6 +3906,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } =20 + qemuDestroyPRDefObject(vm, disk); + qemuDomainReleaseDeviceAddress(vm, &disk->info, src); =20 if (qemuSecurityRestoreDiskLabel(driver, vm, disk) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list