diff mbox series

[13/18] qemu: Support vsock model=virtio-{non-}transitional

Message ID 62f988a4d63b87c3c26407f998a74ddb7c40cf1a.1547746868.git.crobinso@redhat.com
State New
Headers show
Series qemu: virtio-{non-}transitional support | expand

Commit Message

Cole Robinson Jan. 17, 2019, 5:52 p.m. UTC
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                          |  4 +++-
 src/conf/domain_conf.h                          |  2 ++
 src/qemu/qemu_capabilities.c                    |  6 ++++++
 src/qemu/qemu_capabilities.h                    |  4 ++++
 src/qemu/qemu_command.c                         | 17 +++++++++++------
 src/qemu/qemu_domain_address.c                  | 13 ++++++++++++-
 .../qemucapabilitiesdata/caps_4.0.0.x86_64.xml  |  2 ++
 .../virtio-non-transitional.x86_64-3.1.0.args   |  3 +++
 .../virtio-non-transitional.x86_64-latest.args  |  3 +++
 .../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 +++
 .../virtio-non-transitional.xml                 |  9 +++++++++
 .../qemuxml2xmloutdata/virtio-transitional.xml  |  4 ++++
 tests/qemuxml2xmltest.c                         |  6 ++++--
 18 files changed, 80 insertions(+), 12 deletions(-)

-- 
2.20.1

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

Comments

Andrea Bolognani Jan. 21, 2019, 3:48 p.m. UTC | #1
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
[...]
> @@ -893,7 +893,9 @@ 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")


Same comment as always for VIR_ENUM_IMPL().

[...]
> @@ -1136,6 +1140,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {

>      {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL},

>      {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL},

>      {"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},

>  };


Same comment as always for capabilities.

[...]
> @@ -495,6 +495,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf,

>              tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL;

>              ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL;

>              break;

> +        case VIR_DOMAIN_DEVICE_VSOCK:

> +            has_tmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL;

> +            has_ntmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL;

> +            tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL;

> +            ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL;

> +            break;

>  

>          case VIR_DOMAIN_DEVICE_LEASE:

>          case VIR_DOMAIN_DEVICE_INPUT:


Sorry I didn't point this out until now, but having an empty line
after each 'break;' would be nice from the visual point of view...

[...]
> @@ -10471,11 +10476,11 @@ qemuBuildVsockDevStr(virDomainDefPtr def,

>      virBuffer buf = VIR_BUFFER_INITIALIZER;

>      char *ret = NULL;

>  

> -    if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {

> -        virBufferAddLit(&buf, "vhost-vsock-ccw");

> -    } else {

> -        virBufferAddLit(&buf, "vhost-vsock-pci");

> -    }

> +    if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps,

> +                                    vsock->info.type,

> +                                    vsock->model, NULL,

> +                                    VIR_DOMAIN_DEVICE_VSOCK) < 0)

> +        goto cleanup;


Similar comment as vhost-scsi in 7/18: you should make sure this is
actually safe, and either way move to qemuBuildVirtioDevStr() first
and only then to qemuBuildVirtioTransitional().

[...]
> +++ b/tests/qemuxml2xmltest.c

> @@ -1269,12 +1269,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);


This could have gone into patch 2/18.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Cole Robinson Jan. 22, 2019, 5:31 p.m. UTC | #2
On 01/21/2019 10:48 AM, Andrea Bolognani wrote:
> On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:

> [...]

>> @@ -893,7 +893,9 @@ 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")

> 

> Same comment as always for VIR_ENUM_IMPL().

> 

> [...]

>> @@ -1136,6 +1140,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {

>>      {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL},

>>      {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL},

>>      {"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},

>>  };

> 

> Same comment as always for capabilities.

> 

> [...]

>> @@ -495,6 +495,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf,

>>              tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL;

>>              ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL;

>>              break;

>> +        case VIR_DOMAIN_DEVICE_VSOCK:

>> +            has_tmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL;

>> +            has_ntmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL;

>> +            tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL;

>> +            ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL;

>> +            break;

>>  

>>          case VIR_DOMAIN_DEVICE_LEASE:

>>          case VIR_DOMAIN_DEVICE_INPUT:

> 

> Sorry I didn't point this out until now, but having an empty line

> after each 'break;' would be nice from the visual point of view...

> 


Will do

> [...]

>> @@ -10471,11 +10476,11 @@ qemuBuildVsockDevStr(virDomainDefPtr def,

>>      virBuffer buf = VIR_BUFFER_INITIALIZER;

>>      char *ret = NULL;

>>  

>> -    if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {

>> -        virBufferAddLit(&buf, "vhost-vsock-ccw");

>> -    } else {

>> -        virBufferAddLit(&buf, "vhost-vsock-pci");

>> -    }

>> +    if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps,

>> +                                    vsock->info.type,

>> +                                    vsock->model, NULL,

>> +                                    VIR_DOMAIN_DEVICE_VSOCK) < 0)

>> +        goto cleanup;

> 

> Similar comment as vhost-scsi in 7/18: you should make sure this is

> actually safe, and either way move to qemuBuildVirtioDevStr() first

> and only then to qemuBuildVirtioTransitional().

> 


I'll split this out too.

> [...]

>> +++ b/tests/qemuxml2xmltest.c

>> @@ -1269,12 +1269,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);

> 

> This could have gone into patch 2/18.

> 


Seems a little strange since it only became relevant with this patch,
but I'll change it

- Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Andrea Bolognani Jan. 23, 2019, 11:08 a.m. UTC | #3
On Tue, 2019-01-22 at 12:31 -0500, Cole Robinson wrote:
> On 01/21/2019 10:48 AM, Andrea Bolognani wrote:

> > On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:

> > [...]

> > > +++ b/tests/qemuxml2xmltest.c

> > > @@ -1269,12 +1269,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);

> > 

> > This could have gone into patch 2/18.

> 

> Seems a little strange since it only became relevant with this patch,

> but I'll change it


Fair enough. Feel free to leave this, and others, as is.

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Patch

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e8e255f361..5c342cfcfb 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 a35f802960..54541b1148 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4300,7 +4300,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 b3baacf345..79b2ab35c0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -893,7 +893,9 @@  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 ce3255113e..5b9325a6d5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2418,6 +2418,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_capabilities.c b/src/qemu/qemu_capabilities.c
index 59e96887df..954ba5a171 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -536,6 +536,10 @@  VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "virtio-9p-pci-non-transitional",
               "virtio-balloon-pci-transitional",
               "virtio-balloon-pci-non-transitional",
+              "vhost-vsock-pci-transitional",
+
+              /* 340 */
+              "vhost-vsock-pci-non-transitional",
     );
 
 
@@ -1136,6 +1140,8 @@  struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL},
     {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL},
     {"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},
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index cd2a5d186c..99e3b3c5ca 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -520,6 +520,10 @@  typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL, /* -device virtio-9p-pci-non-transitional */
     QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL, /* -device virtio-balloon-pci-transitional */
     QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL, /* -device virtio-balloon-pci-transitional */
+    QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL, /* -device vhost-vsock-pci-transitional */
+
+    /* 340 */
+    QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL, /* -device vhost-vsock-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 dd4c2507c5..67e54d42b8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -495,6 +495,12 @@  qemuBuildVirtioTransitional(virBufferPtr buf,
             tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL;
             ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL;
             break;
+        case VIR_DOMAIN_DEVICE_VSOCK:
+            has_tmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL;
+            has_ntmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL;
+            tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL;
+            ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL;
+            break;
 
         case VIR_DOMAIN_DEVICE_LEASE:
         case VIR_DOMAIN_DEVICE_INPUT:
@@ -514,7 +520,6 @@  qemuBuildVirtioTransitional(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;
@@ -10471,11 +10476,11 @@  qemuBuildVsockDevStr(virDomainDefPtr def,
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *ret = NULL;
 
-    if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-        virBufferAddLit(&buf, "vhost-vsock-ccw");
-    } else {
-        virBufferAddLit(&buf, "vhost-vsock-pci");
-    }
+    if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps,
+                                    vsock->info.type,
+                                    vsock->model, NULL,
+                                    VIR_DOMAIN_DEVICE_VSOCK) < 0)
+        goto cleanup;
 
     virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
     virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 8c5c5f0477..1b476bbc15 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -945,7 +945,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/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
index 3461d32151..b5861b1982 100644
--- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
@@ -224,6 +224,8 @@ 
   <flag name='virtio-9p-pci-non-transitional'/>
   <flag name='virtio-balloon-pci-transitional'/>
   <flag name='virtio-balloon-pci-non-transitional'/>
+  <flag name='vhost-vsock-pci-transitional'/>
+  <flag name='vhost-vsock-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 71a044cd56..100348bf1a 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,scsi=off,bus=pci.3,addr=0x0,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
@@ -48,4 +49,6 @@  id=hostdev0,bus=pci.4,addr=0x0 \
 addr=0x0 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
+-device vhost-vsock-pci,disable-legacy=on,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 e307c0491f..5795f2fdc5 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 b656f69191..d9a0288387 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 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 0eca113e23..1a6eddf3b7 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1269,12 +1269,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);