From nobody Tue May 7 22:01:29 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 1536321963839202.25530009320187; Fri, 7 Sep 2018 05:06:03 -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 D08F030E5F8F; Fri, 7 Sep 2018 12:06:01 +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 40E82200782A; Fri, 7 Sep 2018 12:06:01 +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 267E818005DF; Fri, 7 Sep 2018 12:06:00 +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 w87C5w1Q016128 for ; Fri, 7 Sep 2018 08:05:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C0622166BDB; Fri, 7 Sep 2018 12:05:58 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3865B2166BA3 for ; Fri, 7 Sep 2018 12:05:56 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 7 Sep 2018 14:05:54 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu_domain: Drop namespace check from top level functions 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.45]); Fri, 07 Sep 2018 12:06:02 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In some cases we are checking if the mount namespace is enabled at two places: one is at the beginning of exported function (e.g. qemuDomainNamespaceSetupDisk()) and the other is at the beginning of qemuDomainNamespaceMknodPaths() which is called from the former function anyway. Then we have some other functions which rely on the later check solely. In order to compensate for possibly needles function call, qemuDomainNamespaceMknodPaths() returns early if @npaths is zero. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5329899b13..15325aa4c1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12428,7 +12428,8 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, int ret =3D -1; size_t i; =20 - if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) + if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) || + !npaths) return 0; =20 cfg =3D virQEMUDriverGetConfig(driver); @@ -12521,9 +12522,6 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, char *dmPath =3D NULL; int ret =3D -1; =20 - 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)) { @@ -12574,9 +12572,6 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm, char **paths =3D NULL; size_t i, npaths =3D 0; =20 - if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) - return 0; - if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &paths, NU= LL) < 0) goto cleanup; =20 @@ -12600,9 +12595,6 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr = vm, char **paths =3D NULL; size_t i, npaths =3D 0; =20 - if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) - return 0; - if (qemuDomainGetHostdevPath(vm->def, hostdev, true, &npaths, &paths, NULL) < 0) goto cleanup; --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list