]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_domain: Drop namespace check from top level functions
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 7 Sep 2018 05:14:59 +0000 (07:14 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 12 Sep 2018 08:59:09 +0000 (10:59 +0200)
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 needless function call,
qemuDomainNamespaceMknodPaths() returns early if @npaths is zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c

index 5329899b137300938f6e6f2f8bbf182d03aabcb5..15325aa4c1f67e7c471c8596cc09f776358689ef 100644 (file)
@@ -12428,7 +12428,8 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm,
     int ret = -1;
     size_t i;
 
-    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
+    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) ||
+        !npaths)
         return 0;
 
     cfg = virQEMUDriverGetConfig(driver);
@@ -12521,9 +12522,6 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
     char *dmPath = NULL;
     int ret = -1;
 
-    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
-        return 0;
-
     for (next = src; virStorageSourceIsBacking(next); next = next->backingStore) {
         if (virStorageSourceIsEmpty(next) ||
             !virStorageSourceIsLocalStorage(next)) {
@@ -12574,9 +12572,6 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
     char **paths = NULL;
     size_t i, npaths = 0;
 
-    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
-        return 0;
-
     if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &paths, NULL) < 0)
         goto cleanup;
 
@@ -12600,9 +12595,6 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
     char **paths = NULL;
     size_t i, npaths = 0;
 
-    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
-        return 0;
-
     if (qemuDomainGetHostdevPath(vm->def, hostdev, true,
                                  &npaths, &paths, NULL) < 0)
         goto cleanup;