]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add <input model='virtio-{non-}transitional'/>
authorCole Robinson <crobinso@redhat.com>
Thu, 17 Jan 2019 17:52:41 +0000 (12:52 -0500)
committerCole Robinson <crobinso@redhat.com>
Mon, 4 Mar 2019 16:08:41 +0000 (11:08 -0500)
<input> devices lack the model= attribute which is used by
most other device types. To eventually support
virtio-input-host-pci-{non-}traditional in qemu, let's add
a standard model= attribute. This just adds the domain_conf
wiring

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
13 files changed:
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args
tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
tests/qemuxml2argvdata/virtio-non-transitional.xml
tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
tests/qemuxml2argvdata/virtio-transitional.xml
tests/qemuxml2xmloutdata/virtio-non-transitional.xml
tests/qemuxml2xmloutdata/virtio-transitional.xml
tests/qemuxml2xmltest.c

index 18f9557d1832748ec9144eda67f5602003fdb6ed..f45251de0bae559acfbfd23c64d9b25aa9624710 100644 (file)
@@ -6488,6 +6488,12 @@ qemu-kvm -net nic,model=? /dev/null
       For type <code>passthrough</code>, the mandatory sub-element <code>source</code>
       must have an <code>evdev</code> attribute containing the absolute path to the
       event device passed through to guests. (KVM only)
+
+      <span class="since">Since 5.2.0</span>, the <code>input</code> element
+      accepts a <code>model</code> attribute which has the values 'virtio',
+      'virtio-transitional' and 'virtio-non-transitional'. See
+      <a href="#elementsVirtioTransitional">Virtio transitional devices</a>
+      for more details.
     </p>
 
     <p>
index f1c253fefb8d43b9def3ad5e0d53e2889ad11686..a7f396b522c6c603b89f20f43c90f58d1a79d657 100644 (file)
             </element>
           </group>
         </choice>
+        <optional>
+          <attribute name="model">
+            <choice>
+              <value>virtio</value>
+              <value>virtio-transitional</value>
+              <value>virtio-non-transitional</value>
+            </choice>
+          </attribute>
+        </optional>
         <optional>
           <ref name="alias"/>
         </optional>
index 4c6a63f63afe9feacdad273746d514abe7feb1c0..19f80efe026668ad8c11d3604d4f6efed081f1e7 100644 (file)
@@ -669,6 +669,13 @@ VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST,
               "virtio",
 );
 
+VIR_ENUM_IMPL(virDomainInputModel, VIR_DOMAIN_INPUT_MODEL_LAST,
+              "default",
+              "virtio",
+              "virtio-transitional",
+              "virtio-non-transitional",
+);
+
 VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST,
               "sdl",
               "vnc",
@@ -12943,6 +12950,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_AUTOFREE(char *) evdev = NULL;
     VIR_AUTOFREE(char *) type = NULL;
     VIR_AUTOFREE(char *) bus = NULL;
+    VIR_AUTOFREE(char *) model = NULL;
 
     if (VIR_ALLOC(def) < 0)
         return NULL;
@@ -12951,6 +12959,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt,
 
     type = virXMLPropString(node, "type");
     bus = virXMLPropString(node, "bus");
+    model = virXMLPropString(node, "model");
 
     if (!type) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -12964,6 +12973,14 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt,
         goto error;
     }
 
+    if (model &&
+        ((def->model = virDomainInputModelTypeFromString(model)) < 0 ||
+         def->model == VIR_DOMAIN_INPUT_MODEL_DEFAULT)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("unknown input model '%s'"), model);
+        goto error;
+    }
+
     if (bus) {
         if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -21726,6 +21743,14 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src,
         return false;
     }
 
+    if (src->model != dst->model) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target input model %s does not match source %s"),
+                       virDomainInputBusTypeToString(dst->model),
+                       virDomainInputBusTypeToString(src->model));
+        return false;
+    }
+
     if (src->virtio && dst->virtio &&
         !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
         return false;
@@ -26319,6 +26344,18 @@ virDomainInputDefFormat(virBufferPtr buf,
     virBufferAsprintf(buf, "<input type='%s' bus='%s'",
                       type, bus);
 
+    if (def->model) {
+        const char *model = virDomainInputModelTypeToString(def->model);
+
+        if (!model) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected input model %d"), def->model);
+            goto cleanup;
+        }
+
+        virBufferAsprintf(buf, " model='%s'", model);
+    }
+
     virBufferSetChildIndent(&childbuf, buf);
     virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
     if (virBufferCheckError(&driverBuf) < 0)
index c43101a8ff5df69a616913b2686e1052f97a5bb8..f24769ae820fa90c7484165d1324b566b2a66470 100644 (file)
@@ -1376,9 +1376,19 @@ typedef enum {
     VIR_DOMAIN_INPUT_BUS_LAST
 } virDomainInputBus;
 
+typedef enum {
+    VIR_DOMAIN_INPUT_MODEL_DEFAULT = 0,
+    VIR_DOMAIN_INPUT_MODEL_VIRTIO,
+    VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL,
+    VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL,
+
+    VIR_DOMAIN_INPUT_MODEL_LAST
+} virDomainInputModel;
+
 struct _virDomainInputDef {
     int type;
     int bus;
+    int model; /* virDomainInputModel */
     struct {
         char *evdev;
     } source;
@@ -3518,6 +3528,7 @@ VIR_ENUM_DECL(virDomainHub);
 VIR_ENUM_DECL(virDomainRedirdevBus);
 VIR_ENUM_DECL(virDomainInput);
 VIR_ENUM_DECL(virDomainInputBus);
+VIR_ENUM_DECL(virDomainInputModel);
 VIR_ENUM_DECL(virDomainGraphics);
 VIR_ENUM_DECL(virDomainGraphicsListen);
 VIR_ENUM_DECL(virDomainGraphicsAuthConnected);
index 97df54dd77c28b1341cadfbec79cd79a147b8f53..9130572abea178ed1ec91c17ed9b7160174ac7a8 100644 (file)
@@ -32,6 +32,7 @@ addr=0x1 \
 -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
 -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \
 -device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \
+-device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,addr=0x2 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\
 addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
@@ -41,6 +42,8 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \
 -netdev user,id=hostnet0 \
 -device virtio-net-pci,disable-legacy=on,disable-modern=off,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 vhost-scsi-pci,disable-legacy=on,disable-modern=off,\
 wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.4,addr=0x0 \
 -device virtio-balloon-pci,disable-legacy=on,disable-modern=off,id=balloon0,\
@@ -51,5 +54,5 @@ id=rng0,bus=pci.6,addr=0x0 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\
-guest-cid=4,vhostfd=6789,bus=pci.7,addr=0x0 \
+guest-cid=4,vhostfd=6789,bus=pci.8,addr=0x0 \
 -msg timestamp=on
index 2a73798ee2e713bb6417a1e52d74028a0fe5c2ac..8e0709816b28c7525024096a87795ecd371ac2f8 100644 (file)
@@ -32,6 +32,7 @@ addr=0x1 \
 -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
 -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \
 -device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \
+-device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,addr=0x2 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
@@ -41,6 +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 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 \
@@ -49,5 +52,5 @@ id=hostdev0,bus=pci.4,addr=0x0 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\
-bus=pci.7,addr=0x0 \
+bus=pci.8,addr=0x0 \
 -msg timestamp=on
index 0f691cea3bcc8bc79332f48918fadb971aab6e23..3f4d6df95744df6c1454c84d8c7054fcd4afa1ff 100644 (file)
@@ -25,6 +25,9 @@
       <source dir='/export/fs1'/>
       <target dir='fs1'/>
     </filesystem>
+    <input type='passthrough' bus='virtio' model='virtio-non-transitional'>
+      <source evdev='/dev/input/event1234'/>
+    </input>
     <controller type='usb' model='none'/>
     <memballoon model='virtio-non-transitional'/>
     <vsock model='virtio-non-transitional'>
index c3df97ca86767fee4ce89bdecda35aa594fb259e..0286b98ece7a4eae3bcaf1437ab0076a51380695 100644 (file)
@@ -27,6 +27,7 @@ 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,disable-legacy=off,disable-modern=off,scsi=off,\
 bus=pci.2,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
@@ -36,6 +37,8 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \
 -netdev user,id=hostnet0 \
 -device virtio-net-pci,disable-legacy=off,disable-modern=off,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 vhost-scsi-pci,disable-legacy=off,disable-modern=off,\
 wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x4 \
 -device virtio-balloon-pci,disable-legacy=off,disable-modern=off,id=balloon0,\
index f3a4e0804e5141b95953b169259838cd3f6f34db..24b49e600907af0350319fa583446d64ec4e2811 100644 (file)
@@ -27,6 +27,7 @@ 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 \
@@ -36,6 +37,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 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 \
index d10c917a356ba4e96fb263ff708b6bea19a92045..d3f78eba09a52f075324532e3e62de8be135edd7 100644 (file)
@@ -25,6 +25,9 @@
       <source dir='/export/fs1'/>
       <target dir='fs1'/>
     </filesystem>
+    <input type='passthrough' bus='virtio' model='virtio-transitional'>
+      <source evdev='/dev/input/event1234'/>
+    </input>
     <controller type='usb' model='none'/>
     <memballoon model='virtio-transitional'/>
     <vsock model='virtio-transitional'>
index 9f05de5089816a944d2a2ed52c8b1b388f346b48..b6e762c0a7b0df5c13f81c8eb1b803aec1767443 100644 (file)
       <target chassis='8' port='0xf'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
     </controller>
+    <controller type='pci' index='9' model='pcie-root-port'>
+      <model name='pcie-root-port'/>
+      <target chassis='9' port='0x10'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
     <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'>
       <source dir='/export/fs1'/>
       <target dir='fs1'/>
       <model type='virtio-non-transitional'/>
       <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
     </interface>
+    <input type='passthrough' bus='virtio' model='virtio-non-transitional'>
+      <source evdev='/dev/input/event1234'/>
+      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
+    </input>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'>
@@ -90,7 +99,7 @@
     </rng>
     <vsock model='virtio-non-transitional'>
       <cid auto='no' address='4'/>
-      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
     </vsock>
   </devices>
 </domain>
index 0d99aa2ded193ad555ecc4d7d955218262a27b39..490b28368ae6ec6b832614e8d5f4c7cb1ed5cbab 100644 (file)
       <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'/>
       <model type='virtio-transitional'/>
       <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
     </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'/>
+    </input>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'>
index 5f78d82478da7e5fe98a841a06bc74f2dca01799..ac8e88448d380aecb2c6d23d17a519387cd8bd8a 100644 (file)
@@ -1260,14 +1260,16 @@ mymain(void)
             QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
             QEMU_CAPS_DEVICE_VIRTIO_RNG,
             QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
-            QEMU_CAPS_DEVICE_VHOST_VSOCK);
+            QEMU_CAPS_DEVICE_VHOST_VSOCK,
+            QEMU_CAPS_VIRTIO_INPUT_HOST);
     DO_TEST("virtio-non-transitional",
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
             QEMU_CAPS_DEVICE_VIRTIO_RNG,
             QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
-            QEMU_CAPS_DEVICE_VHOST_VSOCK);
+            QEMU_CAPS_DEVICE_VHOST_VSOCK,
+            QEMU_CAPS_VIRTIO_INPUT_HOST);
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);