Blame SOURCES/virt-manager-tests-verify-MDEV-support.patch

01947c
From a243508cc0a896dd35a73277ca651fa8638b086b Mon Sep 17 00:00:00 2001
01947c
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
01947c
Date: Mon, 31 May 2021 21:54:28 +0200
01947c
Subject: [PATCH] tests: verify MDEV support
01947c
01947c
Add tests to verify add, edit and remove features of mediated
01947c
devices.
01947c
01947c
Reviewed-by: Cole Robinson <crobinso@redhat.com>
01947c
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
01947c
(cherry picked from commit 9d4002ee0f7088c490748ffb3144c006f4e39c68)
01947c
01947c
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995125
01947c
01947c
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
01947c
---
01947c
 .../virt-xml-add-hostdev-mdev-start.xml       | 12 +++++++
01947c
 .../cli/compare/virt-xml-add-hostdev-mdev.xml | 14 ++++++++
01947c
 tests/data/cli/compare/virt-xml-edit-all.xml  |  7 ++++
01947c
 .../compare/virt-xml-edit-hostdev-mdev.xml    | 11 +++++++
01947c
 .../compare/virt-xml-edit-simple-redirdev.xml |  2 +-
01947c
 .../compare/virt-xml-remove-hostdev-mdev.xml  | 15 +++++++++
01947c
 tests/data/testdriver/testsuite.xml           | 32 +++++++++++++++++++
01947c
 tests/test_cli.py                             |  4 +++
01947c
 tests/utils.py                                |  2 +-
01947c
 9 files changed, 97 insertions(+), 2 deletions(-)
01947c
 create mode 100644 tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
01947c
 create mode 100644 tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
01947c
 create mode 100644 tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
01947c
 create mode 100644 tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
01947c
01947c
diff --git a/tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml b/tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
01947c
new file mode 100644
01947c
index 00000000..3742d454
01947c
--- /dev/null
01947c
+++ b/tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
01947c
@@ -0,0 +1,12 @@
01947c
+       <model type="cirrus" vram="16384" heads="1" primary="yes"/>
01947c
+     </video>
01947c
+     <memballoon model="virtio"/>
01947c
++    <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
01947c
++      <source>
01947c
++        <address uuid="8e37ee90-2b51-45e3-9b25-bf8283c03110"/>
01947c
++      </source>
01947c
++    </hostdev>
01947c
+   </devices>
01947c
+ </domain>
01947c
+
01947c
+Domain 'test-state-shutoff' started successfully.
01947c
diff --git a/tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml b/tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
01947c
new file mode 100644
01947c
index 00000000..c2acff8f
01947c
--- /dev/null
01947c
+++ b/tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
01947c
@@ -0,0 +1,14 @@
01947c
+     <vsock model="virtio">
01947c
+       <cid auto="no" address="5"/>
01947c
+     </vsock>
01947c
++    <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
01947c
++      <source>
01947c
++        <address uuid="8e37ee90-2b51-45e3-9b25-bf8283c03110"/>
01947c
++      </source>
01947c
++    </hostdev>
01947c
+   </devices>
01947c
+   <seclabel type="dynamic" model="selinux" relabel="yes"/>
01947c
+   <keywrap>
01947c
+
01947c
+Domain 'test-for-virtxml' defined successfully.
01947c
+Changes will take effect after the domain is fully powered off.
01947c
diff --git a/tests/data/cli/compare/virt-xml-edit-all.xml b/tests/data/cli/compare/virt-xml-edit-all.xml
01947c
index ed09effc..5bdee2aa 100644
01947c
--- a/tests/data/cli/compare/virt-xml-edit-all.xml
01947c
+++ b/tests/data/cli/compare/virt-xml-edit-all.xml
01947c
@@ -8,6 +8,13 @@
01947c
          <address domain="0x0000" bus="0x00" slot="0x19" function="0x0"/>
01947c
        </source>
01947c
        <rom bar="off"/>
01947c
++      <driver name="vfio"/>
01947c
+     </hostdev>
01947c
+     <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
01947c
+       <source>
01947c
+         <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
01947c
+       </source>
01947c
+       <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
01947c
 +      <driver name="vfio"/>
01947c
      </hostdev>
01947c
      <redirdev bus="usb" type="tcp">
01947c
diff --git a/tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml b/tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
01947c
new file mode 100644
01947c
index 00000000..ef5523db
01947c
--- /dev/null
01947c
+++ b/tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
01947c
@@ -0,0 +1,11 @@
01947c
+       <source>
01947c
+         <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
01947c
+       </source>
01947c
+-      <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
01947c
++      <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0008"/>
01947c
+     </hostdev>
01947c
+     <redirdev bus="usb" type="tcp">
01947c
+       <source mode="connect" host="localhost" service="4000"/>
01947c
+
01947c
+Domain 'test-for-virtxml' defined successfully.
01947c
+Changes will take effect after the domain is fully powered off.
01947c
diff --git a/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml b/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml
01947c
index 52ffddfe..f1a0ff6c 100644
01947c
--- a/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml
01947c
+++ b/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml
01947c
@@ -1,5 +1,5 @@
01947c
        </source>
01947c
-       <rom bar="off"/>
01947c
+       <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
01947c
      </hostdev>
01947c
 -    <redirdev bus="usb" type="tcp">
01947c
 -      <source mode="connect" host="localhost" service="4000"/>
01947c
diff --git a/tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml b/tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
01947c
new file mode 100644
01947c
index 00000000..d4c33804
01947c
--- /dev/null
01947c
+++ b/tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
01947c
@@ -0,0 +1,15 @@
01947c
+       </source>
01947c
+       <rom bar="off"/>
01947c
+     </hostdev>
01947c
+-    <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
01947c
+-      <source>
01947c
+-        <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
01947c
+-      </source>
01947c
+-      <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
01947c
+-    </hostdev>
01947c
+     <redirdev bus="usb" type="tcp">
01947c
+       <source mode="connect" host="localhost" service="4000"/>
01947c
+       <protocol type="raw"/>
01947c
+
01947c
+Domain 'test-for-virtxml' defined successfully.
01947c
+Changes will take effect after the domain is fully powered off.
01947c
diff --git a/tests/data/testdriver/testsuite.xml b/tests/data/testdriver/testsuite.xml
01947c
index fd255138..a073cbce 100644
01947c
--- a/tests/data/testdriver/testsuite.xml
01947c
+++ b/tests/data/testdriver/testsuite.xml
01947c
@@ -259,6 +259,12 @@
01947c
       </source>
01947c
       <rom bar='off'/>
01947c
     </hostdev>
01947c
+    <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
01947c
+      <source>
01947c
+        <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
01947c
+      </source>
01947c
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
01947c
+    </hostdev>
01947c
 
01947c
     <serial type='null'/>
01947c
 
01947c
@@ -737,5 +743,31 @@
01947c
   </capability>
01947c
 </device>
01947c
 
01947c
+<device>
01947c
+  <name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110</name>
01947c
+  <path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110</path>
01947c
+  <parent>css_0_0_0023</parent>
01947c
+  <driver>
01947c
+    <name>vfio_mdev</name>
01947c
+  </driver>
01947c
+  <capability type='mdev'>
01947c
+    <type id='vfio_ccw-io'/>
01947c
+    <iommuGroup number='0'/>
01947c
+  </capability>
01947c
+</device>
01947c
+
01947c
+<device>
01947c
+  <name>mdev_b1ae8bf6_38b0_4c81_9d44_78ce3f520496</name>
01947c
+  <path>/sys/devices/css0/0.0.0023/b1ae8bf6-38b0-4c81-9d44-78ce3f520496</path>
01947c
+  <parent>css_0_0_0023</parent>
01947c
+  <driver>
01947c
+    <name>vfio_mdev</name>
01947c
+  </driver>
01947c
+  <capability type='mdev'>
01947c
+    <type id='vfio_ccw-io'/>
01947c
+    <iommuGroup number='0'/>
01947c
+  </capability>
01947c
+</device>
01947c
+
01947c
 
01947c
 </node>
01947c
diff --git a/tests/test_cli.py b/tests/test_cli.py
01947c
index 5f94e009..9f0cdfe9 100644
01947c
--- a/tests/test_cli.py
01947c
+++ b/tests/test_cli.py
01947c
@@ -1274,6 +1274,7 @@ c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "edit-selec
01947c
 c.add_compare("--edit target=hda --disk boot_order=1", "edit-select-disk-bootorder")
01947c
 c.add_compare("--edit path=/dev/null --disk path=,target=fdb,boot_order=12", "edit-disk-unset")  # --disk matching, using empty value to unset path
01947c
 c.add_compare("--edit --memballoon none", "edit-disable-memballoon")
01947c
+c.add_compare("--edit address.devno=0x0002 --hostdev address.devno=0x0008", "edit-hostdev-mdev")
01947c
 
01947c
 c = vixml.add_category("edit and start selection", "test-state-shutoff --print-diff --start")
01947c
 c.add_compare("--define --edit target=vda --disk boot_order=1", "start-select-disk-bootorder")
01947c
@@ -1308,6 +1309,8 @@ c.add_compare("--remove-device --disk /dev/null", "remove-disk-path")
01947c
 c.add_compare("--remove-device --video all", "remove-video-all")
01947c
 c.add_compare("--remove-device --host-device 0x04b3:0x4485", "remove-hostdev-name")
01947c
 c.add_compare("--remove-device --memballoon all", "remove-memballoon")
01947c
+c.add_compare("--add-device --hostdev mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110", "add-hostdev-mdev")
01947c
+c.add_compare("--remove-device --hostdev mdev_b1ae8bf6_38b0_4c81_9d44_78ce3f520496", "remove-hostdev-mdev")
01947c
 
01947c
 c = vixml.add_category("add/rm devices and start", "test-state-shutoff --print-diff --start")
01947c
 c.add_invalid("--add-device --pm suspend_to_disk=yes")  # --add-device without a device
01947c
@@ -1318,6 +1321,7 @@ c.add_compare("--define --add-device --host-device usb_device_4b3_4485_noserial"
01947c
 c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "add-disk-basic-start")
01947c
 c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "add-disk-create-storage-start")
01947c
 c.add_compare("--remove-device --disk /dev/null", "remove-disk-path-start")
01947c
+c.add_compare("--add-device --hostdev mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110", "add-hostdev-mdev-start")
01947c
 
01947c
 c = vixml.add_category("add/rm devices OS KVM", "--connect %(URI-KVM)s test --print-diff --define")
01947c
 c.add_compare("--add-device --disk %(EXISTIMG1)s", "kvm-add-disk-os-from-xml")  # Guest OS (none) from XML
01947c
diff --git a/tests/utils.py b/tests/utils.py
01947c
index 16ba26b4..62443ca8 100644
01947c
--- a/tests/utils.py
01947c
+++ b/tests/utils.py
01947c
@@ -231,7 +231,7 @@ def diff_compare(actual_out, filename=None, expect_out=None):
01947c
             open(filename, "w").write(actual_out)
01947c
         expect_out = open(filename).read()
01947c
 
01947c
-    diff = xmlutil.diff(expect_out, actual_out,
01947c
+    diff = xmlutil.diff(expect_out.rstrip(), actual_out.rstrip(),
01947c
             filename or '', "Generated output")
01947c
     if diff:
01947c
         raise AssertionError("Conversion outputs did not match.\n%s" % diff)
01947c
-- 
01947c
2.31.1
01947c