mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Allow @rendernode for virgl domains
When enabling virgl, qemu opens /dev/dri/render*. So far, we are not allowing that in devices CGroup nor creating the file in domain's namespace and thus requiring users to set the paths in qemu.conf. This, however, is suboptimal as it allows access to ALL qemu processes even those which don't have virgl configured. Now that we have a way to specify render node that qemu will use we can be more cautious and enable just that. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
dfa79bd82b
commit
5c74cf1f44
@ -335,6 +335,28 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuSetupGraphicsCgroup(virDomainObjPtr vm,
|
||||||
|
virDomainGraphicsDefPtr gfx)
|
||||||
|
{
|
||||||
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
const char *rendernode = gfx->data.spice.rendernode;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (gfx->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE ||
|
||||||
|
gfx->data.spice.gl != VIR_TRISTATE_BOOL_YES ||
|
||||||
|
!rendernode)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ret = virCgroupAllowDevicePath(priv->cgroup, rendernode,
|
||||||
|
VIR_CGROUP_DEVICE_RW, false);
|
||||||
|
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", rendernode,
|
||||||
|
"rw", ret == 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuSetupBlkioCgroup(virDomainObjPtr vm)
|
qemuSetupBlkioCgroup(virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
@ -604,6 +626,11 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < vm->def->ngraphics; i++) {
|
||||||
|
if (qemuSetupGraphicsCgroup(vm, vm->def->graphics[i]) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < vm->def->ninputs; i++) {
|
for (i = 0; i < vm->def->ninputs; i++) {
|
||||||
if (qemuSetupInputCgroup(vm, vm->def->inputs[i]) < 0)
|
if (qemuSetupInputCgroup(vm, vm->def->inputs[i]) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -7526,6 +7526,42 @@ qemuDomainSetupTPM(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainSetupGraphics(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||||
|
virDomainGraphicsDefPtr gfx,
|
||||||
|
const char *devPath)
|
||||||
|
{
|
||||||
|
const char *rendernode = gfx->data.spice.rendernode;
|
||||||
|
|
||||||
|
if (gfx->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE ||
|
||||||
|
gfx->data.spice.gl != VIR_TRISTATE_BOOL_YES ||
|
||||||
|
!rendernode)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return qemuDomainCreateDevice(rendernode, devPath, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainSetupAllGraphics(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
const char *devPath)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
VIR_DEBUG("Setting up graphics");
|
||||||
|
for (i = 0; i < vm->def->ngraphics; i++) {
|
||||||
|
if (qemuDomainSetupGraphics(driver,
|
||||||
|
vm->def->graphics[i],
|
||||||
|
devPath) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_DEBUG("Setup all graphics");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainSetupInput(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
qemuDomainSetupInput(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||||
virDomainInputDefPtr input,
|
virDomainInputDefPtr input,
|
||||||
@ -7679,6 +7715,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
|
|||||||
if (qemuDomainSetupTPM(driver, vm, devPath) < 0)
|
if (qemuDomainSetupTPM(driver, vm, devPath) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainSetupAllGraphics(driver, vm, devPath) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainSetupAllInputs(driver, vm, devPath) < 0)
|
if (qemuDomainSetupAllInputs(driver, vm, devPath) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user