[PATCH 2/6] qemuDomainBuildNamespace: Try harder to remove temp directories

Pavel Mores pmores at redhat.com
Thu Mar 19 17:52:23 UTC 2020


On Wed, Mar 18, 2020 at 06:32:12PM +0100, Michal Privoznik wrote:
> 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 at redhat.com>
> ---
>  src/qemu/qemu_domain.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 48bf5ae559..2724607311 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]);
>      }
> -- 
> 2.24.1
> 

Reviewed-by: Pavel Mores <pmores at redhat.com>




More information about the libvir-list mailing list