mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Improve validation for virtio input devices
While the parser and schema have to accept all possible models, virtio-(non-)transitional models are only applicable to type=passthrough and should be otherwise rejected. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
7a05c739c2
commit
ff3f22e0ec
@ -420,6 +420,7 @@ virDomainInputBusTypeToString;
|
|||||||
virDomainInputDefFind;
|
virDomainInputDefFind;
|
||||||
virDomainInputDefFree;
|
virDomainInputDefFree;
|
||||||
virDomainInputDefGetPath;
|
virDomainInputDefGetPath;
|
||||||
|
virDomainInputTypeToString;
|
||||||
virDomainIOMMUModelTypeFromString;
|
virDomainIOMMUModelTypeFromString;
|
||||||
virDomainIOMMUModelTypeToString;
|
virDomainIOMMUModelTypeToString;
|
||||||
virDomainIOThreadIDAdd;
|
virDomainIOThreadIDAdd;
|
||||||
|
@ -5971,6 +5971,38 @@ qemuDomainDeviceDefValidateInput(const virDomainInputDef *input,
|
|||||||
if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO)
|
if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Only type=passthrough supports model=virtio-(non-)transitional */
|
||||||
|
switch ((virDomainInputModel)input->model) {
|
||||||
|
case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL:
|
||||||
|
case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL:
|
||||||
|
switch ((virDomainInputType)input->type) {
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("virtio (non-)transitional models are not "
|
||||||
|
"supported for input type=%s"),
|
||||||
|
virDomainInputTypeToString(input->type));
|
||||||
|
return -1;
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_LAST:
|
||||||
|
default:
|
||||||
|
virReportEnumRangeError(virDomainInputType,
|
||||||
|
input->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_MODEL_VIRTIO:
|
||||||
|
case VIR_DOMAIN_INPUT_MODEL_DEFAULT:
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_MODEL_LAST:
|
||||||
|
default:
|
||||||
|
virReportEnumRangeError(virDomainInputModel,
|
||||||
|
input->model);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
switch ((virDomainInputType)input->type) {
|
switch ((virDomainInputType)input->type) {
|
||||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||||
baseName = "virtio-mouse";
|
baseName = "virtio-mouse";
|
||||||
|
11
tests/qemuxml2argvdata/virtio-transitional-not-supported.xml
Normal file
11
tests/qemuxml2argvdata/virtio-transitional-not-supported.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219136</memory>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='q35'>hvm</type>
|
||||||
|
</os>
|
||||||
|
<devices>
|
||||||
|
<input type='keyboard' bus='virtio' model='virtio-non-transitional'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -3001,6 +3001,10 @@ mymain(void)
|
|||||||
DO_TEST_CAPS_VER("virtio-non-transitional", "3.1.0");
|
DO_TEST_CAPS_VER("virtio-non-transitional", "3.1.0");
|
||||||
DO_TEST_CAPS_LATEST("virtio-transitional");
|
DO_TEST_CAPS_LATEST("virtio-transitional");
|
||||||
DO_TEST_CAPS_LATEST("virtio-non-transitional");
|
DO_TEST_CAPS_LATEST("virtio-non-transitional");
|
||||||
|
DO_TEST_PARSE_ERROR("virtio-transitional-not-supported",
|
||||||
|
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
|
||||||
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
||||||
|
QEMU_CAPS_DEVICE_IOH3420);
|
||||||
|
|
||||||
/* Simple headless guests for various architectures */
|
/* Simple headless guests for various architectures */
|
||||||
DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64");
|
DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64");
|
||||||
|
Loading…
Reference in New Issue
Block a user