From: Michal Privoznik Date: Fri, 4 Oct 2019 19:01:29 +0000 (+0200) Subject: qemuDomainBuildNamespace: Try harder to remove temp directories X-Git-Tag: v6.2.0-rc1~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca2edd678d762381de2453bb4a310205a06fc50a;p=thirdparty%2Flibvirt.git qemuDomainBuildNamespace: Try harder to remove temp directories 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 Reviewed-by: Pavel Mores --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1c8d86a904..af31028830 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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]); }