]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainBuildNamespace: Try harder to remove temp directories
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Oct 2019 19:01:29 +0000 (21:01 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 20 Mar 2020 13:31:13 +0000 (14:31 +0100)
If building namespace fails somewhere in the middle (that is some
files exists under devMountsSavePath[i]), then plain rmdir() is
not enough to remove dir. Umount the temp location and use
virFileDeleteTree() to remove the directory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
src/qemu/qemu_domain.c

index 1c8d86a904706dc4b0cfa7a23c47aab97413f7d4..af31028830a2f32cd8eb4e37d2c74e7321a83640 100644 (file)
@@ -15311,9 +15311,12 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
     ret = 0;
  cleanup:
     for (i = 0; i < ndevMountsPath; i++) {
+#if defined(__linux__)
+        umount(devMountsSavePath[i]);
+#endif /* defined(__linux__) */
         /* The path can be either a regular file or a dir. */
         if (virFileIsDir(devMountsSavePath[i]))
-            rmdir(devMountsSavePath[i]);
+            virFileDeleteTree(devMountsSavePath[i]);
         else
             unlink(devMountsSavePath[i]);
     }