https://bugzilla.redhat.com/show_bug.cgi?id=1591151 Add function virDomainInputDefValidate to validate input devices. Make sure evdev attribute of source element is not used by mouse, keyboard, and tablet input device. Signed-off-by: Han Han <hhan@xxxxxxxxxx> --- src/conf/domain_conf.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 178c6d2711..a65b53b70c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5723,6 +5723,24 @@ virDomainVsockDefValidate(const virDomainVsockDef *vsock) return 0; } +static int +virDomainInputDefValidate(const virDomainInputDef *input) +{ + switch (input->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + if (input->source.evdev) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("setting source evdev path only supported for " + "passthrough input devices")); + return -1; + } + } + + return 0; +} + static int virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, @@ -5762,9 +5780,11 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_VSOCK: return virDomainVsockDefValidate(dev->data.vsock); + case VIR_DOMAIN_DEVICE_INPUT: + return virDomainInputDefValidate(dev->data.input); + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: -- 2.18.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list