You need to sign in or sign up before continuing.
提交 2814f66f 编写于 作者: J Ján Tomko

qemu: Properly label and create evdev on input device hotplug

Utilize all the newly introduced function to create the evdev node
and label it on hotplug and destroy it on hotunplug.

This was forgotten in commits bc9ffafc and 67486bb2.

https://bugzilla.redhat.com/show_bug.cgi?id=1509866
上级 c4c7a18c
...@@ -2743,7 +2743,11 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver, ...@@ -2743,7 +2743,11 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT, virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT,
{ .input = input } }; { .input = input } };
virErrorPtr originalError = NULL;
bool releaseaddr = false; bool releaseaddr = false;
bool teardowndevice = false;
bool teardownlabel = false;
bool teardowncgroup = false;
if (input->bus != VIR_DOMAIN_INPUT_BUS_USB && if (input->bus != VIR_DOMAIN_INPUT_BUS_USB &&
input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) { input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) {
...@@ -2770,6 +2774,18 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver, ...@@ -2770,6 +2774,18 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
if (qemuBuildInputDevStr(&devstr, vm->def, input, priv->qemuCaps) < 0) if (qemuBuildInputDevStr(&devstr, vm->def, input, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
if (qemuDomainNamespaceSetupInput(vm, input) < 0)
goto cleanup;
teardowndevice = true;
if (qemuSetupInputCgroup(vm, input) < 0)
goto cleanup;
teardowncgroup = true;
if (qemuSecuritySetInputLabel(vm, input) < 0)
goto cleanup;
teardownlabel = true;
if (VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1) < 0) if (VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1) < 0)
goto cleanup; goto cleanup;
...@@ -2785,14 +2801,23 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver, ...@@ -2785,14 +2801,23 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
VIR_APPEND_ELEMENT_COPY_INPLACE(vm->def->inputs, vm->def->ninputs, input); VIR_APPEND_ELEMENT_COPY_INPLACE(vm->def->inputs, vm->def->ninputs, input);
ret = 0; ret = 0;
releaseaddr = false;
audit: audit:
virDomainAuditInput(vm, input, "attach", ret == 0); virDomainAuditInput(vm, input, "attach", ret == 0);
cleanup: cleanup:
if (releaseaddr) if (ret < 0) {
qemuDomainReleaseDeviceAddress(vm, &input->info, NULL); virErrorPreserveLast(&originalError);
if (teardownlabel)
qemuSecurityRestoreInputLabel(vm, input);
if (teardowncgroup)
qemuTeardownInputCgroup(vm, input);
if (teardowndevice)
qemuDomainNamespaceTeardownInput(vm, input);
if (releaseaddr)
qemuDomainReleaseDeviceAddress(vm, &input->info, NULL);
virErrorRestore(&originalError);
}
VIR_FREE(devstr); VIR_FREE(devstr);
return ret; return ret;
...@@ -4280,6 +4305,15 @@ qemuDomainRemoveInputDevice(virDomainObjPtr vm, ...@@ -4280,6 +4305,15 @@ qemuDomainRemoveInputDevice(virDomainObjPtr vm,
break; break;
} }
qemuDomainReleaseDeviceAddress(vm, &dev->info, NULL); qemuDomainReleaseDeviceAddress(vm, &dev->info, NULL);
if (qemuSecurityRestoreInputLabel(vm, dev) < 0)
VIR_WARN("Unable to restore security label on input device");
if (qemuTeardownInputCgroup(vm, dev) < 0)
VIR_WARN("Unable to remove input device cgroup ACL");
if (qemuDomainNamespaceTeardownInput(vm, dev) < 0)
VIR_WARN("Unable to remove input device from /dev");
virDomainInputDefFree(vm->def->inputs[i]); virDomainInputDefFree(vm->def->inputs[i]);
VIR_DELETE_ELEMENT(vm->def->inputs, i, vm->def->ninputs); VIR_DELETE_ELEMENT(vm->def->inputs, i, vm->def->ninputs);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册