[PATCH] qemu_namespace: Don't build namespace if domain doesn't have it enabled

Michal Privoznik posted 1 patch 3 years, 7 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/5ca5300c3610b71cd476043575751dcb971c91a8.1598020470.git.mprivozn@redhat.com
src/qemu/qemu_namespace.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] qemu_namespace: Don't build namespace if domain doesn't have it enabled
Posted by Michal Privoznik 3 years, 7 months ago
Even if namespaces are disabled, then due to a missing check at the
beginning of qemuDomainBuildNamespace(), the domain startup code
still tries to populate (nonexistent) domain's namespace.

Fixes: 8da362fe62766b4eee209cd3ce591ceb62299d13
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_namespace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
index 797722b714..b6724a095f 100644
--- a/src/qemu/qemu_namespace.c
+++ b/src/qemu/qemu_namespace.c
@@ -616,6 +616,11 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
 {
     VIR_AUTOSTRINGLIST paths = NULL;
 
+    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) {
+        VIR_DEBUG("namespaces disabled for domain %s", vm->def->name);
+        return 0;
+    }
+
     if (qemuDomainPopulateDevices(cfg, &paths) < 0)
         return -1;
 
-- 
2.26.2

Re: [PATCH] qemu_namespace: Don't build namespace if domain doesn't have it enabled
Posted by Jiri Denemark 3 years, 7 months ago
On Fri, Aug 21, 2020 at 16:34:30 +0200, Michal Privoznik wrote:
> Even if namespaces are disabled, then due to a missing check at the
> beginning of qemuDomainBuildNamespace(), the domain startup code
> still tries to populate (nonexistent) domain's namespace.
> 
> Fixes: 8da362fe62766b4eee209cd3ce591ceb62299d13
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_namespace.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
> index 797722b714..b6724a095f 100644
> --- a/src/qemu/qemu_namespace.c
> +++ b/src/qemu/qemu_namespace.c
> @@ -616,6 +616,11 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
>  {
>      VIR_AUTOSTRINGLIST paths = NULL;
>  
> +    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) {
> +        VIR_DEBUG("namespaces disabled for domain %s", vm->def->name);
> +        return 0;
> +    }
> +
>      if (qemuDomainPopulateDevices(cfg, &paths) < 0)
>          return -1;

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>