[virt-tools-list] [virt-manager PATCH 1/2] virtinst: add support enable setting multifunction on hostdev

Chen Hanxiao chen_han_xiao at 126.com
Tue May 9 10:23:56 UTC 2017


From: Chen Hanxiao <chenhanxiao at gmail.com>

  This patch will enable setting multifunction
  on hostdev.

Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
---
 tests/cli-test-xml/compare/virt-install-many-devices.xml | 6 ++++++
 tests/clitest.py                                         | 1 +
 virtinst/cli.py                                          | 1 +
 virtinst/devicehostdev.py                                | 3 ++-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index 06edf9d..e4e1a74 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -353,6 +353,12 @@
         <address bus="1" device="21"/>
       </source>
     </hostdev>
+    <hostdev mode="subsystem" type="pci" managed="yes">
+      <source>
+        <address domain="0" bus="21" slot="0" function="1"/>
+      </source>
+      <address type="pci" domain="0" bus="0" slot="10" multifunction="on"/>
+    </hostdev>
     <smartcard mode="passthrough" type="spicevmc"/>
     <smartcard mode="passthrough" type="host"/>
     <redirdev bus="usb" type="spicevmc"/>
diff --git a/tests/clitest.py b/tests/clitest.py
index e329e67..a263574 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -515,6 +515,7 @@ c.add_compare(""" \
 --host-device 04b3:4485 \
 --host-device pci_8086_2829_scsi_host_scsi_device_lun0 \
 --hostdev usb_5_20 --hostdev usb_5_21 \
+--hostdev 00:15:0.1,address.type=pci,address.domain=0x0000,address.bus=0x0,address.slot=0xa,address.multifunction=on \
 \
 
 --filesystem /source,/target \
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 52f9106..9a332f0 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2691,6 +2691,7 @@ ParserHostdev.add_arg(None, "name",
 ParserHostdev.add_arg("driver_name", "driver_name")
 ParserHostdev.add_arg("boot.order", "boot_order")
 ParserHostdev.add_arg("rom_bar", "rom_bar", is_onoff=True)
+ParserHostdev.add_arg("multifunction", "multifunction", is_onoff=True)
 
 
 ###########################
diff --git a/virtinst/devicehostdev.py b/virtinst/devicehostdev.py
index 34c00b0..fe751c1 100644
--- a/virtinst/devicehostdev.py
+++ b/virtinst/devicehostdev.py
@@ -111,7 +111,7 @@ class VirtualHostDevice(VirtualDevice):
 
 
     _XML_PROP_ORDER = ["mode", "type", "managed", "vendor", "product",
-                       "domain", "bus", "slot", "function"]
+                       "domain", "bus", "slot", "function", "multifunction"]
 
     mode = XMLProperty("./@mode", default_cb=lambda s: "subsystem")
     type = XMLProperty("./@type")
@@ -134,6 +134,7 @@ class VirtualHostDevice(VirtualDevice):
     domain = XMLProperty("./source/address/@domain",
                          default_cb=_get_default_domain)
     function = XMLProperty("./source/address/@function")
+    multifunction = XMLProperty("./address/@multifunction")
     slot = XMLProperty("./source/address/@slot")
 
     driver_name = XMLProperty("./driver/@name")
-- 
2.7.4





More information about the virt-tools-list mailing list