[PATCH 3/4] qemuDomainCreateNamespace: move mkdir to qemuDomainBuildNamespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Again, there is no need to create /var/lib/libvirt/$domain.*
directories in CreateNamespace(). It is sufficient to create them
as soon as we need them which is in BuildNamespace. This way we
don't leave them around for the whole lifetime of domain.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 54481214c..137d68e47 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7369,6 +7369,13 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
         if (devMountsSavePath[i] == devPath)
             continue;
 
+        if (virFileMakePath(devMountsSavePath[i]) < 0) {
+            virReportSystemError(errno,
+                                 _("Failed to create %s"),
+                                 devMountsSavePath[i]);
+            goto cleanup;
+        }
+
         if (mount(devMountsPath[i], devMountsSavePath[i],
                   NULL, mount_flags, NULL) < 0) {
             virReportSystemError(errno,
@@ -7426,6 +7433,8 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
     ret = 0;
  cleanup:
     virObjectUnref(cfg);
+    for (i = 0; i < ndevMountsPath; i++)
+        rmdir(devMountsSavePath[i]);
     virStringListFreeCount(devMountsPath, ndevMountsPath);
     virStringListFreeCount(devMountsSavePath, ndevMountsPath);
     return ret;
@@ -7438,8 +7447,6 @@ qemuDomainCreateNamespace(virQEMUDriverPtr driver,
 {
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     int ret = -1;
-    char **devMountsSavePath = NULL;
-    size_t ndevMountsSavePath = 0, i;
 
     if (!virBitmapIsBitSet(cfg->namespaces, QEMU_DOMAIN_NS_MOUNT) ||
         !virQEMUDriverIsPrivileged(driver)) {
@@ -7447,30 +7454,11 @@ qemuDomainCreateNamespace(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    if (qemuDomainGetPreservedMounts(driver, vm,
-                                     NULL, &devMountsSavePath,
-                                     &ndevMountsSavePath) < 0)
-        goto cleanup;
-
-    for (i = 0; i < ndevMountsSavePath; i++) {
-        if (virFileMakePath(devMountsSavePath[i]) < 0) {
-            virReportSystemError(errno,
-                                 _("Failed to create %s"),
-                                 devMountsSavePath[i]);
-            goto cleanup;
-        }
-    }
-
     if (qemuDomainEnableNamespace(vm, QEMU_DOMAIN_NS_MOUNT) < 0)
         goto cleanup;
 
     ret = 0;
  cleanup:
-    if (ret < 0) {
-        for (i = 0; i < ndevMountsSavePath; i++)
-            rmdir(devMountsSavePath[i]);
-    }
-    virStringListFreeCount(devMountsSavePath, ndevMountsSavePath);
     virObjectUnref(cfg);
     return ret;
 }
-- 
2.11.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux