From nobody Wed May 14 10:39:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 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