]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainBuildNamespace: Populate graphics from daemon's namespace
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Jul 2020 12:30:44 +0000 (14:30 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 3 Aug 2020 17:40:37 +0000 (19:40 +0200)
As mentioned in one of previous commits, populating domain's
namespace from pre-exec() hook is dangerous. This commit moves
population of the namespace with domain graphics (render node)
into daemon's namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_namespace.c

index f31aae281cd146132cfd0d1fbfdb5256292a9bdf..cb6156c3c125474615b50345251344cfa225fdf3 100644 (file)
@@ -701,27 +701,27 @@ qemuDomainSetupAllTPMs(virDomainObjPtr vm,
 
 static int
 qemuDomainSetupGraphics(virDomainGraphicsDefPtr gfx,
-                        const struct qemuDomainCreateDeviceData *data)
+                        char ***paths)
 {
     const char *rendernode = virDomainGraphicsGetRenderNode(gfx);
 
     if (!rendernode)
         return 0;
 
-    return qemuDomainCreateDevice(rendernode, data, false);
+    return virStringListAdd(paths, rendernode);
 }
 
 
 static int
 qemuDomainSetupAllGraphics(virDomainObjPtr vm,
-                           const struct qemuDomainCreateDeviceData *data)
+                           char ***paths)
 {
     size_t i;
 
     VIR_DEBUG("Setting up graphics");
     for (i = 0; i < vm->def->ngraphics; i++) {
         if (qemuDomainSetupGraphics(vm->def->graphics[i],
-                                    data) < 0)
+                                    paths) < 0)
             return -1;
     }
 
@@ -882,6 +882,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
     if (qemuDomainSetupAllTPMs(vm, &paths) < 0)
         return -1;
 
+    if (qemuDomainSetupAllGraphics(vm, &paths) < 0)
+        return -1;
+
     if (qemuNamespaceMknodPaths(vm, (const char **) paths) < 0)
         return -1;
 
@@ -933,9 +936,6 @@ qemuDomainUnshareNamespace(virQEMUDriverConfigPtr cfg,
     if (qemuDomainSetupDev(mgr, vm, devPath) < 0)
         goto cleanup;
 
-    if (qemuDomainSetupAllGraphics(vm, &data) < 0)
-        goto cleanup;
-
     if (qemuDomainSetupAllInputs(vm, &data) < 0)
         goto cleanup;