mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
qemu: Refactor virtio-input capabilities checks
The checks and error messages are mostly the same across all virtio-input devices, so we can avoid having multiple copies of the same code. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
eeafebc51d
commit
3d23a434d2
@ -5957,43 +5957,33 @@ qemuDomainDeviceDefValidateInput(const virDomainInputDef *input,
|
|||||||
const virDomainDef *def ATTRIBUTE_UNUSED,
|
const virDomainDef *def ATTRIBUTE_UNUSED,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
|
const char *baseName;
|
||||||
|
int cap;
|
||||||
|
int ccwCap;
|
||||||
|
|
||||||
if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO)
|
if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch ((virDomainInputType)input->type) {
|
switch ((virDomainInputType)input->type) {
|
||||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_MOUSE) ||
|
baseName = "virtio-mouse";
|
||||||
(input->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
|
cap = QEMU_CAPS_VIRTIO_MOUSE;
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW))) {
|
ccwCap = QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("virtio-mouse is not supported by this QEMU binary"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TABLET) ||
|
baseName = "virtio-tablet";
|
||||||
(input->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
|
cap = QEMU_CAPS_VIRTIO_TABLET;
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW))) {
|
ccwCap = QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("virtio-tablet is not supported by this QEMU binary"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_KEYBOARD) ||
|
baseName = "virtio-keyboard";
|
||||||
(input->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
|
cap = QEMU_CAPS_VIRTIO_KEYBOARD;
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW))) {
|
ccwCap = QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("virtio-keyboard is not supported by this QEMU binary"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
|
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_INPUT_HOST)) {
|
baseName = "virtio-input-host";
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
cap = QEMU_CAPS_VIRTIO_INPUT_HOST;
|
||||||
_("virtio-input-host is not supported by this QEMU binary"));
|
ccwCap = QEMU_CAPS_LAST;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_INPUT_TYPE_LAST:
|
case VIR_DOMAIN_INPUT_TYPE_LAST:
|
||||||
default:
|
default:
|
||||||
@ -6002,6 +5992,15 @@ qemuDomainDeviceDefValidateInput(const virDomainInputDef *input,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, cap) ||
|
||||||
|
(input->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
|
||||||
|
!virQEMUCapsGet(qemuCaps, ccwCap))) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("%s is not supported by this QEMU binary"),
|
||||||
|
baseName);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user