]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainBuildNamespace: Clean up temp files
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 12 Jun 2017 15:46:30 +0000 (17:46 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 16 Jun 2017 12:29:12 +0000 (14:29 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1431112

After 290a00e41d we know how to deal with file mount points.
However, when cleaning up the temporary location for preserved
mount points we are still calling rmdir(). This won't fly for
files. We need to call unlink(). Now, since we don't really care
if the cleanup succeeded or not (it's the best effort anyway), we
can call both rmdir() and unlink() without need for
differentiation between files and directories.

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

index 6838d2eaa468a147b406bb8603d03db426e10ec5..570da2cf546785eb8e7107909a8fd0f41f69587a 100644 (file)
@@ -8363,8 +8363,13 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
 
     ret = 0;
  cleanup:
-    for (i = 0; i < ndevMountsPath; i++)
-        rmdir(devMountsSavePath[i]);
+    for (i = 0; i < ndevMountsPath; i++) {
+        /* The path can be either a regular file or a dir. */
+        if (virFileIsDir(devMountsSavePath[i]))
+            rmdir(devMountsSavePath[i]);
+        else
+            unlink(devMountsSavePath[i]);
+    }
     virStringListFreeCount(devMountsPath, ndevMountsPath);
     virStringListFreeCount(devMountsSavePath, ndevMountsPath);
     return ret;