From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486550449039135.52652514328588; Wed, 8 Feb 2017 02:40:49 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbTPF006624; Wed, 8 Feb 2017 05:37:29 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbNIj001354 for ; Wed, 8 Feb 2017 05:37:23 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHb029088 for ; Wed, 8 Feb 2017 05:37:22 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:04 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/11] qemuDomainAttachSCSIVHostDevice: Prefer qemuSecurity wrappers 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we have qemuSecurity wrappers over virSecurityManagerSetHostdevLabel and virSecurityManagerRestoreHostdevLabel we ought to use them instead of calling secdriver APIs directly. Signed-off-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e272df356..dd6e31823 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2552,8 +2552,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driv= er, goto cleanup; teardowncgroup =3D true; =20 - if (virSecurityManagerSetHostdevLabel(driver->securityManager, - vm->def, hostdev, NULL) < 0) + if (qemuSecuritySetHostdevLabel(driver, vm, hostdev) < 0) goto cleanup; teardownlabel =3D true; =20 @@ -2612,8 +2611,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driv= er, if (teardowncgroup && qemuTeardownHostdevCgroup(vm, hostdev) < 0) VIR_WARN("Unable to remove host device cgroup ACL on hotplug f= ail"); if (teardownlabel && - virSecurityManagerRestoreHostdevLabel(driver->securityManager, - vm->def, hostdev, NULL) = < 0) + qemuSecurityRestoreHostdevLabel(driver, vm, hostdev) < 0) VIR_WARN("Unable to restore host device labelling on hotplug f= ail"); if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL); --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486550445987343.98437433236893; Wed, 8 Feb 2017 02:40:45 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbPj4047652; Wed, 8 Feb 2017 05:37:26 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbOYs001364 for ; Wed, 8 Feb 2017 05:37:24 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHc029088 for ; Wed, 8 Feb 2017 05:37:23 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:05 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/11] syntax-check: Enforce qemuSecurity 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we have some qemuSecurity wrappers over virSecurityManager APIs, lets make sure everybody sticks with them. We have them for a reason and calling virSecurityManager API directly instead of wrapper may lead into accidentally labelling a file on the host instead of namespace. Signed-off-by: Michal Privoznik --- cfg.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cfg.mk b/cfg.mk index 69e3f3a1a..6fb2fc961 100644 --- a/cfg.mk +++ b/cfg.mk @@ -585,6 +585,14 @@ sc_prohibit_unsigned_pid: halt=3D'use signed type for pid values' \ $(_sc_search_regexp) =20 +sc_prohibit_direct_secdriver: + @for i in $$(grep -i ^WRAP.\( src/qemu/qemu_security.c | \ + awk 'BEGIN {FS =3D "[^[:alnum:]]"} {print "virSecurityManager" $$2 }'); d= o \ + grep -n $$i $$($(VC_LIST_EXCEPT) | grep -E '^src/qemu/') && \ + { echo "$(ME): prefer qemuSecurity$${i#virSecurityManager} over $$i" 1>= &2; exit 1; } \ + done || : + + # Many of the function names below came from this filter: # git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$'= \ # |sed 's/.*\.c- *//'|perl -pe 's/ ?\(.*//'|sort -u \ --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1486550451106280.8877700547911; Wed, 8 Feb 2017 02:40:51 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbUZO027556; Wed, 8 Feb 2017 05:37:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbOAb001377 for ; Wed, 8 Feb 2017 05:37:24 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHd029088 for ; Wed, 8 Feb 2017 05:37:24 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:06 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/11] qemuDomainAttachSCSIVHostDevice: manage /dev entry 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Again, one missed bit. This time without this commit there is no /dev entry when attaching vhost SCSI device. Signed-off-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index dd6e31823..778c8ef20 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2532,6 +2532,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driv= er, char *devstr =3D NULL; bool teardowncgroup =3D false; bool teardownlabel =3D false; + bool teardowndevice =3D false; bool releaseaddr =3D false; =20 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) { @@ -2548,6 +2549,10 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr dri= ver, return -1; } =20 + if (qemuDomainNamespaceSetupHostdev(driver, vm, hostdev) < 0) + goto cleanup; + teardowndevice =3D true; + if (qemuSetupHostdevCgroup(vm, hostdev) < 0) goto cleanup; teardowncgroup =3D true; @@ -2613,6 +2618,9 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driv= er, if (teardownlabel && qemuSecurityRestoreHostdevLabel(driver, vm, hostdev) < 0) VIR_WARN("Unable to restore host device labelling on hotplug f= ail"); + if (teardowndevice && + qemuDomainNamespaceTeardownHostdev(driver, vm, hostdev) < 0) + VIR_WARN("Unable to remove host device from /dev"); if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL); } --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486550474371938.2282190924019; Wed, 8 Feb 2017 02:41:14 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbSA7047665; Wed, 8 Feb 2017 05:37:28 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbPaP001385 for ; Wed, 8 Feb 2017 05:37:25 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHe029088 for ; Wed, 8 Feb 2017 05:37:25 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:07 +0100 Message-Id: <5454772dfed0542ccc023636213916cd1f5df865.1486550004.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/11] qemu_security: Kill code duplication 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Nearly all of these functions look the same. Except for a different virSecurityManager API call. There is no need to copy paste the code when we can use macros to generate it. Signed-off-by: Michal Privoznik --- src/qemu/qemu_security.c | 179 ++++++++++++-------------------------------= ---- 1 file changed, 44 insertions(+), 135 deletions(-) diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 35cdf50b0..b2155afcf 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -40,33 +40,49 @@ struct qemuSecuritySetRestoreAllLabelData { }; =20 =20 -int -qemuSecuritySetAllLabel(virQEMUDriverPtr driver, - virDomainObjPtr vm, - const char *stdin_path) -{ - int ret =3D -1; +#define PROLOGUE(F, type) = \ +int = \ +qemuSecurity##F(virQEMUDriverPtr driver, = \ + virDomainObjPtr vm, = \ + type var) = \ +{ = \ + int ret =3D -1; = \ + = \ + if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && = \ + virSecurityManagerTransactionStart(driver->securityManager) < 0) = \ + goto cleanup; = \ =20 - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionStart(driver->securityManager) < 0) - goto cleanup; - - if (virSecurityManagerSetAllLabel(driver->securityManager, - vm->def, - stdin_path) < 0) - goto cleanup; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionCommit(driver->securityManager, - vm->pid) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virSecurityManagerTransactionAbort(driver->securityManager); - return ret; +#define EPILOGUE = \ + if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && = \ + virSecurityManagerTransactionCommit(driver->securityManager, = \ + vm->pid) < 0) = \ + goto cleanup; = \ + = \ + ret =3D 0; = \ + cleanup: = \ + virSecurityManagerTransactionAbort(driver->securityManager); = \ + return ret; = \ } =20 +#define WRAP1(F, type) = \ + PROLOGUE(F, type) = \ + if (virSecurityManager##F(driver->securityManager, = \ + vm->def, = \ + var) < 0) = \ + goto cleanup; = \ + = \ + EPILOGUE + +#define WRAP2(F, type) = \ + PROLOGUE(F, type) = \ + if (virSecurityManager##F(driver->securityManager, = \ + vm->def, = \ + var, NULL) < 0) = \ + goto cleanup; = \ + = \ + EPILOGUE + +WRAP1(SetAllLabel, const char *) =20 void qemuSecurityRestoreAllLabel(virQEMUDriverPtr driver, @@ -85,115 +101,8 @@ qemuSecurityRestoreAllLabel(virQEMUDriverPtr driver, } =20 =20 -int -qemuSecuritySetDiskLabel(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDiskDefPtr disk) -{ - int ret =3D -1; +WRAP1(SetDiskLabel, virDomainDiskDefPtr) +WRAP1(RestoreDiskLabel, virDomainDiskDefPtr) =20 - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionStart(driver->securityManager) < 0) - goto cleanup; - - if (virSecurityManagerSetDiskLabel(driver->securityManager, - vm->def, - disk) < 0) - goto cleanup; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionCommit(driver->securityManager, - vm->pid) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virSecurityManagerTransactionAbort(driver->securityManager); - return ret; -} - - -int -qemuSecurityRestoreDiskLabel(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDiskDefPtr disk) -{ - int ret =3D -1; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionStart(driver->securityManager) < 0) - goto cleanup; - - if (virSecurityManagerRestoreDiskLabel(driver->securityManager, - vm->def, - disk) < 0) - goto cleanup; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionCommit(driver->securityManager, - vm->pid) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virSecurityManagerTransactionAbort(driver->securityManager); - return ret; -} - - -int -qemuSecuritySetHostdevLabel(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainHostdevDefPtr hostdev) -{ - int ret =3D -1; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionStart(driver->securityManager) < 0) - goto cleanup; - - if (virSecurityManagerSetHostdevLabel(driver->securityManager, - vm->def, - hostdev, - NULL) < 0) - goto cleanup; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionCommit(driver->securityManager, - vm->pid) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virSecurityManagerTransactionAbort(driver->securityManager); - return ret; -} - - -int -qemuSecurityRestoreHostdevLabel(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainHostdevDefPtr hostdev) -{ - int ret =3D -1; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionStart(driver->securityManager) < 0) - goto cleanup; - - if (virSecurityManagerRestoreHostdevLabel(driver->securityManager, - vm->def, - hostdev, - NULL) < 0) - goto cleanup; - - if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) && - virSecurityManagerTransactionCommit(driver->securityManager, - vm->pid) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virSecurityManagerTransactionAbort(driver->securityManager); - return ret; -} +WRAP2(SetHostdevLabel, virDomainHostdevDefPtr) +WRAP2(RestoreHostdevLabel, virDomainHostdevDefPtr) --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486550503847126.74465484517464; Wed, 8 Feb 2017 02:41:43 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbWCV006650; Wed, 8 Feb 2017 05:37:32 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbQ0F001396 for ; Wed, 8 Feb 2017 05:37:26 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHf029088 for ; Wed, 8 Feb 2017 05:37:26 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:08 +0100 Message-Id: <1f3c8a7c11ff77f35897904f10f2d435898ee3d0.1486550004.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/11] qemu_security: Drop qemuSecuritySetRestoreAllLabelData struct 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This struct is unused after 095f042ed68b01. Signed-off-by: Michal Privoznik --- src/qemu/qemu_security.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index b2155afcf..06bff2470 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -31,15 +31,6 @@ =20 VIR_LOG_INIT("qemu.qemu_process"); =20 -struct qemuSecuritySetRestoreAllLabelData { - bool set; - virQEMUDriverPtr driver; - virDomainObjPtr vm; - const char *stdin_path; - bool migrated; -}; - - #define PROLOGUE(F, type) = \ int = \ qemuSecurity##F(virQEMUDriverPtr driver, = \ --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486550475981910.5402606046838; Wed, 8 Feb 2017 02:41:15 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbTD4006629; Wed, 8 Feb 2017 05:37:29 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbRqE001405 for ; Wed, 8 Feb 2017 05:37:27 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHg029088 for ; Wed, 8 Feb 2017 05:37:26 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:09 +0100 Message-Id: <305db64c1a9650ac1543a5ec21afa7780ffcff71.1486550004.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/11] qemu_domain: Don't pass virDomainDeviceDefPtr to ns helpers 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no need for this. None of the namespace helpers uses it. Historically it was used when calling secdriver APIs, but we don't to that anymore. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 54e63878f..067b7a42f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7643,7 +7643,6 @@ qemuDomainCreateNamespace(virQEMUDriverPtr driver, struct qemuDomainAttachDeviceMknodData { virQEMUDriverPtr driver; virDomainObjPtr vm; - virDomainDeviceDefPtr devDef; const char *file; const char *target; struct stat sb; @@ -7747,7 +7746,6 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE= _UNUSED, static int qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDeviceDefPtr devDef, const char *file, unsigned int ttl) { @@ -7767,7 +7765,6 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr= driver, =20 data.driver =3D driver; data.vm =3D vm; - data.devDef =3D devDef; data.file =3D file; =20 if (lstat(file, &data.sb) < 0) { @@ -7840,8 +7837,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr= driver, } =20 if (isLink && - qemuDomainAttachDeviceMknodRecursive(driver, vm, devDef, - target, ttl -1) < 0) + qemuDomainAttachDeviceMknodRecursive(driver, vm, target, ttl -1) <= 0) goto cleanup; =20 ret =3D 0; @@ -7858,13 +7854,11 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverP= tr driver, static int qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDeviceDefPtr devDef, const char *file) { long symloop_max =3D sysconf(_SC_SYMLOOP_MAX); =20 - return qemuDomainAttachDeviceMknodRecursive(driver, vm, devDef, - file, symloop_max); + return qemuDomainAttachDeviceMknodRecursive(driver, vm, file, symloop_= max); } =20 =20 @@ -7888,7 +7882,6 @@ qemuDomainDetachDeviceUnlinkHelper(pid_t pid ATTRIBUT= E_UNUSED, static int qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr vm, - virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED, const char *file) { if (virProcessRunInMountNamespace(vm->pid, @@ -7905,7 +7898,6 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_DISK, .data.di= sk =3D disk}; virStorageSourcePtr next; const char *src =3D NULL; struct stat sb; @@ -7935,7 +7927,6 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, =20 if (qemuDomainAttachDeviceMknod(driver, vm, - &dev, next->path) < 0) goto cleanup; } @@ -7966,7 +7957,6 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driv= er, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_HOSTDEV, .data= .hostdev =3D hostdev}; int ret =3D -1; char *path =3D NULL; =20 @@ -7984,7 +7974,6 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driv= er, =20 if (qemuDomainAttachDeviceMknod(driver, vm, - &dev, path) < 0) goto cleanup; ret =3D 0; @@ -7999,7 +7988,6 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr d= river, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_HOSTDEV, .data= .hostdev =3D hostdev}; int ret =3D -1; char *path =3D NULL; =20 @@ -8015,7 +8003,7 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr d= river, goto cleanup; } =20 - if (qemuDomainDetachDeviceUnlink(driver, vm, &dev, path) < 0) + if (qemuDomainDetachDeviceUnlink(driver, vm, path) < 0) goto cleanup; =20 ret =3D 0; @@ -8030,7 +8018,6 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driv= er, virDomainObjPtr vm, virDomainChrDefPtr chr) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_CHR, .data.chr= =3D chr}; const char *path; int ret =3D -1; =20 @@ -8044,7 +8031,6 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driv= er, =20 if (qemuDomainAttachDeviceMknod(driver, vm, - &dev, path) < 0) goto cleanup; ret =3D 0; @@ -8058,7 +8044,6 @@ qemuDomainNamespaceTeardownChardev(virQEMUDriverPtr d= river, virDomainObjPtr vm, virDomainChrDefPtr chr) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_CHR, .data.chr= =3D chr}; int ret =3D -1; const char *path =3D NULL; =20 @@ -8070,7 +8055,7 @@ qemuDomainNamespaceTeardownChardev(virQEMUDriverPtr d= river, =20 path =3D chr->source->data.file.path; =20 - if (qemuDomainDetachDeviceUnlink(driver, vm, &dev, path) < 0) + if (qemuDomainDetachDeviceUnlink(driver, vm, path) < 0) goto cleanup; =20 ret =3D 0; @@ -8084,7 +8069,6 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainRNGDefPtr rng) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_RNG, .data.rng= =3D rng}; const char *path =3D NULL; int ret =3D -1; =20 @@ -8104,7 +8088,6 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver, =20 if (qemuDomainAttachDeviceMknod(driver, vm, - &dev, path) < 0) goto cleanup; ret =3D 0; @@ -8118,7 +8101,6 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr drive= r, virDomainObjPtr vm, virDomainRNGDefPtr rng) { - virDomainDeviceDef dev =3D {.type =3D VIR_DOMAIN_DEVICE_RNG, .data.rng= =3D rng}; int ret =3D -1; const char *path =3D NULL; =20 @@ -8136,7 +8118,7 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr drive= r, goto cleanup; } =20 - if (qemuDomainDetachDeviceUnlink(driver, vm, &dev, path) < 0) + if (qemuDomainDetachDeviceUnlink(driver, vm, path) < 0) goto cleanup; =20 ret =3D 0; --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486550483736822.3621209651386; Wed, 8 Feb 2017 02:41:23 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbWUJ006647; Wed, 8 Feb 2017 05:37:32 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbSij001410 for ; Wed, 8 Feb 2017 05:37:28 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHh029088 for ; Wed, 8 Feb 2017 05:37:27 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:10 +0100 Message-Id: <9293767fc7a99f656972ba0cc1844c218a18da09.1486550004.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/11] qemuDomainNamespaceSetupDisk: Drop useless @src variable 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since its introduction in 81df21507bef9 this variable was never used. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 067b7a42f..8ec9601d2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7899,7 +7899,6 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, virDomainDiskDefPtr disk) { virStorageSourcePtr next; - const char *src =3D NULL; struct stat sb; int ret =3D -1; =20 @@ -7914,14 +7913,14 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr drive= r, =20 if (stat(next->path, &sb) < 0) { virReportSystemError(errno, - _("Unable to access %s"), src); + _("Unable to access %s"), next->path); goto cleanup; } =20 if (!S_ISBLK(sb.st_mode)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Disk source %s must be a block device"), - src); + next->path); goto cleanup; } =20 --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 148655047936661.39502154883792; Wed, 8 Feb 2017 02:41:19 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbXem032261; Wed, 8 Feb 2017 05:37:34 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbTmX001418 for ; Wed, 8 Feb 2017 05:37:29 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHi029088 for ; Wed, 8 Feb 2017 05:37:28 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:11 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/11] qemuDomainNamespace{Setup, Teardown}Disk: Don't pass pointer to full disk 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" These functions do not need to see the whole virDomainDiskDef. Moreover, they are going to be called from places where we don't have access to the full disk definition. Sticking with virStorageSource is more than enough. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 8 ++++---- src/qemu/qemu_domain.h | 4 ++-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_hotplug.c | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8ec9601d2..5db8b60c5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7896,7 +7896,7 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver = ATTRIBUTE_UNUSED, int qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDiskDefPtr disk) + virStorageSourcePtr src) { virStorageSourcePtr next; struct stat sb; @@ -7905,8 +7905,8 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) return 0; =20 - for (next =3D disk->src; next; next =3D next->backingStore) { - if (!next->path || !virStorageSourceIsBlockLocal(disk->src)) { + for (next =3D src; next; next =3D next->backingStore) { + if (!next->path || !virStorageSourceIsBlockLocal(src)) { /* Not creating device. Just continue. */ continue; } @@ -7939,7 +7939,7 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, int qemuDomainNamespaceTeardownDisk(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr vm ATTRIBUTE_UNUSED, - virDomainDiskDefPtr disk ATTRIBUTE_UNUSED) + virStorageSourcePtr src ATTRIBUTE_UNUSED) { /* While in hotplug case we create the whole backing chain, * here we must limit ourselves. The disk we want to remove diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 39731826e..5cfa3e114 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -810,11 +810,11 @@ int qemuDomainCreateNamespace(virQEMUDriverPtr driver, =20 int qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDiskDefPtr disk); + virStorageSourcePtr src); =20 int qemuDomainNamespaceTeardownDisk(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDiskDefPtr disk); + virStorageSourcePtr src); =20 int qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 37ccfdf6b..89bc833de 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15915,7 +15915,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, =20 if (disk->mirror->format && disk->mirror->format !=3D VIR_STORAGE_FILE_RAW && - (qemuDomainNamespaceSetupDisk(driver, vm, disk) < 0 || + (qemuDomainNamespaceSetupDisk(driver, vm, disk->src) < 0 || qemuSetupDiskCgroup(vm, disk) < 0 || qemuSecuritySetDiskLabel(driver, vm, disk) < 0)) goto cleanup; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 778c8ef20..2f209f12b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -110,7 +110,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver, vm, disk) < 0) goto cleanup; =20 - if (qemuDomainNamespaceSetupDisk(driver, vm, disk) < 0) + if (qemuDomainNamespaceSetupDisk(driver, vm, disk->src) < 0) goto rollback_lock; =20 if (qemuSecuritySetDiskLabel(driver, vm, disk) < 0) @@ -132,7 +132,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver, virDomainDiskGetSource(disk)); =20 rollback_namespace: - if (qemuDomainNamespaceTeardownDisk(driver, vm, disk) < 0) + if (qemuDomainNamespaceTeardownDisk(driver, vm, disk->src) < 0) VIR_WARN("Unable to remove /dev entry for %s", virDomainDiskGetSource(disk)); =20 @@ -3649,7 +3649,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0) VIR_WARN("Unable to release lock on %s", src); =20 - if (qemuDomainNamespaceTeardownDisk(driver, vm, disk) < 0) + if (qemuDomainNamespaceTeardownDisk(driver, vm, disk->src) < 0) VIR_WARN("Unable to remove /dev entry for %s", src); =20 dev.type =3D VIR_DOMAIN_DEVICE_DISK; --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486550480178356.2090079618514; Wed, 8 Feb 2017 02:41:20 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbZAI006672; Wed, 8 Feb 2017 05:37:35 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbTec001434 for ; Wed, 8 Feb 2017 05:37:29 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHj029088 for ; Wed, 8 Feb 2017 05:37:29 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:12 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/11] qemuDomainDiskChainElement{Prepare, Revoke}: manage /dev entry 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Again, one missed bit. This time without this commit there is no /dev entry when doing disk snapshots. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5db8b60c5..9e34d73be 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5090,14 +5090,17 @@ qemuDomainDiskChainElementRevoke(virQEMUDriverPtr d= river, virDomainObjPtr vm, virStorageSourcePtr elem) { - if (virSecurityManagerRestoreImageLabel(driver->securityManager, - vm->def, elem) < 0) - VIR_WARN("Unable to restore security label on %s", NULLSTR(elem->p= ath)); - if (qemuTeardownImageCgroup(vm, elem) < 0) VIR_WARN("Failed to teardown cgroup for disk path %s", NULLSTR(elem->path)); =20 + if (virSecurityManagerRestoreImageLabel(driver->securityManager, + vm->def, elem) < 0) + VIR_WARN("Unable to restore security label on %s", NULLSTR(elem->p= ath)); + + if (qemuDomainNamespaceTeardownDisk(driver, vm, elem) < 0) + VIR_WARN("Unable to remove /dev entry for %s", NULLSTR(elem->path)= ); + if (virDomainLockImageDetach(driver->lockManager, vm, elem) < 0) VIR_WARN("Unable to release lock on %s", NULLSTR(elem->path)); } @@ -5126,6 +5129,9 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr dr= iver, if (virDomainLockImageAttach(driver->lockManager, cfg->uri, vm, elem) = < 0) goto cleanup; =20 + if (qemuDomainNamespaceSetupDisk(driver, vm, elem) < 0) + goto cleanup; + if (qemuSetupImageCgroup(vm, elem) < 0) goto cleanup; =20 --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486550493867306.0323596980372; Wed, 8 Feb 2017 02:41:33 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbWJk047682; Wed, 8 Feb 2017 05:37:32 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbUI2001441 for ; Wed, 8 Feb 2017 05:37:30 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHk029088 for ; Wed, 8 Feb 2017 05:37:30 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:13 +0100 Message-Id: <638131b397735d3a4073dfa662ad790ebcbc9b5b.1486550004.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/11] qemu_security: Introduce ImageLabel APIs 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Just like we need wrappers over other virSecurityManager APIs, we need one for virSecurityManagerSetImageLabel and virSecurityManagerRestoreImageLabel. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 7 +++---- src/qemu/qemu_security.c | 3 +++ src/qemu/qemu_security.h | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9e34d73be..a4ee652db 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -31,6 +31,7 @@ #include "qemu_parse_command.h" #include "qemu_capabilities.h" #include "qemu_migration.h" +#include "qemu_security.h" #include "viralloc.h" #include "virlog.h" #include "virerror.h" @@ -5094,8 +5095,7 @@ qemuDomainDiskChainElementRevoke(virQEMUDriverPtr dri= ver, VIR_WARN("Failed to teardown cgroup for disk path %s", NULLSTR(elem->path)); =20 - if (virSecurityManagerRestoreImageLabel(driver->securityManager, - vm->def, elem) < 0) + if (qemuSecurityRestoreImageLabel(driver, vm, elem) < 0) VIR_WARN("Unable to restore security label on %s", NULLSTR(elem->p= ath)); =20 if (qemuDomainNamespaceTeardownDisk(driver, vm, elem) < 0) @@ -5135,8 +5135,7 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr dr= iver, if (qemuSetupImageCgroup(vm, elem) < 0) goto cleanup; =20 - if (virSecurityManagerSetImageLabel(driver->securityManager, vm->def, - elem) < 0) + if (qemuSecuritySetImageLabel(driver, vm, elem) < 0) goto cleanup; =20 ret =3D 0; diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 06bff2470..131be6e4b 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -95,5 +95,8 @@ qemuSecurityRestoreAllLabel(virQEMUDriverPtr driver, WRAP1(SetDiskLabel, virDomainDiskDefPtr) WRAP1(RestoreDiskLabel, virDomainDiskDefPtr) =20 +WRAP1(SetImageLabel, virStorageSourcePtr) +WRAP1(RestoreImageLabel, virStorageSourcePtr) + WRAP2(SetHostdevLabel, virDomainHostdevDefPtr) WRAP2(RestoreHostdevLabel, virDomainHostdevDefPtr) diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h index cc373b3e1..54638908d 100644 --- a/src/qemu/qemu_security.h +++ b/src/qemu/qemu_security.h @@ -45,6 +45,14 @@ int qemuSecurityRestoreDiskLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk); =20 +int qemuSecuritySetImageLabel(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virStorageSourcePtr src); + +int qemuSecurityRestoreImageLabel(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virStorageSourcePtr src); + int qemuSecuritySetHostdevLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev); --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:58:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1486550479050583.2583153352269; Wed, 8 Feb 2017 02:41:19 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbXFN027574; Wed, 8 Feb 2017 05:37:33 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18AbVl7001447 for ; Wed, 8 Feb 2017 05:37:31 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18AbLHl029088 for ; Wed, 8 Feb 2017 05:37:31 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 11:37:14 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/11] qemuDomainNamespaceSetupDisk: Simplify disk check 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Firstly, instead of checking for next->path the virStorageSourceIsEmpty() function should be used which also takes disk type into account. Secondly, not every disk source passed has the correct type set (due to our laziness). Therefore, instead of checking for virStorageSourceIsBlockLocal() and also S_ISBLK() the former can be refined to just virStorageSourceIsLocalStorage(). Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a4ee652db..7c696963e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7911,7 +7911,8 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, return 0; =20 for (next =3D src; next; next =3D next->backingStore) { - if (!next->path || !virStorageSourceIsBlockLocal(src)) { + if (virStorageSourceIsEmpty(next) || + !virStorageSourceIsLocalStorage(next)) { /* Not creating device. Just continue. */ continue; } @@ -7922,12 +7923,8 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, goto cleanup; } =20 - if (!S_ISBLK(sb.st_mode)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Disk source %s must be a block device"), - next->path); - goto cleanup; - } + if (!S_ISBLK(sb.st_mode)) + continue; =20 if (qemuDomainAttachDeviceMknod(driver, vm, --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list