[05/18] qemu: Support interface model=virtio-{non-}transitional

Message ID c4af9174c860d6eaea9e587e38d1be720a869fa3.1547746867.git.crobinso@redhat.com
State New
Headers show
Series
  • qemu: virtio-{non-}transitional support
Related show

Commit Message

Cole Robinson Jan. 17, 2019, 5:52 p.m.
Add new <interface> model handling for virtio transitional devices. Ex:

<interface>
  <model type='virtio-transitional'/>
</interface>

* "virtio-transitional" maps to qemu "virtio-net-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional"

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

(cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)
---
 src/conf/domain_conf.c                          |  4 +++-
 src/qemu/qemu_capabilities.c                    |  6 ++++++
 src/qemu/qemu_capabilities.h                    |  4 ++++
 src/qemu/qemu_command.c                         | 17 +++++++++++++----
 src/qemu/qemu_domain_address.c                  |  8 ++++++--
 .../qemucapabilitiesdata/caps_4.0.0.x86_64.xml  |  2 ++
 .../virtio-non-transitional.x86_64-3.1.0.args   |  6 +++++-
 .../virtio-non-transitional.x86_64-latest.args  |  6 +++++-
 .../virtio-non-transitional.xml                 |  4 ++++
 .../virtio-transitional.x86_64-3.1.0.args       |  5 ++++-
 .../virtio-transitional.x86_64-latest.args      |  5 ++++-
 tests/qemuxml2argvdata/virtio-transitional.xml  |  4 ++++
 .../virtio-non-transitional.xml                 | 12 +++++++++++-
 .../qemuxml2xmloutdata/virtio-transitional.xml  |  7 ++++++-
 14 files changed, 77 insertions(+), 13 deletions(-)

-- 
2.20.1

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

Comments

Andrea Bolognani Jan. 18, 2019, 2:20 p.m. | #1
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
> Add new <interface> model handling for virtio transitional devices. Ex:

> 

> <interface>

>   <model type='virtio-transitional'/>

> </interface>

> 

> * "virtio-transitional" maps to qemu "virtio-net-pci-transitional"

> * "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional"

> 

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

> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)


Guess this slipped in somehow :)

[...]
> @@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {

>      { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },

>      {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL},

>      {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},

> +    {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL},

> +    {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},


Same comments about spacing, naming the capabilities and introducing
them in their separate commit as for virtio-blk apply.

[...]
> @@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf,

>                              virQEMUCapsPtr qemuCaps,

>                              virDomainDeviceAddressType type,

>                              int model,

> +                            const char *modelstr,


Ewww.

We really, really need to make the handling of model names for
network interface more sane.

In the meantime, can you add some sort of (ideally compile-time)
sanity check to ensure that the function is either called with
model == -1 && modelStr != NULL or model >= 0 && modelStr == NULL?
Or at the very least some documentation on how you're supposed to
be calling it.

[...]
> @@ -3741,8 +3747,11 @@ qemuBuildNicDevStr(virDomainDefPtr def,

>      bool usingVirtio = false;

>      char macaddr[VIR_MAC_STRING_BUFLEN];

>  

> -    if (STREQ(net->model, "virtio")) {

> -        if (qemuBuildVirtioDevStr(&buf, "virtio-net", net->info.type) < 0)

> +    if (virDomainNetHasVirtioModel(net)) {

> +        if (qemuBuildVirtioTransitional(&buf, "virtio-net", qemuCaps,

> +                                        net->info.type,

> +                                        0, net->model,

> +                                        VIR_DOMAIN_DEVICE_NET) < 0)


The change from STREQ() to virDomainNetHasVirtioModel() should be
squashed into the previous patch.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Cole Robinson Jan. 18, 2019, 5:24 p.m. | #2
On 01/18/2019 09:20 AM, Andrea Bolognani wrote:
> On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:

>> Add new <interface> model handling for virtio transitional devices. Ex:

>>

>> <interface>

>>    <model type='virtio-transitional'/>

>> </interface>

>>

>> * "virtio-transitional" maps to qemu "virtio-net-pci-transitional"

>> * "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional"

>>

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

>> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)

> 

> Guess this slipped in somehow :)

> 

> [...]

>> @@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {

>>       { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },

>>       {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL},

>>       {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},

>> +    {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL},

>> +    {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},

> 

> Same comments about spacing, naming the capabilities and introducing

> them in their separate commit as for virtio-blk apply.

> 

> [...]

>> @@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf,

>>                               virQEMUCapsPtr qemuCaps,

>>                               virDomainDeviceAddressType type,

>>                               int model,

>> +                            const char *modelstr,

> 

> Ewww.

> 

> We really, really need to make the handling of model names for

> network interface more sane.

> 

> In the meantime, can you add some sort of (ideally compile-time)

> sanity check to ensure that the function is either called with

> model == -1 && modelStr != NULL or model >= 0 && modelStr == NULL?

> Or at the very least some documentation on how you're supposed to

> be calling it.

> 


I'll respond to the rest of the review in time but I just wanted to 
mention here: I'm working on a series to try and untangle the net model 
mess and it undoes this hack. It converts nearly all usage of net->model 
internally to use an enum, but preserves the string passthrough in 
xen+qemu to be dealt with separately since that will take some 
discussion and probably need to be phased out after a grace period. I 
plan to finish + post the series today unless I hit unexpected hurdles.

Thanks for the reviews!

- Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Cole Robinson Jan. 21, 2019, 11:18 p.m. | #3
On 01/18/2019 09:20 AM, Andrea Bolognani wrote:
> On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:

>> Add new <interface> model handling for virtio transitional devices. Ex:

>>

>> <interface>

>>   <model type='virtio-transitional'/>

>> </interface>

>>

>> * "virtio-transitional" maps to qemu "virtio-net-pci-transitional"

>> * "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional"

>>

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

>> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)

> 

> Guess this slipped in somehow :)

> 

> [...]

>> @@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {

>>      { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },

>>      {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL},

>>      {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},

>> +    {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL},

>> +    {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},

> 

> Same comments about spacing, naming the capabilities and introducing

> them in their separate commit as for virtio-blk apply.

> 

> [...]

>> @@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf,

>>                              virQEMUCapsPtr qemuCaps,

>>                              virDomainDeviceAddressType type,

>>                              int model,

>> +                            const char *modelstr,

> 

> Ewww.

> 

> We really, really need to make the handling of model names for

> network interface more sane.

> 

> In the meantime, can you add some sort of (ideally compile-time)

> sanity check to ensure that the function is either called with

> model == -1 && modelStr != NULL or model >= 0 && modelStr == NULL?

> Or at the very least some documentation on how you're supposed to

> be calling it.

> 


Since hopefully this will be removed by my series in the near future,
I'll just add a docstring for the function to clarify its usage

Thanks,
Cole

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

Patch

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4fc33c7e2f..9c68e41765 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29735,7 +29735,9 @@  virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface)
 bool
 virDomainNetHasVirtioModel(const virDomainNetDef *iface)
 {
-    return STREQ_NULLABLE(iface->model, "virtio");
+    return (STREQ_NULLABLE(iface->model, "virtio") ||
+            STREQ_NULLABLE(iface->model, "virtio-transitional") ||
+            STREQ_NULLABLE(iface->model, "virtio-non-transitional"));
 }
 
 
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b7c0387f8e..44c4b890b9 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -522,6 +522,10 @@  VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "nvdimm.unarmed",
               "virtio-blk-pci-transitional",
               "virtio-blk-pci-non-transitional",
+              "virtio-net-pci-transitional",
+
+              /* 330 */
+              "virtio-net-pci-non-transitional",
     );
 
 
@@ -1112,6 +1116,8 @@  struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },
     {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL},
     {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},
+    {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL},
+    {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 34265d7cc0..1a92c00575 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -506,6 +506,10 @@  typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */
     QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL, /* -device virtio-blk-pci-transitional */
     QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL, /* -device virtio-blk-pci-non-transitional */
+    QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL, /* -device virtio-net-pci-transitional */
+
+    /* 330 */
+    QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL, /* -device virtio-net-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 608cd65806..d3b74211b7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -449,6 +449,7 @@  qemuBuildVirtioTransitional(virBufferPtr buf,
                             virQEMUCapsPtr qemuCaps,
                             virDomainDeviceAddressType type,
                             int model,
+                            const char *modelstr,
                             virDomainDeviceType devtype)
 {
     int tmodel_cap, ntmodel_cap;
@@ -464,10 +465,15 @@  qemuBuildVirtioTransitional(virBufferPtr buf,
             tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL;
             ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL;
             break;
+        case VIR_DOMAIN_DEVICE_NET:
+            has_tmodel = STREQ(modelstr, "virtio-transitional");
+            has_ntmodel = STREQ(modelstr, "virtio-non-transitional");
+            tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL;
+            ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL;
+            break;
 
         case VIR_DOMAIN_DEVICE_LEASE:
         case VIR_DOMAIN_DEVICE_FS:
-        case VIR_DOMAIN_DEVICE_NET:
         case VIR_DOMAIN_DEVICE_INPUT:
         case VIR_DOMAIN_DEVICE_SOUND:
         case VIR_DOMAIN_DEVICE_VIDEO:
@@ -2136,7 +2142,7 @@  qemuBuildDiskDeviceStr(const virDomainDef *def,
     case VIR_DOMAIN_DISK_BUS_VIRTIO:
         if (qemuBuildVirtioTransitional(&opt, "virtio-blk", qemuCaps,
                                         disk->info.type,
-                                        disk->model,
+                                        disk->model, NULL,
                                         VIR_DOMAIN_DEVICE_DISK) < 0)
             goto error;
 
@@ -3741,8 +3747,11 @@  qemuBuildNicDevStr(virDomainDefPtr def,
     bool usingVirtio = false;
     char macaddr[VIR_MAC_STRING_BUFLEN];
 
-    if (STREQ(net->model, "virtio")) {
-        if (qemuBuildVirtioDevStr(&buf, "virtio-net", net->info.type) < 0)
+    if (virDomainNetHasVirtioModel(net)) {
+        if (qemuBuildVirtioTransitional(&buf, "virtio-net", qemuCaps,
+                                        net->info.type,
+                                        0, net->model,
+                                        VIR_DOMAIN_DEVICE_NET) < 0)
             goto error;
 
         usingVirtio = true;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 0950197a44..654567c500 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -694,8 +694,12 @@  qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
             return 0;
         }
 
-        if (STREQ(net->model, "virtio"))
-            return  virtioFlags;
+        if (STREQ(net->model, "virtio") ||
+            STREQ(net->model, "virtio-non-transitional"))
+            return virtioFlags;
+
+        if (STREQ(net->model, "virtio-transitional"))
+            return pciFlags;
 
         if (STREQ(net->model, "e1000e"))
             return pcieFlags;
diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
index 8cf9083035..137dcaf156 100644
--- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
@@ -214,6 +214,8 @@ 
   <flag name='nvdimm.unarmed'/>
   <flag name='virtio-blk-pci-transitional'/>
   <flag name='virtio-blk-pci-non-transitional'/>
+  <flag name='virtio-net-pci-transitional'/>
+  <flag name='virtio-net-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 9c5d553077..6eaf3086ef 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
@@ -26,9 +26,13 @@  file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
 addr=0x1 \
 -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
+-device pcie-root-port,port=0xa,chassis=3,id=pci.3,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=on,scsi=off,bus=pci.1,addr=0x0,\
+-device virtio-blk-pci,disable-legacy=on,scsi=off,bus=pci.2,addr=0x0,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-netdev user,id=hostnet0 \
+-device virtio-net-pci,disable-legacy=on,netdev=hostnet0,id=net0,\
+mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -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 37078765bc..9a0eb9a1f3 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
@@ -26,9 +26,13 @@  file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
 addr=0x1 \
 -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
+-device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
--device virtio-blk-pci-non-transitional,scsi=off,bus=pci.1,addr=0x0,\
+-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.2,addr=0x0,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-netdev user,id=hostnet0 \
+-device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\
+mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml
index 7899994622..a1b35d1c07 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml
@@ -12,6 +12,10 @@ 
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='vda' bus='virtio'/>
     </disk>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:55'/>
+      <model type='virtio-non-transitional'/>
+    </interface>
     <controller type='usb' index='0' model='none'/>
     <memballoon model='none'/>
   </devices>
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 356e8fdf4c..9b80cd893a 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
@@ -28,8 +28,11 @@  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 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
--device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x1,drive=drive-virtio-disk0,\
+-device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk0,\
 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=0x1 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
index e78223eac8..46e139d492 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
@@ -28,8 +28,11 @@  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 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
--device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x1,\
+-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x2,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-netdev user,id=hostnet0 \
+-device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\
+mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml
index 678a7b9132..18f665577a 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-transitional.xml
@@ -12,6 +12,10 @@ 
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='vda' bus='virtio'/>
     </disk>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:55'/>
+      <model type='virtio-transitional'/>
+    </interface>
     <controller type='usb' index='0' model='none'/>
     <memballoon model='none'/>
   </devices>
diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
index 7e4aa16b32..f0dc7c0833 100644
--- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
@@ -18,7 +18,7 @@ 
       <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='vda' bus='virtio'/>
-      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
     </disk>
     <controller type='usb' index='0' model='none'/>
     <controller type='sata' index='0'>
@@ -35,6 +35,16 @@ 
       <target chassis='2' port='0x9'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
     </controller>
+    <controller type='pci' index='3' model='pcie-root-port'>
+      <model name='pcie-root-port'/>
+      <target chassis='3' port='0xa'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:55'/>
+      <model type='virtio-non-transitional'/>
+      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+    </interface>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='none'/>
diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml
index c19e133bb3..f9729391a5 100644
--- a/tests/qemuxml2xmloutdata/virtio-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml
@@ -18,7 +18,7 @@ 
       <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='vda' bus='virtio'/>
-      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
     </disk>
     <controller type='usb' index='0' model='none'/>
     <controller type='sata' index='0'>
@@ -39,6 +39,11 @@ 
       <target chassis='3' port='0x9'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
     </controller>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:55'/>
+      <model type='virtio-transitional'/>
+      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+    </interface>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='none'/>