From nobody Sun Feb 8 19:56:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1595411043; cv=none; d=zohomail.com; s=zohoarc; b=irIILyBsjckhSX6E/UplQWuSd7X1gGx14c7TPgNWgacJkwB0jAQNIFgJxWZzyMm5mXI2H8Urda5R6oEOvi4q53md2k3/okXb9hog4zNSJBq5pqaZwsI2kJWcnUACc2o/lLqJsRzOYyEYC3DBHjE1ARLjcATUyqGgT+YPWI6+cng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595411043; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FIlmuw8h6RvLmTYPAbmyM2PE74rvOFowbpiW1Nnyk5s=; b=WRwjDkOYi3eA1hoKsBfEiWRMLcKZazo7cVts0+EkWiuIyDqnAYoP7p147O8o9vYED8cNMJx5htjV0RhtENhxZ/mlu/GMymazUPnWey1DiXXno8dMiIKfsktgKwHUlb8BmkZN1R+pg/qEdXAioQ0+f32tcKGAqiUIJP3/ZcaLx0c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1595411043516510.0242531784778; Wed, 22 Jul 2020 02:44:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-gl23h0EuP-G-PudxAY8I5g-1; Wed, 22 Jul 2020 05:44:00 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB5028015F7; Wed, 22 Jul 2020 09:43:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C355D1001B2C; Wed, 22 Jul 2020 09:43:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 31F511800B72; Wed, 22 Jul 2020 09:43:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.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 06M9efrd000856 for ; Wed, 22 Jul 2020 05:40:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4A82A1A8F7; Wed, 22 Jul 2020 09:40:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD5F12B4DA for ; Wed, 22 Jul 2020 09:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595411042; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FIlmuw8h6RvLmTYPAbmyM2PE74rvOFowbpiW1Nnyk5s=; b=F+lkgjw7nC0yrQx3xNIJMLqiFlCQ3Lcn7VhIKhPOif7RHDodxYsK+Z/dEJy+R0acdSt7H8 EcKuBCxrH0ES2OZMZHg6A2L1J1gR0Q4DfVD8e9A1brI5mShL+ikaRf2vzJVkEYMCRf3AK2 qx1rmYLb8TycMIMGtmmV/UoRdQjfMnc= X-MC-Unique: gl23h0EuP-G-PudxAY8I5g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v1 06/34] qemu_domain_namespace: Check for namespace enablement earlier Date: Wed, 22 Jul 2020 11:40:00 +0200 Message-Id: <52411a3bb51f646f8ba7026921ff4a38c4496176.1595410402.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Functions that create a device node after domain startup (used from hotplug) will get a list of paths they want to create and eventually call qemuDomainNamespaceMknodPaths() which then checks whether domain mount namespace is enabled in the first place. Alternatively, on device hotunplug, we might want to delete a path inside domain namespace in which case qemuDomainNamespaceUnlinkPaths() checks whether the namespace is enabled. While this is not dangerous, it certainly burns a couple of CPU cycles needlessly. Check whether mount namespace is enabled upfront. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain_namespace.c | 39 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain_namespace.c b/src/qemu/qemu_domain_namesp= ace.c index 6d8faa79fb..41451bec9f 100644 --- a/src/qemu/qemu_domain_namespace.c +++ b/src/qemu/qemu_domain_namespace.c @@ -1481,8 +1481,7 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, int ret =3D -1; size_t i; =20 - if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) || - !npaths) + if (!npaths) return 0; =20 cfg =3D virQEMUDriverGetConfig(driver); @@ -1529,8 +1528,7 @@ qemuDomainNamespaceUnlinkPaths(virDomainObjPtr vm, size_t i; int ret =3D -1; =20 - if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) || - !npaths) + if (!npaths) return 0; =20 cfg =3D virQEMUDriverGetConfig(driver); @@ -1572,6 +1570,9 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, size_t npaths =3D 0; bool hasNVMe =3D false; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + for (next =3D src; virStorageSourceIsBacking(next); next =3D next->bac= kingStore) { g_autofree char *tmpPath =3D NULL; =20 @@ -1655,6 +1656,9 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm, { g_autofree char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) return -1; =20 @@ -1687,6 +1691,9 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm, { g_autofree char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) return -1; =20 @@ -1706,6 +1713,9 @@ int qemuDomainNamespaceSetupMemory(virDomainObjPtr vm, virDomainMemoryDefPtr mem) { + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (mem->model !=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) return 0; =20 @@ -1720,6 +1730,9 @@ int qemuDomainNamespaceTeardownMemory(virDomainObjPtr vm, virDomainMemoryDefPtr mem) { + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (mem->model !=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) return 0; =20 @@ -1736,6 +1749,9 @@ qemuDomainNamespaceSetupChardev(virDomainObjPtr vm, { const char *path; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (!(path =3D virDomainChrSourceDefGetPath(chr->source))) return 0; =20 @@ -1757,6 +1773,9 @@ qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm, { const char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (chr->source->type !=3D VIR_DOMAIN_CHR_TYPE_DEV) return 0; =20 @@ -1775,6 +1794,9 @@ qemuDomainNamespaceSetupRNG(virDomainObjPtr vm, { const char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + switch ((virDomainRNGBackend) rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: path =3D rng->source.file; @@ -1799,6 +1821,9 @@ qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm, { const char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + switch ((virDomainRNGBackend) rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: path =3D rng->source.file; @@ -1823,6 +1848,9 @@ qemuDomainNamespaceSetupInput(virDomainObjPtr vm, { const char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (!(path =3D virDomainInputDefGetPath(input))) return 0; =20 @@ -1838,6 +1866,9 @@ qemuDomainNamespaceTeardownInput(virDomainObjPtr vm, { const char *path =3D NULL; =20 + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + return 0; + if (!(path =3D virDomainInputDefGetPath(input))) return 0; =20 --=20 2.26.2