[v3,12/17] qemu: Support vsock model=virtio-{non-}transitional

Message ID 799dce4e13814bbb7ad7474891c8d23217b134b2.1549663397.git.crobinso@redhat.com
State Accepted
Commit 6e64899284a006812d2677641de5e3ddfd44f109
Headers show
Series
  • qemu: virtio-{non-}transitional support
Related show

Commit Message

Cole Robinson Feb. 8, 2019, 10:12 p.m.
Add <vsock> model handling for virtio transitional devices. Ex:

  <vsock model='virtio-transitional'>
    ...
  </vsock>

* "virtio-transitional" maps to qemu "vhost-vsock-pci-transitional"
* "virtio-non-transitional" maps to qemu "vhost-vsock-pci-non-transitional"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 docs/formatdomain.html.in                           |  6 +++++-
 docs/schemas/domaincommon.rng                       |  6 +++++-
 src/conf/domain_conf.c                              |  2 ++
 src/conf/domain_conf.h                              |  2 ++
 src/qemu/qemu_command.c                             |  6 +++++-
 src/qemu/qemu_domain_address.c                      | 13 ++++++++++++-
 .../virtio-non-transitional.x86_64-3.1.0.args       |  3 +++
 .../virtio-non-transitional.x86_64-latest.args      |  3 +++
 tests/qemuxml2argvdata/virtio-non-transitional.xml  |  3 +++
 .../virtio-transitional.x86_64-3.1.0.args           |  2 ++
 .../virtio-transitional.x86_64-latest.args          |  2 ++
 tests/qemuxml2argvdata/virtio-transitional.xml      |  3 +++
 .../qemuxml2xmloutdata/virtio-non-transitional.xml  |  9 +++++++++
 tests/qemuxml2xmloutdata/virtio-transitional.xml    |  4 ++++
 tests/qemuxml2xmltest.c                             |  6 ++++--
 15 files changed, 64 insertions(+), 6 deletions(-)

-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Andrea Bolognani Feb. 12, 2019, 4:30 p.m. | #1
On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote:
[...]
> @@ -977,7 +977,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,

>          break;

>  

>      case VIR_DOMAIN_DEVICE_VSOCK:

> -        return virtioFlags;

> +        switch ((virDomainVsockModel) dev->data.vsock->model) {

> +        case VIR_DOMAIN_VSOCK_MODEL_VIRTIO:

> +        case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL:

> +            return virtioFlags;

> +        case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL:

> +            return pciFlags;


Same nit as in 8/17.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>


-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Patch

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 4a1ba83cd8..15aed5381f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8652,7 +8652,11 @@  qemu-kvm -net nic,model=? /dev/null
     <h3><a id="vsock">Vsock</a></h3>
 
     <p>A vsock host/guest interface. The <code>model</code> attribute
-    defaults to <code>virtio</code>.
+    defaults to <code>virtio</code>. <span class="since">Since 5.1.0</span>
+    <code>model</code> can also be 'virtio-transitional' and
+    'virtio-non-transitional', see
+    <a href="#elementsVirtioTransitional">Virtio transitional devices</a>
+    for more details.
     The optional attribute <code>address</code> of the <code>cid</code>
     element specifies the CID assigned to the guest. If the attribute
     <code>auto</code> is set to <code>yes</code>, libvirt
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 94c358b578..e1e5a64592 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4304,7 +4304,11 @@ 
     <element name="vsock">
       <optional>
         <attribute name="model">
-          <value>virtio</value>
+          <choice>
+            <value>virtio</value>
+            <value>virtio-transitional</value>
+            <value>virtio-non-transitional</value>
+          </choice>
         </attribute>
       </optional>
       <interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e4484f9982..22f07307ad 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -990,6 +990,8 @@  VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST,
 VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST,
               "default",
               "virtio",
+              "virtio-transitional",
+              "virtio-non-transitional",
 );
 
 VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 40da1b40b7..a236d4fc9c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2420,6 +2420,8 @@  struct _virDomainIOMMUDef {
 typedef enum {
     VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
     VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
+    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
+    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
 
     VIR_DOMAIN_VSOCK_MODEL_LAST
 } virDomainVsockModel;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b843408402..022d5a5d90 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -507,6 +507,11 @@  qemuBuildVirtioDevStr(virBufferPtr buf,
             has_ntmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL;
             break;
 
+        case VIR_DOMAIN_DEVICE_VSOCK:
+            has_tmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL;
+            has_ntmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL;
+            break;
+
         case VIR_DOMAIN_DEVICE_LEASE:
         case VIR_DOMAIN_DEVICE_INPUT:
         case VIR_DOMAIN_DEVICE_SOUND:
@@ -525,7 +530,6 @@  qemuBuildVirtioDevStr(virBufferPtr buf,
         case VIR_DOMAIN_DEVICE_PANIC:
         case VIR_DOMAIN_DEVICE_MEMORY:
         case VIR_DOMAIN_DEVICE_IOMMU:
-        case VIR_DOMAIN_DEVICE_VSOCK:
         case VIR_DOMAIN_DEVICE_LAST:
         default:
             return 0;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index c1a6d94a4c..badf237333 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -977,7 +977,18 @@  qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         break;
 
     case VIR_DOMAIN_DEVICE_VSOCK:
-        return virtioFlags;
+        switch ((virDomainVsockModel) dev->data.vsock->model) {
+        case VIR_DOMAIN_VSOCK_MODEL_VIRTIO:
+        case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL:
+            return virtioFlags;
+        case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL:
+            return pciFlags;
+
+        case VIR_DOMAIN_VSOCK_MODEL_DEFAULT:
+        case VIR_DOMAIN_VSOCK_MODEL_LAST:
+            return 0;
+        }
+        break;
 
         /* These devices don't ever connect with PCI */
     case VIR_DOMAIN_DEVICE_NVRAM:
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 30e8e4244e..97df54dd77 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
@@ -31,6 +31,7 @@  addr=0x1 \
 -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
 -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 \
 -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 \
@@ -49,4 +50,6 @@  bus=pci.5,addr=0x0 \
 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 \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
index dbf7a4ef15..2a73798ee2 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
@@ -31,6 +31,7 @@  addr=0x1 \
 -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
 -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 \
 -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 \
@@ -47,4 +48,6 @@  id=hostdev0,bus=pci.4,addr=0x0 \
 -device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,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 \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml
index 6d9691c1e5..97d9c77a73 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml
@@ -27,5 +27,8 @@ 
     </filesystem>
     <controller type='usb' index='0' model='none'/>
     <memballoon model='virtio-non-transitional'/>
+    <vsock model='virtio-non-transitional'>
+      <cid auto='no' address='4'/>
+    </vsock>
   </devices>
 </domain>
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 b7cb304891..c3df97ca86 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
@@ -45,4 +45,6 @@  bus=pci.2,addr=0x5 \
 id=rng0,bus=pci.2,addr=0x6 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
+-device vhost-vsock-pci,disable-legacy=off,disable-modern=off,id=vsock0,\
+guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
index 77332549bf..f3a4e0804e 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
@@ -43,4 +43,6 @@  id=hostdev0,bus=pci.2,addr=0x4 \
 -device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \
 -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 \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml
index 43c55e9d31..a2ca96ed09 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-transitional.xml
@@ -27,5 +27,8 @@ 
     </filesystem>
     <controller type='usb' index='0' model='none'/>
     <memballoon model='virtio-transitional'/>
+    <vsock model='virtio-transitional'>
+      <cid auto='no' address='4'/>
+    </vsock>
   </devices>
 </domain>
diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
index 721dccbaef..9f05de5089 100644
--- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
@@ -60,6 +60,11 @@ 
       <target chassis='7' port='0xe'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
     </controller>
+    <controller type='pci' index='8' model='pcie-root-port'>
+      <model name='pcie-root-port'/>
+      <target chassis='8' port='0xf'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
+    </controller>
     <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'>
       <source dir='/export/fs1'/>
       <target dir='fs1'/>
@@ -83,5 +88,9 @@ 
       <backend model='random'>/dev/urandom</backend>
       <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
     </rng>
+    <vsock model='virtio-non-transitional'>
+      <cid auto='no' address='4'/>
+      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
+    </vsock>
   </devices>
 </domain>
diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml
index 2402c5f227..0d99aa2ded 100644
--- a/tests/qemuxml2xmloutdata/virtio-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml
@@ -62,5 +62,9 @@ 
       <backend model='random'>/dev/urandom</backend>
       <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/>
     </rng>
+    <vsock model='virtio-transitional'>
+      <cid auto='no' address='4'/>
+      <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/>
+    </vsock>
   </devices>
 </domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 15f0ccffb1..30954cc341 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1258,12 +1258,14 @@  mymain(void)
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
-            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
+            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
+            QEMU_CAPS_DEVICE_VHOST_VSOCK);
     DO_TEST("virtio-non-transitional",
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
-            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
+            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
+            QEMU_CAPS_DEVICE_VHOST_VSOCK);
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);