From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294541847699.1709088132955; Mon, 14 May 2018 03:42:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16D49A8D13; Mon, 14 May 2018 10:42:19 +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 CCED62010CDC; Mon, 14 May 2018 10:42:18 +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 57166180B536; Mon, 14 May 2018 10:42:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgGgw003608 for ; Mon, 14 May 2018 06:42:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62BC22026DEF; Mon, 14 May 2018 10:42:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEF612026E0E; Mon, 14 May 2018 10:42:15 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:52 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/13] qemu: hotplug: Fix spacing around addition operator X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 14 May 2018 10:42:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f3ff945787..1d748ccffb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -484,7 +484,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (!(devstr =3D qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps= ))) goto error; - if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) + if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1) < 0) goto error; qemuDomainObjEnterMonitor(driver, vm); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294548527458.2994625760017; Mon, 14 May 2018 03:42:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0542314DCE2; Mon, 14 May 2018 10:42:25 +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 B95C330012B0; Mon, 14 May 2018 10:42:25 +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 0B2474CAA7; Mon, 14 May 2018 10:42:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgHRW003613 for ; Mon, 14 May 2018 06:42:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 221872026DEF; Mon, 14 May 2018 10:42:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DFAF2026E0E; Mon, 14 May 2018 10:42:16 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:53 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/13] qemu: alias: Allow passing alias of parent when generating PR manager alias X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 14 May 2018 10:42:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For use with blockdev the PR manager will be bound to a virStorageSource rather than a virDomainDiskDef, so we will need to use the correct alias. Allow passing a string rather than the whole disk. Signed-off-by: Peter Krempa --- src/qemu/qemu_alias.c | 4 ++-- src/qemu/qemu_alias.h | 2 +- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_hotplug.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index bd714f7aee..578a33b284 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -783,11 +783,11 @@ qemuDomainGetManagedPRAlias(void) char * -qemuDomainGetUnmanagedPRAlias(const virDomainDiskDef *disk) +qemuDomainGetUnmanagedPRAlias(const char *parentalias) { char *ret; - ignore_value(virAsprintf(&ret, "pr-helper-%s", disk->info.alias)); + ignore_value(virAsprintf(&ret, "pr-helper-%s", parentalias)); return ret; } diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index 76678658c0..51f64624d7 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -94,6 +94,6 @@ char *qemuAliasChardevFromDevAlias(const char *devAlias) const char *qemuDomainGetManagedPRAlias(void); -char *qemuDomainGetUnmanagedPRAlias(const virDomainDiskDef *disk); +char *qemuDomainGetUnmanagedPRAlias(const char *parentalias); #endif /* __QEMU_ALIAS_H__*/ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 11ad77f145..24b482efd8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1482,7 +1482,7 @@ qemuBuildDriveSourcePR(virBufferPtr buf, if (virStoragePRDefIsManaged(disk->src->pr)) defaultAlias =3D qemuDomainGetManagedPRAlias(); - else if (!(alias =3D qemuDomainGetUnmanagedPRAlias(disk))) + else if (!(alias =3D qemuDomainGetUnmanagedPRAlias(disk->info.alias))) return -1; @@ -9705,7 +9705,7 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, if (VIR_STRDUP(alias, qemuDomainGetManagedPRAlias()) < 0) goto cleanup; } else { - if (!(alias =3D qemuDomainGetUnmanagedPRAlias(disk))) + if (!(alias =3D qemuDomainGetUnmanagedPRAlias(disk->info.alias))) goto cleanup; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1d748ccffb..52e1abdcd3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3842,7 +3842,7 @@ qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, return 0; if (!virStoragePRDefIsManaged(disk->src->pr)) { - *aliasret =3D qemuDomainGetUnmanagedPRAlias(disk); + *aliasret =3D qemuDomainGetUnmanagedPRAlias(disk->info.alias); return *aliasret ? 0 : -1; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294543629601.8355349513013; Mon, 14 May 2018 03:42:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B19AC30D7816; Mon, 14 May 2018 10:42:21 +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 803493001661; Mon, 14 May 2018 10:42:21 +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 313574BB79; Mon, 14 May 2018 10:42:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgH4n003621 for ; Mon, 14 May 2018 06:42:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id D52212026DEF; Mon, 14 May 2018 10:42:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D5EC2026E0E; Mon, 14 May 2018 10:42:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/13] qemu: command: Fix comment for qemuBuildPRManagerInfoProps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 14 May 2018 10:42:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The comment did not accurately describe the arguments. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 24b482efd8..d84cf6dffc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9667,8 +9667,10 @@ qemuBuildPanicCommandLine(virCommandPtr cmd, /** * qemuBuildPRManagerInfoProps: - * @prd: disk PR runtime info - * @propsret: JSON properties to return + * @vm: domain object + * @disk: disk definition + * @propsret: Returns JSON object containing properties of the pr-manager-= helper object + * @aliasret: alias of the pr-manager-helper object * * Build the JSON properties for the pr-manager object. * --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294549205523.5724547085905; Mon, 14 May 2018 03:42:29 -0700 (PDT) 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 A55E6C4657; Mon, 14 May 2018 10:42:27 +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 34D0618171; Mon, 14 May 2018 10:42: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 DAEAE4BB78; Mon, 14 May 2018 10:42:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgIQ3003631 for ; Mon, 14 May 2018 06:42:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 953722026DFD; Mon, 14 May 2018 10:42:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C50A2026E0E; Mon, 14 May 2018 10:42:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:55 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/13] qemu: Move validation of PR manager support 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.25]); Mon, 14 May 2018 10:42:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Disk source definition should be validated in qemuDomainValidateStorageSource rather than in individual generators of command line arguments. Change to the XML2XML test is required since now the definition is actually validated at define time. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 7 ------- src/qemu/qemu_domain.c | 7 +++++++ tests/qemuxml2xmltest.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d84cf6dffc..29ca2005a0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9683,7 +9683,6 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, virJSONValuePtr *propsret, char **aliasret) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; char *socketPath =3D NULL; char *alias =3D NULL; int ret =3D -1; @@ -9694,12 +9693,6 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, if (!virStoragePRDefIsEnabled(disk->src->pr)) return 0; - if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("reservations not supported with this QEMU binary= ")); - return ret; - } - if (!(socketPath =3D qemuDomainGetPRSocketPath(vm, disk->src->pr))) return ret; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 233327b906..611a96d6be 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4204,6 +4204,13 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src, } } + if (virStoragePRDefIsEnabled(src->pr) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("reservations not supported with this QEMU binary= ")); + return -1; + } + return 0; } diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 762e0e2d25..44cba97d4a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -388,7 +388,7 @@ mymain(void) DO_TEST("disk-virtio-scsi-num_queues", QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-virtio-scsi-reservations", - QEMU_CAPS_VIRTIO_SCSI); + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_PR_MANAGER_HELPER); DO_TEST("disk-virtio-scsi-cmd_per_lun", QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-virtio-scsi-max_sectors", --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294553552917.3818122589398; Mon, 14 May 2018 03:42:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5980630D7A3A; Mon, 14 May 2018 10:42:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11BB3300165E; Mon, 14 May 2018 10:42:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 956763FCF9; Mon, 14 May 2018 10:42:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgJsW003639 for ; Mon, 14 May 2018 06:42:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 541202026DFD; Mon, 14 May 2018 10:42:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFEE52026E0E; Mon, 14 May 2018 10:42:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:56 +0200 Message-Id: <28711b0f32c873a870eae3fcbfd953c04b7dbc85.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/13] util: storage: Drop pointless 'enabled' form PR definition X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 14 May 2018 10:42:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Everything can be disabled by not using the parent element. There's no need to store this explicitly. Additionally it does not add any value since any configuration is dropped if enabled=3D'no' is configured. Drop the attribute and adjust the code accordingly.t Signed-off-by: Peter Krempa --- docs/formatdomain.html.in | 21 ++-- docs/schemas/storagecommon.rng | 3 - src/util/virstoragefile.c | 117 +++++++++--------= ---- src/util/virstoragefile.h | 1 - .../disk-virtio-scsi-reservations.xml | 4 +- 5 files changed, 59 insertions(+), 87 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 80172c18d0..d69a669259 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2583,7 +2583,7 @@ <disk type=3D'block' device=3D'lun'> <driver name=3D'qemu' type=3D'raw'/> <source dev=3D'/dev/sda'> - <reservations enabled=3D'yes' managed=3D'no'> + <reservations managed=3D'no'> <source type=3D'unix' path=3D'/path/to/qemu-pr-helper' mode=3D'= client'/> </reservations> <target dev=3D'sda' bus=3D'scsi'/> @@ -2952,17 +2952,16 @@
Since libvirt 4.4.0, the reservations can be a sub-element of the source element for storage sources (QEMU driver o= nly). - If present (and enabled) it enables persistent reservations fo= r SCSI + If present it enables persistent reservations for SCSI based disks. The element has one mandatory attribute - enabled with accepted values yes and - no. If the feature is enabled, then there's anoth= er - mandatory attribute managed (accepted values are = the - same as for enabled) that enables or disables lib= virt - spawning a helper process. When the PR is unmanaged, then hype= rvisor - acts as a client and path to server socket must be provided in= child - element source, which currently accepts only the - following attributes: type with one value - unix, path with path the socket, and + managed with accepted values yes and + no. If managed is enabled libvirt pr= epares + and manages any resources needed for the feature. When the PR = is + unmanaged, then hypervisor acts as a client and path to server + socket must be provided in child element source, + which currently accepts only the following attributes: + type with one value unix, + path with path the socket, and finally mode which accepts one value client and specifies the role of hypervisor. It's recommended to allow libvirt manage the persistent diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index eed0b33347..cb4f14f52f 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -75,9 +75,6 @@ - - - diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 87c3499561..d6907e47bb 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1906,8 +1906,8 @@ virStoragePRDefFree(virStoragePRDefPtr prd) virStoragePRDefPtr virStoragePRDefParseXML(xmlXPathContextPtr ctxt) { - virStoragePRDefPtr prd, ret =3D NULL; - char *enabled =3D NULL; + virStoragePRDefPtr prd; + virStoragePRDefPtr ret =3D NULL; char *managed =3D NULL; char *type =3D NULL; char *path =3D NULL; @@ -1916,81 +1916,65 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) if (VIR_ALLOC(prd) < 0) return NULL; - if (!(enabled =3D virXPathString("string(./@enabled)", ctxt))) { + if (!(managed =3D virXPathString("string(./@managed)", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing @enabled attribute for ")= ); + _("missing @managed attribute for ")= ); goto cleanup; } - if ((prd->enabled =3D virTristateBoolTypeFromString(enabled)) <=3D 0) { + if ((prd->managed =3D virTristateBoolTypeFromString(managed)) <=3D 0) { virReportError(VIR_ERR_XML_ERROR, - _("invalid value for 'enabled': %s"), enabled); + _("invalid value for 'managed': %s"), managed); goto cleanup; } - if (prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - if (!(managed =3D virXPathString("string(./@managed)", ctxt))) { + if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { + type =3D virXPathString("string(./source[1]/@type)", ctxt); + path =3D virXPathString("string(./source[1]/@path)", ctxt); + mode =3D virXPathString("string(./source[1]/@mode)", ctxt); + + if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing @managed attribute for ")); + _("missing connection type for "= )); goto cleanup; } - if ((prd->managed =3D virTristateBoolTypeFromString(managed)) <=3D= 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid value for 'managed': %s"), managed); + if (!path) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing path for ")); goto cleanup; } - if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { - type =3D virXPathString("string(./source[1]/@type)", ctxt); - path =3D virXPathString("string(./source[1]/@path)", ctxt); - mode =3D virXPathString("string(./source[1]/@mode)", ctxt); - - if (!type) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing connection type for ")); - goto cleanup; - } - - if (!path) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing path for ")); - goto cleanup; - } - - if (!mode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing connection mode for ")); - goto cleanup; - } - - if (STRNEQ(type, "unix")) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported connection type for : %s"), - type); - goto cleanup; - } + if (!mode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing connection mode for "= )); + goto cleanup; + } - if (STRNEQ(mode, "client")) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported connection mode for : %s"), - mode); - goto cleanup; - } + if (STRNEQ(type, "unix")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported connection type for : %s"), + type); + goto cleanup; + } - VIR_STEAL_PTR(prd->path, path); + if (STRNEQ(mode, "client")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported connection mode for : %s"), + mode); + goto cleanup; } + + VIR_STEAL_PTR(prd->path, path); } - ret =3D prd; - prd =3D NULL; + VIR_STEAL_PTR(ret, prd); cleanup: VIR_FREE(mode); VIR_FREE(path); VIR_FREE(type); VIR_FREE(managed); - VIR_FREE(enabled); virStoragePRDefFree(prd); return ret; } @@ -2000,22 +1984,16 @@ void virStoragePRDefFormat(virBufferPtr buf, virStoragePRDefPtr prd) { - virBufferAsprintf(buf, "enabled)); - if (prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(prd->managed)); - if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAddLit(buf, "path); - virBufferAddLit(buf, " mode=3D'client'/>\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } + virBufferAsprintf(buf, "managed)); + if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAddLit(buf, "path); + virBufferAddLit(buf, " mode=3D'client'/>\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); } @@ -2032,8 +2010,7 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a, if (!a || !b) return false; - if (a->enabled !=3D b->enabled || - a->managed !=3D b->managed || + if (a->managed !=3D b->managed || STRNEQ_NULLABLE(a->path, b->path)) return false; @@ -2044,7 +2021,7 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a, bool virStoragePRDefIsEnabled(virStoragePRDefPtr prd) { - return prd && prd->enabled =3D=3D VIR_TRISTATE_BOOL_YES; + return !!prd; } diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 0bba016e4e..ec49152880 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -219,7 +219,6 @@ struct _virStorageAuthDef { typedef struct _virStoragePRDef virStoragePRDef; typedef virStoragePRDef *virStoragePRDefPtr; struct _virStoragePRDef { - int enabled; /* enum virTristateBool */ int managed; /* enum virTristateBool */ char *path; }; diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml b/tes= ts/qemuxml2argvdata/disk-virtio-scsi-reservations.xml index 036c6e3c25..acad600ef8 100644 --- a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml +++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml @@ -17,7 +17,7 @@ - +
@@ -25,7 +25,7 @@ - + --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294559538486.5931028655; Mon, 14 May 2018 03:42:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5373C30C79D6; Mon, 14 May 2018 10:42:37 +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 C26EB99349; Mon, 14 May 2018 10:42:36 +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 3B9781801249; Mon, 14 May 2018 10:42:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgKKF003647 for ; Mon, 14 May 2018 06:42:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1329C2026DFD; Mon, 14 May 2018 10:42:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F48E2026E0E; Mon, 14 May 2018 10:42:19 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:57 +0200 Message-Id: <166f0eab5d6f6e2431815fe3fc9b8aa4755830de.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/13] util: storage: Drop virStoragePRDefIsEnabled X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 14 May 2018 10:42:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function now does not do anything useful. Replace it by the pointer check. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_domain.c | 8 ++++---- src/qemu/qemu_hotplug.c | 2 +- src/util/virstoragefile.c | 7 ------- src/util/virstoragefile.h | 1 - 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d28a751ebd..dd10be9753 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2804,7 +2804,6 @@ virStorageNetHostTransportTypeToString; virStorageNetProtocolTypeToString; virStoragePRDefFormat; virStoragePRDefFree; -virStoragePRDefIsEnabled; virStoragePRDefIsEqual; virStoragePRDefIsManaged; virStoragePRDefParseXML; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 29ca2005a0..2bdba7734a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1477,7 +1477,7 @@ qemuBuildDriveSourcePR(virBufferPtr buf, char *alias =3D NULL; const char *defaultAlias =3D NULL; - if (!virStoragePRDefIsEnabled(disk->src->pr)) + if (!disk->src->pr) return 0; if (virStoragePRDefIsManaged(disk->src->pr)) @@ -9690,7 +9690,7 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, *propsret =3D NULL; *aliasret =3D NULL; - if (!virStoragePRDefIsEnabled(disk->src->pr)) + if (!disk->src->pr) return 0; if (!(socketPath =3D qemuDomainGetPRSocketPath(vm, disk->src->pr))) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 611a96d6be..c8d2daa26f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4204,7 +4204,7 @@ qemuDomainValidateStorageSource(virStorageSourcePtr s= rc, } } - if (virStoragePRDefIsEnabled(src->pr) && + if (src->pr && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("reservations not supported with this QEMU binary= ")); @@ -10240,7 +10240,7 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTR= IBUTE_UNUSED, } /* qemu-pr-helper might require access to /dev/mapper/control. */ - if (virStoragePRDefIsEnabled(disk->src->pr) && + if (disk->src->pr && qemuDomainCreateDevice(DEVICE_MAPPER_CONTROL_PATH, data, true) < 0) goto cleanup; @@ -11273,7 +11273,7 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, } /* qemu-pr-helper might require access to /dev/mapper/control. */ - if (virStoragePRDefIsEnabled(src->pr) && + if (src->pr && (VIR_STRDUP(dmPath, DEVICE_MAPPER_CONTROL_PATH) < 0 || VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0)) goto cleanup; @@ -12050,7 +12050,7 @@ qemuDomainGetPRSocketPath(virDomainObjPtr vm, const char *defaultAlias =3D NULL; char *ret =3D NULL; - if (!virStoragePRDefIsEnabled(pr)) + if (!pr) return NULL; if (virStoragePRDefIsManaged(pr)) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 52e1abdcd3..39c457e607 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3838,7 +3838,7 @@ qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, *aliasret =3D NULL; *stopDaemon =3D false; - if (!virStoragePRDefIsEnabled(disk->src->pr)) + if (!disk->src->pr) return 0; if (!virStoragePRDefIsManaged(disk->src->pr)) { diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index d6907e47bb..c89bdb9e49 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2018,13 +2018,6 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a, } -bool -virStoragePRDefIsEnabled(virStoragePRDefPtr prd) -{ - return !!prd; -} - - bool virStoragePRDefIsManaged(virStoragePRDefPtr prd) { diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index ec49152880..3a90c60fa5 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -396,7 +396,6 @@ void virStoragePRDefFormat(virBufferPtr buf, virStoragePRDefPtr prd); bool virStoragePRDefIsEqual(virStoragePRDefPtr a, virStoragePRDefPtr b); -bool virStoragePRDefIsEnabled(virStoragePRDefPtr prd); bool virStoragePRDefIsManaged(virStoragePRDefPtr prd); virSecurityDeviceLabelDefPtr --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294565181228.717962353477; Mon, 14 May 2018 03:42:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58FECECFBC; Mon, 14 May 2018 10:42:43 +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 E1E351001914; Mon, 14 May 2018 10:42:42 +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 72EA61808841; Mon, 14 May 2018 10:42:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgKj6003658 for ; Mon, 14 May 2018 06:42:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id C62C02026DEF; Mon, 14 May 2018 10:42:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E11A2026E0E; Mon, 14 May 2018 10:42:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:58 +0200 Message-Id: <9d42c701efd198d86b65b10c5370b036f85be551.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/13] util: storage: Allow passing also for managed PR case X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 14 May 2018 10:42:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To allow storing status information in the XML move the validation that the 'path' is not valid for managed PR daemon case into qemuDomainValidateStorageSource and allow parsing of the data even in case when managed=3D'yes'. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 18 +++++++++++++----- src/util/virstoragefile.c | 37 ++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c8d2daa26f..eaa796260c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4204,11 +4204,19 @@ qemuDomainValidateStorageSource(virStorageSourcePtr= src, } } - if (src->pr && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("reservations not supported with this QEMU binary= ")); - return -1; + if (src->pr) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("reservations not supported with this QEMU bi= nary")); + return -1; + } + + if (virStoragePRDefIsManaged(src->pr) && src->pr->path) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'path' attribute should not be provided for " + "managed reservations")); + return -1; + } } return 0; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c89bdb9e49..dbbe758f30 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1928,11 +1928,11 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) 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); + 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 (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO || type || path || mode) { if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing connection type for "= )); @@ -1950,24 +1950,23 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) _("missing connection mode for "= )); goto cleanup; } + } - if (STRNEQ(type, "unix")) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported connection type for : %s"), - type); - goto cleanup; - } - - if (STRNEQ(mode, "client")) { - virReportError(VIR_ERR_XML_ERROR, - _("unsupported connection mode for : %s"), - mode); - goto cleanup; - } + if (type && STRNEQ(type, "unix")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported connection type for := %s"), + type); + goto cleanup; + } - VIR_STEAL_PTR(prd->path, path); + if (mode && STRNEQ(mode, "client")) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported connection mode for := %s"), + mode); + goto cleanup; } + VIR_STEAL_PTR(prd->path, path); VIR_STEAL_PTR(ret, prd); cleanup: @@ -1986,7 +1985,7 @@ virStoragePRDefFormat(virBufferPtr buf, { virBufferAsprintf(buf, "managed)); - if (prd->managed =3D=3D VIR_TRISTATE_BOOL_NO) { + if (prd->path) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferAddLit(buf, " Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294549951603.789753132407; Mon, 14 May 2018 03:42:29 -0700 (PDT) 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 00B92AD8B2; Mon, 14 May 2018 10:42: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 B09705C88A; Mon, 14 May 2018 10:42:26 +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 5A3A4180474F; Mon, 14 May 2018 10:42:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAgLZR003669 for ; Mon, 14 May 2018 06:42:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84EEC2026DEF; Mon, 14 May 2018 10:42:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CF432026E0E; Mon, 14 May 2018 10:42:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:41:59 +0200 Message-Id: <1a8a4a131cb6ad818b7ba3051bc2a1439e483ab1.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/13] qemu: Assign managed PR path when preparing storage source 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.28]); Mon, 14 May 2018 10:42:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than always checking which path to use pre-assign it when preparing storage source. This reduces the need to pass 'vm' around too much. For later use the path can be retrieved from the status XML. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 18 +++++------------- src/qemu/qemu_command.h | 3 +-- src/qemu/qemu_domain.c | 35 ++++++++++++++++++++++------------- src/qemu/qemu_domain.h | 3 +-- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_process.c | 2 +- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2bdba7734a..7df9979cb2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9667,7 +9667,6 @@ qemuBuildPanicCommandLine(virCommandPtr cmd, /** * qemuBuildPRManagerInfoProps: - * @vm: domain object * @disk: disk definition * @propsret: Returns JSON object containing properties of the pr-manager-= helper object * @aliasret: alias of the pr-manager-helper object @@ -9678,12 +9677,10 @@ qemuBuildPanicCommandLine(virCommandPtr cmd, * -1 on failure (with error message set). */ int -qemuBuildPRManagerInfoProps(virDomainObjPtr vm, - const virDomainDiskDef *disk, +qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk, virJSONValuePtr *propsret, char **aliasret) { - char *socketPath =3D NULL; char *alias =3D NULL; int ret =3D -1; @@ -9693,9 +9690,6 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, if (!disk->src->pr) return 0; - if (!(socketPath =3D qemuDomainGetPRSocketPath(vm, disk->src->pr))) - return ret; - if (virStoragePRDefIsManaged(disk->src->pr)) { if (VIR_STRDUP(alias, qemuDomainGetManagedPRAlias()) < 0) goto cleanup; @@ -9705,7 +9699,7 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, } if (virJSONValueObjectCreate(propsret, - "s:path", socketPath, + "s:path", disk->src->pr->path, NULL) < 0) goto cleanup; @@ -9713,14 +9707,12 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm, ret =3D 0; cleanup: VIR_FREE(alias); - VIR_FREE(socketPath); return ret; } static int -qemuBuildMasterPRCommandLine(virDomainObjPtr vm, - virCommandPtr cmd, +qemuBuildMasterPRCommandLine(virCommandPtr cmd, const virDomainDef *def) { size_t i; @@ -9740,7 +9732,7 @@ qemuBuildMasterPRCommandLine(virDomainObjPtr vm, managedAdded =3D true; } - if (qemuBuildPRManagerInfoProps(vm, disk, &props, &alias) < 0) + if (qemuBuildPRManagerInfoProps(disk, &props, &alias) < 0) goto cleanup; if (!props) @@ -9934,7 +9926,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0) goto error; - if (qemuBuildMasterPRCommandLine(vm, cmd, def) < 0) + if (qemuBuildMasterPRCommandLine(cmd, def) < 0) goto error; if (enableFips) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index da1fe679fe..621592cd79 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -55,8 +55,7 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr drive= r, int **nicindexes); /* Generate the object properties for pr-manager */ -int qemuBuildPRManagerInfoProps(virDomainObjPtr vm, - const virDomainDiskDef *disk, +int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk, virJSONValuePtr *propsret, char **alias); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index eaa796260c..92217e66fe 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11930,6 +11930,22 @@ qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr= disk) } +static int +qemuDomainPrepareStorageSourcePR(virStorageSourcePtr src, + qemuDomainObjPrivatePtr priv) +{ + if (!src->pr) + return 0; + + if (virStoragePRDefIsManaged(src->pr)) { + if (!(src->pr->path =3D qemuDomainGetManagedPRSocketPath(priv))) + return -1; + } + + return 0; +} + + int qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, qemuDomainObjPrivatePtr priv, @@ -11946,6 +11962,9 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr dis= k, if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) = < 0) return -1; + if (qemuDomainPrepareStorageSourcePR(disk->src, priv) < 0) + return -1; + return 0; } @@ -12051,22 +12070,12 @@ qemuProcessEventFree(struct qemuProcessEvent *eve= nt) char * -qemuDomainGetPRSocketPath(virDomainObjPtr vm, - virStoragePRDefPtr pr) +qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; - const char *defaultAlias =3D NULL; char *ret =3D NULL; - if (!pr) - return NULL; - - if (virStoragePRDefIsManaged(pr)) { - defaultAlias =3D qemuDomainGetManagedPRAlias(); - ignore_value(virAsprintf(&ret, "%s/%s.sock", priv->libDir, default= Alias)); - } else { - ignore_value(VIR_STRDUP(ret, pr->path)); - } + ignore_value(virAsprintf(&ret, "%s/%s.sock", priv->libDir, + qemuDomainGetManagedPRAlias())); return ret; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 09969f606a..40d1d095a3 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1006,7 +1006,6 @@ qemuDomainDiskCachemodeFlags(int cachemode, bool *direct, bool *noflush); -char * qemuDomainGetPRSocketPath(virDomainObjPtr vm, - virStoragePRDefPtr pr); +char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv); #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 39c457e607..77d37e5ef6 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -401,7 +401,7 @@ qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm, return 0; } - return qemuBuildPRManagerInfoProps(vm, disk, propsret, aliasret); + return qemuBuildPRManagerInfoProps(disk, propsret, aliasret); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index a280784764..42b91b39ac 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2659,7 +2659,7 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, if ((pidfd =3D virPidFileAcquirePath(pidfile, false, -1)) < 0) goto cleanup; - if (!(socketPath =3D qemuDomainGetPRSocketPath(vm, disk->src->pr))) + if (!(socketPath =3D qemuDomainGetManagedPRSocketPath(priv))) goto cleanup; /* Remove stale socket */ --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294725297631.5460758262358; Mon, 14 May 2018 03:45:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA2DF30CBFE8; Mon, 14 May 2018 10:45:21 +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 BEE7926DD0; Mon, 14 May 2018 10:45:21 +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 73E1B180B536; Mon, 14 May 2018 10:45:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAjJ5g004100 for ; Mon, 14 May 2018 06:45:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AF8E2166BB1; Mon, 14 May 2018 10:45:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id A19C82166BAD for ; Mon, 14 May 2018 10:45:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:45:09 +0200 Message-Id: <97532250537bc18209411ef47d83a173712c60f1.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/13] qemu: process: Change semantics of functions starting PR daemon X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 14 May 2018 10:45:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Libvirt only manages one PR daemon. This means that we don't need to pass the 'disk' object and also rename the functions dealing with this so that it's obvious we only deal with the managed PR daemon. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 6 +++--- src/qemu/qemu_process.c | 37 ++++++++++++++++--------------------- src/qemu/qemu_process.h | 5 ++--- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 77d37e5ef6..3a26876c10 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -377,7 +377,7 @@ qemuDomainMaybeStartPRDaemon(virDomainObjPtr vm, /* @disk requires qemu-pr-helper but none is running. * Start it now. */ - if (qemuProcessStartPRDaemon(vm, disk) < 0) + if (qemuProcessStartManagedPRDaemon(vm) < 0) return -1; return 1; @@ -567,7 +567,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, qemuDomainDelDiskSrcTLSObject(driver, vm, disk->src); ignore_value(qemuHotplugPrepareDiskAccess(driver, vm, disk, NULL, true= )); if (prdStarted) - qemuProcessKillPRDaemon(vm); + qemuProcessKillManagedPRDaemon(vm); goto cleanup; } @@ -3963,7 +3963,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } if (stopPRDaemon) - qemuProcessKillPRDaemon(vm); + qemuProcessKillManagedPRDaemon(vm); qemuDomainReleaseDeviceAddress(vm, &disk->info, src); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 42b91b39ac..af29bcc59e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2566,7 +2566,7 @@ qemuProcessBuildPRHelperPidfilePath(virDomainObjPtr v= m) void -qemuProcessKillPRDaemon(virDomainObjPtr vm) +qemuProcessKillManagedPRDaemon(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; virErrorPtr orig_err; @@ -2624,8 +2624,7 @@ qemuProcessStartPRDaemonHook(void *opaque) int -qemuProcessStartPRDaemon(virDomainObjPtr vm, - const virDomainDiskDef *disk) +qemuProcessStartManagedPRDaemon(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverPtr driver =3D priv->driver; @@ -2640,10 +2639,6 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, const unsigned long long timeout =3D 500000; /* ms */ int ret =3D -1; - if (!virStoragePRDefIsManaged(disk->src->pr) || - priv->prDaemonRunning) - return 0; - cfg =3D virQEMUDriverGetConfig(driver); if (!virFileIsExecutable(cfg->prHelperName)) { @@ -2734,7 +2729,7 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, goto cleanup; priv->prDaemonRunning =3D true; - ret =3D 1; + ret =3D 0; cleanup: if (ret < 0) { virCommandAbort(cmd); @@ -2754,22 +2749,22 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, static int -qemuProcessMaybeStartPRDaemon(virDomainObjPtr vm) +qemuProcessMaybeStartManagedPRDaemon(virDomainObjPtr vm) { + bool hasManaged =3D false; size_t i; - int rv; for (i =3D 0; i < vm->def->ndisks; i++) { - const virDomainDiskDef *disk =3D vm->def->disks[i]; - - if ((rv =3D qemuProcessStartPRDaemon(vm, disk)) < 0) - return -1; - - if (rv > 0) - return 1; + if (virStoragePRDefIsManaged(vm->def->disks[i]->src->pr)) { + hasManaged =3D true; + break; + } } - return 0; + if (!hasManaged) + return 0; + + return qemuProcessStartManagedPRDaemon(vm); } @@ -6289,8 +6284,8 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessResctrlCreate(driver, vm) < 0) goto cleanup; - VIR_DEBUG("Setting up PR daemon"); - if (qemuProcessMaybeStartPRDaemon(vm) < 0) + VIR_DEBUG("Setting up managed PR daemon"); + if (qemuProcessMaybeStartManagedPRDaemon(vm) < 0) goto cleanup; VIR_DEBUG("Setting domain security labels"); @@ -6821,7 +6816,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, qemuDomainMasterKeyRemove(priv); /* Do this before we delete the tree and remove pidfile. */ - qemuProcessKillPRDaemon(vm); + qemuProcessKillManagedPRDaemon(vm); virFileDeleteTree(priv->libDir); virFileDeleteTree(priv->channelTargetDir); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index eda6695415..a0e34b1c85 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -205,9 +205,8 @@ int qemuProcessRefreshDisks(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob); -int qemuProcessStartPRDaemon(virDomainObjPtr vm, - const virDomainDiskDef *disk); +int qemuProcessStartManagedPRDaemon(virDomainObjPtr vm); -void qemuProcessKillPRDaemon(virDomainObjPtr vm); +void qemuProcessKillManagedPRDaemon(virDomainObjPtr vm); #endif /* __QEMU_PROCESS_H__ */ --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294743799382.15466141829575; Mon, 14 May 2018 03:45:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EE9230BDF88; Mon, 14 May 2018 10:45:42 +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 DFA2E30001DA; Mon, 14 May 2018 10:45:41 +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 8925D180124C; Mon, 14 May 2018 10:45:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAjcNk004145 for ; Mon, 14 May 2018 06:45:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id B2F2F10FFE6E; Mon, 14 May 2018 10:45:38 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C9110FFE6B for ; Mon, 14 May 2018 10:45:36 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:45:26 +0200 Message-Id: <3f929aa958d8e9317b5e1d04cb306001fa783113.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/13] qemu: command: Move check whether PR manager object props need to be built X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 14 May 2018 10:45:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move it out of the formatter function and let the caller decide this. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 9 +++------ src/qemu/qemu_hotplug.c | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7df9979cb2..c38dde5a60 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9687,9 +9687,6 @@ qemuBuildPRManagerInfoProps(const virDomainDiskDef *d= isk, *propsret =3D NULL; *aliasret =3D NULL; - if (!disk->src->pr) - return 0; - if (virStoragePRDefIsManaged(disk->src->pr)) { if (VIR_STRDUP(alias, qemuDomainGetManagedPRAlias()) < 0) goto cleanup; @@ -9725,6 +9722,9 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd, for (i =3D 0; i < def->ndisks; i++) { const virDomainDiskDef *disk =3D def->disks[i]; + if (!disk->src->pr) + continue; + if (virStoragePRDefIsManaged(disk->src->pr)) { if (managedAdded) continue; @@ -9735,9 +9735,6 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd, if (qemuBuildPRManagerInfoProps(disk, &props, &alias) < 0) goto cleanup; - if (!props) - continue; - if (!(tmp =3D virQEMUBuildObjectCommandlineFromJSON("pr-manager-he= lper", alias, props))) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3a26876c10..6557711ec1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -395,6 +395,9 @@ qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm, *propsret =3D NULL; *aliasret =3D NULL; + if (!disk->src->pr) + return 0; + if (virStoragePRDefIsManaged(disk->src->pr) && priv->prDaemonRunning) { /* @disk requires qemu-pr-helper but there's already one running. = */ --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294754426993.6089453742749; Mon, 14 May 2018 03:45:54 -0700 (PDT) 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 24E3B30D2C2E; Mon, 14 May 2018 10:45:53 +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 E0CBA6091D; Mon, 14 May 2018 10:45: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 9F1283FA56; Mon, 14 May 2018 10:45:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAjnWZ004179 for ; Mon, 14 May 2018 06:45:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4C04215CDAA; Mon, 14 May 2018 10:45:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79643215CDA7 for ; Mon, 14 May 2018 10:45:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:45:40 +0200 Message-Id: <5ec97f073281f79702476835a1f0ca3cc535cc37.1526294432.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/13] conf: domain: Add helper to check whether a domain def requires use of PR 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.42]); Mon, 14 May 2018 10:45:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the lookup code so that it can be reused later. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 21 +++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_process.c | 23 ++--------------------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86229db654..6f16e4ade4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29528,3 +29528,24 @@ virDomainDiskGetDetectZeroesMode(virDomainDiskDisc= ard discard, return detect_zeroes; } + + +/** + * virDomainDefHasManagedPR: + * @def: domain definition + * + * Returns true if any of the domain disks requires the use of the managed + * persistent reservations infrastructure. + */ +bool +virDomainDefHasManagedPR(const virDomainDef *def) +{ + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + if (virStoragePRDefIsManaged(def->disks[i]->src->pr)) + return true; + } + + return false; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 07d04fb2f9..f1add06155 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3543,4 +3543,7 @@ int virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard, virDomainDiskDetectZeroes detect_zeroes); +bool +virDomainDefHasManagedPR(const virDomainDef *def); + #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index dd10be9753..a0b78f72ba 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -275,6 +275,7 @@ virDomainDefGetVcpus; virDomainDefGetVcpusMax; virDomainDefGetVcpusTopology; virDomainDefHasDeviceAddress; +virDomainDefHasManagedPR; virDomainDefHasMemballoon; virDomainDefHasMemoryHotplug; virDomainDefHasUSB; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index af29bcc59e..5b73a61962 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2748,26 +2748,6 @@ qemuProcessStartManagedPRDaemon(virDomainObjPtr vm) } -static int -qemuProcessMaybeStartManagedPRDaemon(virDomainObjPtr vm) -{ - bool hasManaged =3D false; - size_t i; - - for (i =3D 0; i < vm->def->ndisks; i++) { - if (virStoragePRDefIsManaged(vm->def->disks[i]->src->pr)) { - hasManaged =3D true; - break; - } - } - - if (!hasManaged) - return 0; - - return qemuProcessStartManagedPRDaemon(vm); -} - - static int qemuProcessInitPasswords(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -6285,7 +6265,8 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; VIR_DEBUG("Setting up managed PR daemon"); - if (qemuProcessMaybeStartManagedPRDaemon(vm) < 0) + if (virDomainDefHasManagedPR(vm->def) && + qemuProcessStartManagedPRDaemon(vm) < 0) goto cleanup; VIR_DEBUG("Setting domain security labels"); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294759917464.3856590844066; Mon, 14 May 2018 03:45:59 -0700 (PDT) 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 9A02A3003E61; Mon, 14 May 2018 10:45:58 +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 6704017CFF; Mon, 14 May 2018 10:45:58 +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 215563FA5B; Mon, 14 May 2018 10:45:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAjtRE004205 for ; Mon, 14 May 2018 06:45:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CFF12166BAD; Mon, 14 May 2018 10:45:55 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99042215CDA7 for ; Mon, 14 May 2018 10:45:54 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:45:45 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/13] util: storage: Store PR manager alias in the definition X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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.42]); Mon, 14 May 2018 10:45:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than always re-generating the alias store it in the definition and in the status XML. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 23 +++------------------ src/qemu/qemu_command.h | 3 +-- src/qemu/qemu_domain.c | 16 +++++++++++++-- src/qemu/qemu_hotplug.c | 34 ++++++++++-----------------= ---- src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 3 +++ tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++ 7 files changed, 37 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c38dde5a60..84d7d51c7c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9669,7 +9669,6 @@ qemuBuildPanicCommandLine(virCommandPtr cmd, * qemuBuildPRManagerInfoProps: * @disk: disk definition * @propsret: Returns JSON object containing properties of the pr-manager-= helper object - * @aliasret: alias of the pr-manager-helper object * * Build the JSON properties for the pr-manager object. * @@ -9678,32 +9677,19 @@ qemuBuildPanicCommandLine(virCommandPtr cmd, */ int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk, - virJSONValuePtr *propsret, - char **aliasret) + virJSONValuePtr *propsret) { - char *alias =3D NULL; int ret =3D -1; *propsret =3D NULL; - *aliasret =3D NULL; - - if (virStoragePRDefIsManaged(disk->src->pr)) { - if (VIR_STRDUP(alias, qemuDomainGetManagedPRAlias()) < 0) - goto cleanup; - } else { - if (!(alias =3D qemuDomainGetUnmanagedPRAlias(disk->info.alias))) - goto cleanup; - } if (virJSONValueObjectCreate(propsret, "s:path", disk->src->pr->path, NULL) < 0) goto cleanup; - VIR_STEAL_PTR(*aliasret, alias); ret =3D 0; cleanup: - VIR_FREE(alias); return ret; } @@ -9715,7 +9701,6 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd, size_t i; bool managedAdded =3D false; virJSONValuePtr props =3D NULL; - char *alias =3D NULL; char *tmp =3D NULL; int ret =3D -1; @@ -9732,14 +9717,13 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd, managedAdded =3D true; } - if (qemuBuildPRManagerInfoProps(disk, &props, &alias) < 0) + if (qemuBuildPRManagerInfoProps(disk, &props) < 0) goto cleanup; if (!(tmp =3D virQEMUBuildObjectCommandlineFromJSON("pr-manager-he= lper", - alias, + disk->src->pr->m= gralias, props))) goto cleanup; - VIR_FREE(alias); virJSONValueFree(props); props =3D NULL; @@ -9749,7 +9733,6 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd, ret =3D 0; cleanup: - VIR_FREE(alias); virJSONValueFree(props); return ret; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 621592cd79..28bc33558b 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -56,8 +56,7 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr drive= r, /* Generate the object properties for pr-manager */ int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk, - virJSONValuePtr *propsret, - char **alias); + virJSONValuePtr *propsret); /* Generate the object properties for a secret */ int qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 92217e66fe..1572ce5c2d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1941,6 +1941,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr = ctxt, src->nodestorage =3D virXPathString("string(./nodenames/nodename[@type= =3D'storage']/@name)", ctxt); src->nodeformat =3D virXPathString("string(./nodenames/nodename[@type= =3D'format']/@name)", ctxt); + if (src->pr) + src->pr->mgralias =3D virXPathString("string(./reservations/@mgral= ias)", ctxt); + if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0) return -1; @@ -1961,6 +1964,9 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePt= r src, virBufferAddLit(buf, "\n"); } + if (src->pr) + virBufferAsprintf(buf, "\n", src->p= r->mgralias); + if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0) return -1; @@ -11932,7 +11938,8 @@ qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr = disk) static int qemuDomainPrepareStorageSourcePR(virStorageSourcePtr src, - qemuDomainObjPrivatePtr priv) + qemuDomainObjPrivatePtr priv, + const char *parentalias) { if (!src->pr) return 0; @@ -11940,6 +11947,11 @@ qemuDomainPrepareStorageSourcePR(virStorageSourceP= tr src, if (virStoragePRDefIsManaged(src->pr)) { if (!(src->pr->path =3D qemuDomainGetManagedPRSocketPath(priv))) return -1; + if (VIR_STRDUP(src->pr->mgralias, qemuDomainGetManagedPRAlias()) <= 0) + return -1; + } else { + if (!(src->pr->mgralias =3D qemuDomainGetUnmanagedPRAlias(parental= ias))) + return -1; } return 0; @@ -11962,7 +11974,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr dis= k, if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) = < 0) return -1; - if (qemuDomainPrepareStorageSourcePR(disk->src, priv) < 0) + if (qemuDomainPrepareStorageSourcePR(disk->src, priv, disk->info.alias= ) < 0) return -1; return 0; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6557711ec1..9481123c19 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -387,13 +387,11 @@ qemuDomainMaybeStartPRDaemon(virDomainObjPtr vm, static int qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm, const virDomainDiskDef *disk, - virJSONValuePtr *propsret, - char **aliasret) + virJSONValuePtr *propsret) { qemuDomainObjPrivatePtr priv =3D vm->privateData; *propsret =3D NULL; - *aliasret =3D NULL; if (!disk->src->pr) return 0; @@ -404,7 +402,7 @@ qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm, return 0; } - return qemuBuildPRManagerInfoProps(disk, propsret, aliasret); + return qemuBuildPRManagerInfoProps(disk, propsret); } @@ -425,7 +423,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, char *devstr =3D NULL; char *drivestr =3D NULL; char *drivealias =3D NULL; - char *prmgrAlias =3D NULL; bool driveAdded =3D false; bool secobjAdded =3D false; bool encobjAdded =3D false; @@ -462,7 +459,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0) goto error; - if (qemuMaybeBuildPRManagerInfoProps(vm, disk, &prmgrProps, &prmgrAlia= s) < 0) + if (qemuMaybeBuildPRManagerInfoProps(vm, disk, &prmgrProps) < 0) goto error; /* Start daemon only after prmgrProps is built. Otherwise @@ -511,7 +508,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, } if (prmgrProps) { - rv =3D qemuMonitorAddObject(priv->mon, "pr-manager-helper", prmgrA= lias, + rv =3D qemuMonitorAddObject(priv->mon, "pr-manager-helper", + disk->src->pr->mgralias, prmgrProps); prmgrProps =3D NULL; /* qemuMonitorAddObject consumes */ if (rv < 0) @@ -541,7 +539,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, virJSONValueFree(encobjProps); virJSONValueFree(secobjProps); qemuDomainSecretDiskDestroy(disk); - VIR_FREE(prmgrAlias); VIR_FREE(drivealias); VIR_FREE(drivestr); VIR_FREE(devstr); @@ -559,7 +556,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (encobjAdded) ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias)= ); if (prmgrAdded) - ignore_value(qemuMonitorDelObject(priv->mon, prmgrAlias)); + ignore_value(qemuMonitorDelObject(priv->mon, disk->src->pr->mgrali= as)); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -2; virErrorRestore(&orig_err); @@ -3832,22 +3829,18 @@ static bool qemuIsMultiFunctionDevice(virDomainDefP= tr def, static int qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, virDomainDiskDefPtr disk, - char **aliasret, bool *stopDaemon) { qemuDomainObjPrivatePtr priv =3D vm->privateData; size_t i; - *aliasret =3D NULL; *stopDaemon =3D false; if (!disk->src->pr) return 0; - if (!virStoragePRDefIsManaged(disk->src->pr)) { - *aliasret =3D qemuDomainGetUnmanagedPRAlias(disk->info.alias); - return *aliasret ? 0 : -1; - } + if (!virStoragePRDefIsManaged(disk->src->pr)) + return 0; for (i =3D 0; i < vm->def->ndisks; i++) { const virDomainDiskDef *domainDisk =3D vm->def->disks[i]; @@ -3862,9 +3855,6 @@ qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, if (i !=3D vm->def->ndisks) return 0; - if (VIR_STRDUP(*aliasret, qemuDomainGetManagedPRAlias()) < 0) - return -1; - if (priv->prDaemonRunning) *stopDaemon =3D true; @@ -3885,7 +3875,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, char *drivestr; char *objAlias =3D NULL; char *encAlias =3D NULL; - char *prmgrAlias =3D NULL; bool stopPRDaemon =3D false; VIR_DEBUG("Removing disk %s from domain %p %s", @@ -3924,7 +3913,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } - if (qemuDomainDiskNeedRemovePR(vm, disk, &prmgrAlias, &stopPRDaemon) <= 0) + if (qemuDomainDiskNeedRemovePR(vm, disk, &stopPRDaemon) < 0) return -1; qemuDomainObjEnterMonitor(driver, vm); @@ -3943,9 +3932,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, VIR_FREE(encAlias); /* If it fails, then so be it - it was a best shot */ - if (prmgrAlias) - ignore_value(qemuMonitorDelObject(priv->mon, prmgrAlias)); - VIR_FREE(prmgrAlias); + if (disk->src->pr) + ignore_value(qemuMonitorDelObject(priv->mon, disk->src->pr->mgrali= as)); if (disk->src->haveTLS) ignore_value(qemuMonitorDelObject(priv->mon, disk->src->tlsAlias)); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index dbbe758f30..54de2c1c30 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1899,6 +1899,7 @@ virStoragePRDefFree(virStoragePRDefPtr prd) return; VIR_FREE(prd->path); + VIR_FREE(prd->mgralias); VIR_FREE(prd); } diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 3a90c60fa5..1631c4cf66 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -221,6 +221,9 @@ typedef virStoragePRDef *virStoragePRDefPtr; struct _virStoragePRDef { int managed; /* enum virTristateBool */ char *path; + + /* manager object alias */ + char *mgralias; }; typedef struct _virStorageDriverData virStorageDriverData; diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index d57e1f605f..d63fcf79f1 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -308,11 +308,15 @@ + + + + base.qcow2 --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:33:14 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526294765654538.90415659918; Mon, 14 May 2018 03:46:05 -0700 (PDT) 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 229E630012DB; Mon, 14 May 2018 10:46:04 +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 D735117D57; Mon, 14 May 2018 10:46: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 5BE4A180124D; Mon, 14 May 2018 10:46:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EAk1Pn004228 for ; Mon, 14 May 2018 06:46:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E97910FFE6E; Mon, 14 May 2018 10:46:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id E839810FFE6B for ; Mon, 14 May 2018 10:45:58 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 14 May 2018 12:45:49 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/13] qemu: hotplug: Replace qemuDomainDiskNeedRemovePR 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.44]); Mon, 14 May 2018 10:46:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function can be replaced by much simpler logic. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9481123c19..96042bc06c 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3826,42 +3826,6 @@ static bool qemuIsMultiFunctionDevice(virDomainDefPt= r def, } -static int -qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, - virDomainDiskDefPtr disk, - bool *stopDaemon) -{ - qemuDomainObjPrivatePtr priv =3D vm->privateData; - size_t i; - - *stopDaemon =3D false; - - if (!disk->src->pr) - return 0; - - if (!virStoragePRDefIsManaged(disk->src->pr)) - return 0; - - for (i =3D 0; i < vm->def->ndisks; i++) { - const virDomainDiskDef *domainDisk =3D vm->def->disks[i]; - - if (domainDisk =3D=3D disk) - continue; - - if (virStoragePRDefIsManaged(domainDisk->src->pr)) - break; - } - - if (i !=3D vm->def->ndisks) - return 0; - - if (priv->prDaemonRunning) - *stopDaemon =3D true; - - return 0; -} - - static int qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3875,7 +3839,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, char *drivestr; char *objAlias =3D NULL; char *encAlias =3D NULL; - bool stopPRDaemon =3D false; VIR_DEBUG("Removing disk %s from domain %p %s", disk->info.alias, vm, vm->def->name); @@ -3913,9 +3876,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } - if (qemuDomainDiskNeedRemovePR(vm, disk, &stopPRDaemon) < 0) - return -1; - qemuDomainObjEnterMonitor(driver, vm); qemuMonitorDriveDel(priv->mon, drivestr); @@ -3953,7 +3913,9 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } - if (stopPRDaemon) + /* check if the last disk with managed PR was just removed */ + if (priv->prDaemonRunning && + !virDomainDefHasManagedPR(vm->def)) qemuProcessKillManagedPRDaemon(vm); qemuDomainReleaseDeviceAddress(vm, &disk->info, src); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list