qemu: Introduce functions for input device cgroup manipulation

Export qemuSetupInputCgroup and introduce qemuTeardownInputCgroup
for hotunplug.
This commit is contained in:
Ján Tomko 2017-11-21 13:33:07 +01:00
parent d8116b5a0a
commit f29612fd35
2 changed files with 28 additions and 1 deletions

View File

@ -246,7 +246,7 @@ qemuSetupTPMCgroup(virDomainObjPtr vm)
}
static int
int
qemuSetupInputCgroup(virDomainObjPtr vm,
virDomainInputDefPtr dev)
{
@ -269,6 +269,29 @@ qemuSetupInputCgroup(virDomainObjPtr vm,
}
int
qemuTeardownInputCgroup(virDomainObjPtr vm,
virDomainInputDefPtr dev)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = 0;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
return 0;
switch (dev->type) {
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
VIR_DEBUG("Process path '%s' for input device", dev->source.evdev);
ret = virCgroupDenyDevicePath(priv->cgroup, dev->source.evdev,
VIR_CGROUP_DEVICE_RWM, false);
virDomainAuditCgroupPath(vm, priv->cgroup, "deny", dev->source.evdev, "rwm", ret == 0);
break;
}
return ret;
}
int
qemuSetupHostdevCgroup(virDomainObjPtr vm,
virDomainHostdevDefPtr dev)

View File

@ -37,6 +37,10 @@ int qemuSetupDiskCgroup(virDomainObjPtr vm,
virDomainDiskDefPtr disk);
int qemuTeardownDiskCgroup(virDomainObjPtr vm,
virDomainDiskDefPtr disk);
int qemuSetupInputCgroup(virDomainObjPtr vm,
virDomainInputDefPtr dev);
int qemuTeardownInputCgroup(virDomainObjPtr vm,
virDomainInputDefPtr dev);
int qemuSetupHostdevCgroup(virDomainObjPtr vm,
virDomainHostdevDefPtr dev)
ATTRIBUTE_RETURN_CHECK;