[virt-tools-list] [virt-manager PATCH V3 2/3] tests: add test for network of SR-IOV VF pool

Lin Ma lma at suse.com
Fri Mar 31 12:12:00 UTC 2017


Signed-off-by: Lin Ma <lma at suse.com>
---
 tests/xmlparse-xml/network-vf-pool-in.xml  |  5 +++++
 tests/xmlparse-xml/network-vf-pool-out.xml |  6 ++++++
 tests/xmlparse.py                          | 21 +++++++++++++++++++++
 virtinst/network.py                        | 12 ++++++++++++
 4 files changed, 44 insertions(+)
 create mode 100644 tests/xmlparse-xml/network-vf-pool-in.xml
 create mode 100644 tests/xmlparse-xml/network-vf-pool-out.xml

diff --git a/tests/xmlparse-xml/network-vf-pool-in.xml b/tests/xmlparse-xml/network-vf-pool-in.xml
new file mode 100644
index 0000000..821aa07
--- /dev/null
+++ b/tests/xmlparse-xml/network-vf-pool-in.xml
@@ -0,0 +1,5 @@
+<network>
+  <name>passthrough</name>
+    <forward mode="hostdev" managed="yes">
+    </forward>
+</network>
diff --git a/tests/xmlparse-xml/network-vf-pool-out.xml b/tests/xmlparse-xml/network-vf-pool-out.xml
new file mode 100644
index 0000000..62a7305
--- /dev/null
+++ b/tests/xmlparse-xml/network-vf-pool-out.xml
@@ -0,0 +1,6 @@
+<network>
+  <name>new-foo</name>
+    <forward mode="hostdev" managed="yes">
+      <pf dev="eth3"/>
+    </forward>
+</network>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index a7fe5dd..b8beebf 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -1293,6 +1293,27 @@ class XMLParseTest(unittest.TestCase):
         utils.diff_compare(net.get_xml_config(), outfile)
         utils.test_create(conn, net.get_xml_config(), "networkDefineXML")
 
+    def testNetVfPool(self):
+        basename = "network-vf-pool"
+        infile = "tests/xmlparse-xml/%s-in.xml" % basename
+        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
+        net = virtinst.Network(conn, parsexml=file(infile).read())
+
+        check = self._make_checker(net)
+        check("name", "passthrough", "new-foo")
+
+        check = self._make_checker(net.forward)
+        check("mode", "hostdev")
+        check("managed", "yes")
+
+        r = net.forward.add_pf()
+        r.dev = "eth3"
+        check = self._make_checker(r)
+        check("dev", "eth3")
+
+        utils.diff_compare(net.get_xml_config(), outfile)
+        utils.test_create(conn, net.get_xml_config(), "networkDefineXML")
+
 
     ##############
     # Misc tests #
diff --git a/virtinst/network.py b/virtinst/network.py
index 457afa0..dfc1436 100644
--- a/virtinst/network.py
+++ b/virtinst/network.py
@@ -72,11 +72,23 @@ class _NetworkRoute(XMLBuilder):
     netmask = XMLProperty("./@netmask")
 
 
+class _NetworkForwardPf(XMLBuilder):
+    _XML_ROOT_NAME = "pf"
+    dev = XMLProperty("./@dev")
+
+
 class _NetworkForward(XMLBuilder):
     _XML_ROOT_NAME = "forward"
 
     mode = XMLProperty("./@mode")
     dev = XMLProperty("./@dev")
+    managed = XMLProperty("./@managed")
+    pf = XMLChildProperty(_NetworkForwardPf)
+
+    def add_pf(self):
+        r = _NetworkForwardPf(self.conn)
+        self.add_child(r)
+        return r
 
     def pretty_desc(self):
         return Network.pretty_forward_desc(self.mode, self.dev)
-- 
2.9.2




More information about the virt-tools-list mailing list