From nobody Thu May 15 06:01:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1511546114422203.9864954450377; Fri, 24 Nov 2017 09:55:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 498FD5D9E2; Fri, 24 Nov 2017 17:55:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F3AB6198F; Fri, 24 Nov 2017 17:55:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DA1E01800C87; Fri, 24 Nov 2017 17:55:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAOHt6lr025080 for ; Fri, 24 Nov 2017 12:55:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 64BEE17B16; Fri, 24 Nov 2017 17:55:06 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFBE517B12 for ; Fri, 24 Nov 2017 17:55:05 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 24 Nov 2017 18:54:53 +0100 Message-Id: <667bbb74e5918f75b59c1cb6a4a7de4dc8eace56.1511546041.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] Introduce qemuDomainNamespaceMknodPaths X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 24 Nov 2017 17:55:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Separate the logic of creating devices from their gathering. Use this new function in qemuDomainNamespaceSetupHostdev and qemuDomainNamespaceSetupDisk. --- src/qemu/qemu_domain.c | 82 +++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c4a1e6d0b..d931afd3d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9657,16 +9657,18 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr drive= r ATTRIBUTE_UNUSED, } =20 =20 -int -qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virStorageSourcePtr src) +static int +qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, + const char **paths, + size_t npaths) { - virQEMUDriverConfigPtr cfg =3D NULL; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + virQEMUDriverConfigPtr cfg; char **devMountsPath =3D NULL; size_t ndevMountsPath =3D 0; - virStorageSourcePtr next; int ret =3D -1; + size_t i; =20 if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) return 0; @@ -9677,6 +9679,35 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver, &ndevMountsPath) < 0) goto cleanup; =20 + for (i =3D 0; i < npaths; i++) { + if (qemuDomainAttachDeviceMknod(driver, + vm, + paths[i], + devMountsPath, ndevMountsPath) < 0) + goto cleanup; + } + + ret =3D 0; + cleanup: + virStringListFreeCount(devMountsPath, ndevMountsPath); + virObjectUnref(cfg); + return ret; +} + + +int +qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, + virDomainObjPtr vm, + virStorageSourcePtr src) +{ + virStorageSourcePtr next; + char **paths =3D NULL; + size_t npaths; + int ret =3D -1; + + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + for (next =3D src; virStorageSourceIsBacking(next); next =3D next->bac= kingStore) { if (virStorageSourceIsEmpty(next) || !virStorageSourceIsLocalStorage(next)) { @@ -9684,17 +9715,16 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr drive= r, continue; } =20 - if (qemuDomainAttachDeviceMknod(driver, - vm, - next->path, - devMountsPath, ndevMountsPath) < 0) + if (VIR_APPEND_ELEMENT_COPY(paths, npaths, next->path) < 0) goto cleanup; } =20 + if (qemuDomainNamespaceMknodPaths(vm, (const char **)paths, npaths) < = 0) + return -1; + ret =3D 0; cleanup: - virStringListFreeCount(devMountsPath, ndevMountsPath); - virObjectUnref(cfg); + VIR_FREE(paths); return ret; } =20 @@ -9715,44 +9745,28 @@ qemuDomainNamespaceTeardownDisk(virQEMUDriverPtr dr= iver ATTRIBUTE_UNUSED, =20 =20 int -qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver, +qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { - virQEMUDriverConfigPtr cfg =3D NULL; - char **devMountsPath =3D NULL; - size_t ndevMountsPath =3D 0; int ret =3D -1; - char **path =3D NULL; + char **paths =3D NULL; size_t i, npaths =3D 0; =20 if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) return 0; =20 - if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &path, NUL= L) < 0) + if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &paths, NU= LL) < 0) goto cleanup; =20 - cfg =3D virQEMUDriverGetConfig(driver); - if (qemuDomainGetPreservedMounts(cfg, vm, - &devMountsPath, NULL, - &ndevMountsPath) < 0) - goto cleanup; - - for (i =3D 0; i < npaths; i++) { - if (qemuDomainAttachDeviceMknod(driver, - vm, - path[i], - devMountsPath, ndevMountsPath) < 0) + if (qemuDomainNamespaceMknodPaths(vm, (const char **)paths, npaths) < = 0) goto cleanup; - } =20 ret =3D 0; cleanup: for (i =3D 0; i < npaths; i++) - VIR_FREE(path[i]); - VIR_FREE(path); - virStringListFreeCount(devMountsPath, ndevMountsPath); - virObjectUnref(cfg); + VIR_FREE(paths[i]); + VIR_FREE(paths); return ret; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list