Add <input> model handling for virtio transitional devices. Ex:
<input type='passthrough' bus='virtio'
model='virtio-transitional'>
...
</input>
* "virtio-transitional" maps to qemu
"virtio-input-host-pci-transitional"
* "virtio-non-transitional" maps to qemu
"virtio-input-host-non-transitional"
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 4 ++++
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_command.c | 12 ++++++++++--
src/qemu/qemu_domain_address.c | 9 +++++++++
tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 ++
.../virtio-non-transitional.x86_64-3.1.0.args | 4 ++--
.../virtio-non-transitional.x86_64-latest.args | 4 ++--
.../virtio-transitional.x86_64-3.1.0.args | 7 +++----
.../virtio-transitional.x86_64-latest.args | 7 +++----
tests/qemuxml2xmloutdata/virtio-transitional.xml | 9 ++-------
10 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 954ba5a171..f5b9bc6937 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -540,6 +540,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
/* 340 */
"vhost-vsock-pci-non-transitional",
+ "virtio-input-host-pci-transitional",
+ "virtio-input-host-pci-non-transitional",
);
@@ -1142,6 +1144,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{"virtio-balloon-pci-non-transitional",
QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL},
{"vhost-vsock-pci-transitional",
QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL},
{"vhost-vsock-pci-non-transitional",
QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL},
+ {"virtio-input-host-pci-transitional",
QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL},
+ {"virtio-input-host-pci-non-transitional",
QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL},
};
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 99e3b3c5ca..91aae8df5b 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -524,6 +524,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check
*/
/* 340 */
QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL, /* -device
vhost-vsock-pci-non-transitional */
+ QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL, /* -device
virtio-input-host-pci-transitional */
+ QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL, /* -device
virtio-input-host-pci-non-transitional */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 67e54d42b8..4d14ac9e5d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -501,9 +501,14 @@ qemuBuildVirtioTransitional(virBufferPtr buf,
tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL;
ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL;
break;
+ case VIR_DOMAIN_DEVICE_INPUT:
+ has_tmodel = model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL;
+ has_ntmodel = model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL;
+ tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL;
+ ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL;
+ break;
case VIR_DOMAIN_DEVICE_LEASE:
- case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
case VIR_DOMAIN_DEVICE_VIDEO:
case VIR_DOMAIN_DEVICE_WATCHDOG:
@@ -4286,7 +4291,10 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
goto error;
break;
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
- if (qemuBuildVirtioDevStr(&buf, "virtio-input-host",
dev->info.type) < 0)
+ if (qemuBuildVirtioTransitional(&buf, "virtio-input-host",
qemuCaps,
+ dev->info.type,
+ dev->model, NULL,
+ VIR_DOMAIN_DEVICE_INPUT) < 0)
goto error;
break;
case VIR_DOMAIN_INPUT_TYPE_LAST:
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 1b476bbc15..70591dce25 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DEVICE_INPUT:
switch ((virDomainInputBus) dev->data.input->bus) {
case VIR_DOMAIN_INPUT_BUS_VIRTIO:
+ switch ((virDomainInputModel) dev->data.input->model) {
+ case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL:
+ return pciFlags;
+ case VIR_DOMAIN_INPUT_MODEL_VIRTIO:
+ case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL:
+ case VIR_DOMAIN_INPUT_MODEL_DEFAULT:
+ case VIR_DOMAIN_INPUT_MODEL_LAST:
+ break;
+ }
return virtioFlags;
case VIR_DOMAIN_INPUT_BUS_PS2:
diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
index b5861b1982..d5bbbc40f7 100644
--- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
@@ -226,6 +226,8 @@
<flag name='virtio-balloon-pci-non-transitional'/>
<flag name='vhost-vsock-pci-transitional'/>
<flag name='vhost-vsock-pci-non-transitional'/>
+ <flag name='virtio-input-host-pci-transitional'/>
+ <flag name='virtio-input-host-pci-non-transitional'/>
<version>3001050</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>446361</microcodeVersion>
diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args
b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args
index 5952008b28..fc183757b0 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args
@@ -42,8 +42,8 @@ bus=pci.1,addr=0x0 \
-netdev user,id=hostnet0 \
-device virtio-net-pci,disable-legacy=on,netdev=hostnet0,id=net0,\
mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \
--device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.7,\
-addr=0x0 \
+-device virtio-input-host-pci,disable-legacy=on,id=input0,\
+evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \
-device vhost-scsi-pci,disable-legacy=on,wwpn=naa.5123456789abcde0,vhostfd=3,\
id=hostdev0,bus=pci.4,addr=0x0 \
-device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.5,addr=0x0 \
diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
index 8e0709816b..383b29f629 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
@@ -42,8 +42,8 @@ bus=pci.1,addr=0x0 \
-netdev user,id=hostnet0 \
-device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\
mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \
--device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.7,\
-addr=0x0 \
+-device virtio-input-host-pci-non-transitional,id=input0,\
+evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \
-device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\
id=hostdev0,bus=pci.4,addr=0x0 \
-device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.5,addr=0x0 \
diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
index 06fe70bb11..8046e5c102 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
@@ -27,7 +27,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
addr=0x1 \
-device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \
-device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \
--device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x3,drive=drive-virtio-disk0,\
id=virtio-disk0,bootindex=1 \
@@ -36,8 +35,8 @@ id=virtio-disk0,bootindex=1 \
-netdev user,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.2,\
addr=0x2 \
--device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.3,\
-addr=0x0 \
+-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.2,\
+addr=0x7 \
-device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\
bus=pci.2,addr=0x4 \
-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x5 \
@@ -45,5 +44,5 @@ bus=pci.2,addr=0x4 \
-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
--device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \
+-device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x8 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
index 24b49e6009..410eb28f0a 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
@@ -27,7 +27,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
addr=0x1 \
-device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \
-device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \
--device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x3,\
drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
@@ -37,8 +36,8 @@ bus=pci.2,addr=0x1 \
-netdev user,id=hostnet0 \
-device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\
mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \
--device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.3,\
-addr=0x0 \
+-device virtio-input-host-pci-transitional,id=input0,\
+evdev=/dev/input/event1234,bus=pci.2,addr=0x7 \
-device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\
id=hostdev0,bus=pci.2,addr=0x4 \
-device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x5 \
@@ -47,5 +46,5 @@ id=hostdev0,bus=pci.2,addr=0x4 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
-device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\
-bus=pci.2,addr=0x7 \
+bus=pci.2,addr=0x8 \
-msg timestamp=on
diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml
b/tests/qemuxml2xmloutdata/virtio-transitional.xml
index 490b28368a..9fa9732c2d 100644
--- a/tests/qemuxml2xmloutdata/virtio-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml
@@ -39,11 +39,6 @@
<target chassis='3' port='0x9'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
</controller>
- <controller type='pci' index='4'
model='pcie-root-port'>
- <model name='pcie-root-port'/>
- <target chassis='4' port='0xa'/>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
- </controller>
<filesystem type='mount' accessmode='passthrough'
model='virtio-transitional'>
<source dir='/export/fs1'/>
<target dir='fs1'/>
@@ -56,7 +51,7 @@
</interface>
<input type='passthrough' bus='virtio'
model='virtio-transitional'>
<source evdev='/dev/input/event1234'/>
- <address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x02'
slot='0x07' function='0x0'/>
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
@@ -73,7 +68,7 @@
</rng>
<vsock model='virtio-transitional'>
<cid auto='no' address='4'/>
- <address type='pci' domain='0x0000' bus='0x02'
slot='0x07' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x02'
slot='0x08' function='0x0'/>
</vsock>
</devices>
</domain>
--
2.20.1