qemuDomainBuildNamespace: Populate graphics from daemon's namespace

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>
This commit is contained in:
Michal Privoznik 2020-07-21 14:30:44 +02:00
parent 87ae5262a0
commit 5f4f7c2094

View File

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