[libvirt] [PATCH 4/4] qemu: add test case for spapr-pci-vfio-host-bridge

Shivaprasad G Bhat shivaprasadbhat at gmail.com
Fri Oct 17 16:57:40 UTC 2014


The test case adds passthrough hostdevices and interface of
type hostdev. The test case tests the address for multifunction,
multibus, and pci bridges within the spapr-vfio domain.

Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
Signed-off-by: Pradipta Kumar Banerjee <bpradip at in.ibm.com>
---
 docs/schemas/domaincommon.rng                      |   28 +++++++
 .../qemuxml2argv-hostdev-spapr-vfio.args           |   16 ++++
 .../qemuxml2argv-hostdev-spapr-vfio.xml            |   76 ++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |    8 ++
 4 files changed, 128 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 20d81ae..d04d044 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1778,6 +1778,34 @@
               </group>
             </choice>
           </group>
+          <!-- spapr-vfio-pci has a default "model" -->
+          <group>
+            <attribute name="type">
+              <value>spapr-vfio-pci</value>
+            </attribute>
+            <attribute name="iommuGroupNum">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <attribute name="domain">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <choice>
+              <group>
+                <attribute name="model">
+                  <choice>
+                    <value>pci-root</value>
+                  </choice>
+                </attribute>
+              </group>
+              <group>
+                <attribute name="model">
+                  <choice>
+                    <value>pci-bridge</value>
+                  </choice>
+                </attribute>
+              </group>
+            </choice>
+          </group>
           <!-- virtio-serial has optional "ports" and "vectors" -->
           <group>
             <attribute name="type">
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.args
new file mode 100644
index 0000000..88db0c1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.args
@@ -0,0 +1,16 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -realtime mlock=off -smp 1 \
+-nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi \
+-boot c -device spapr-vscsi,id=scsi0,reg=0x2000 \
+-device spapr-pci-vfio-host-bridge,iommu=3,id=vfiohostbridge3,index=1 \
+-device spapr-pci-vfio-host-bridge,iommu=156,id=vfiohostbridge156,index=2 \
+-device pci-bridge,chassis_nr=3,id=vfiohostbridge3.1,bus=vfiohostbridge3.0,addr=0x2 \
+-device pci-bridge,chassis_nr=3,id=vfiohostbridge3.2,bus=vfiohostbridge3.0,addr=0x3 \
+-usb -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
+-drive file=/root/boot.iso,if=none,media=cdrom,id=drive-scsi0-0-0-2 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=2,drive=drive-scsi0-0-0-2,id=scsi0-0-0-2 \
+-serial pty -device vfio-pci,host=0003:05:00.1,id=hostdev0,bus=vfiohostbridge156.0,addr=0x1 \
+-device vfio-pci,host=0003:20:01.0,id=hostdev1,bus=vfiohostbridge3.0,multifunction=on,addr=0x1 \
+-device vfio-pci,host=0003:20:01.1,id=hostdev2,bus=vfiohostbridge3.0,addr=0x1.0x1 \
+-device vfio-pci,host=0003:20:01.2,id=hostdev3,bus=vfiohostbridge3.2,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.xml
new file mode 100644
index 0000000..2d379c8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-spapr-vfio.xml
@@ -0,0 +1,76 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>87eedafe-eedc-4336-8130-ed9fe5dc90c8</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc' bus='scsi'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+    </disk>
+    <controller type='scsi' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <address type='spapr-vio' reg='0x30000000'/>
+    </console>
+    <controller type='spapr-vfio-pci' index='0' model='pci-root' iommuGroupNum='3' domain='1'/>
+    <controller type='spapr-vfio-pci' index='0' model='pci-root' iommuGroupNum='156' domain='2'/>
+    <controller type='spapr-vfio-pci' index='1' model='pci-bridge' iommuGroupNum='3' domain='1'>
+      <address type='pci' domain='0x0001' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <controller type='spapr-vfio-pci' index='2' model='pci-bridge' iommuGroupNum='3' domain='1'>
+      <address type='pci' domain='0x0001' bus='0x00' slot='0x03' function='0x0'/>
+    </controller>
+    <hostdev mode='subsystem' type='pci' managed='yes'>
+      <driver name='vfio'/>
+      <source>
+        <address domain='0x0003' bus='0x20' slot='0x01' function='0x0'/>
+      </source>
+      <address type='pci' domain='0x0001' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
+    </hostdev>
+    <hostdev mode='subsystem' type='pci' managed='yes'>
+      <driver name='vfio'/>
+      <source>
+        <address domain='0x0003' bus='0x20' slot='0x01' function='0x1'/>
+      </source>
+      <address type='pci' domain='0x0001' bus='0x00' slot='0x01' function='0x1'/>
+    </hostdev>
+    <hostdev mode='subsystem' type='pci' managed='yes'>
+      <driver name='vfio'/>
+      <source>
+        <address domain='0x0003' bus='0x20' slot='0x01' function='0x2'/>
+      </source>
+      <address type='pci' domain='0x0001' bus='0x02' slot='0x01' function='0x0'/>
+    </hostdev>
+    <interface type='hostdev' managed='yes'>
+      <driver name='vfio'/>
+      <mac address='52:54:00:6d:90:02'/>
+      <source>
+        <address type='pci' domain='0x0003' bus='0x05' slot='0x00' function='0x1'/>
+      </source>
+      <address type='pci' domain='0x0002' bus='0x00' slot='0x01' function='0x0'/>
+    </interface>
+    <memballoon model='none'/>
+  </devices>
+</domain>
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c13aa99..8c2a7f3 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1405,6 +1405,14 @@ mymain(void)
             QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
             QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_DEVICE_SCSI_GENERIC);
+    DO_TEST("hostdev-spapr-vfio", QEMU_CAPS_DEVICE,
+            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DRIVE,
+            QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_SCSI,
+            QEMU_CAPS_SPAPR_VFIO_HOST_BRIDGE,
+            QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_MLOCK,
+            QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
+            QEMU_CAPS_PCI_MULTIFUNCTION,
+            QEMU_CAPS_PCI_MULTIBUS);
 
     DO_TEST("mlock-on", QEMU_CAPS_MLOCK);
     DO_TEST_FAILURE("mlock-on", NONE);




More information about the libvir-list mailing list