[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 20/25] qemu: Support vsock model=virtio-{non-}transitional



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"

Signed-off-by: Cole Robinson <crobinso redhat com>
---
 docs/formatdomain.html.in                           |  4 +++-
 docs/schemas/domaincommon.rng                       |  6 +++++-
 src/conf/domain_conf.c                              |  5 ++++-
 src/conf/domain_conf.h                              |  2 ++
 src/qemu/qemu_command.c                             |  9 +++++++--
 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           |  1 +
 .../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, 65 insertions(+), 8 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 05f2beb237..eed35ef545 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8606,7 +8606,9 @@ 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'
     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 ac7c558511..1e26d5efca 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4301,7 +4301,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 b51c2a86ee..55ee8da179 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -897,7 +897,10 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST,
 
 VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST,
               "default",
-              "virtio")
+              "virtio",
+              "virtio-transitional",
+              "virtio-non-transitional",
+);
 
 VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST,
               "default",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f79b3e5f48..f0d41e3153 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 614c9db291..9d64c7d7b0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -509,6 +509,13 @@ qemuBuildVirtioDevStr(virBufferPtr buf,
             ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_PCI_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;
+            tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_PCI_TRANSITIONAL;
+            ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_PCI_NON_TRANSITIONAL;
+            break;
+
         case VIR_DOMAIN_DEVICE_LEASE:
         case VIR_DOMAIN_DEVICE_INPUT:
         case VIR_DOMAIN_DEVICE_SOUND:
@@ -527,7 +534,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;
@@ -10494,7 +10500,6 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *ret = NULL;
 
-
     if (qemuBuildVirtioDevStr(&buf, "vhost-vsock", qemuCaps,
                               VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) {
         goto cleanup;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 5164bcd49b..4767b7aadc 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -947,7 +947,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 b94ea58b5e..d4c07420dc 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml
@@ -28,5 +28,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 c35e73ec45..d2429d2d2c 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
@@ -42,4 +42,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 \
 -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 3bdb602a06..dd33071eb9 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-transitional.xml
@@ -28,5 +28,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 7490dfdbbf..5ba39ea30f 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-9p-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 2a42ce6359..5cb6568cc8 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 a84f9241d6..c5ad3ba4b6 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1272,12 +1272,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);
-- 
2.20.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]