Subject: virt-install: Add support for xenbus controller
From: Jim Fehlig jfehlig@suse.com Wed Mar 20 14:24:41 2019 -0600
Date: Thu Mar 21 14:15:40 2019 -0400:
Git: 8d9743d69f5a197d959995552bda380a44e583b4

libvirt commit 09eb1ae0 added support for a new 'xenbus' controller
type. Add support for the controller in virtinst, including support
for the maxGrantFrames attribute.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>

Index: virt-manager-1.5.1/tests/cli-test-xml/compare/virt-install-many-devices.xml
===================================================================
--- virt-manager-1.5.1.orig/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ virt-manager-1.5.1/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -168,6 +168,7 @@
       <master startport="4"/>
       <address type="pci" domain="0" bus="0" slot="4" function="2"/>
     </controller>
+    <controller type="xenbus" index="0" maxGrantFrames="64"/>
     <filesystem type="mount" accessmode="mapped">
       <source dir="/source"/>
       <target dir="/target"/>
Index: virt-manager-1.5.1/tests/cli-test-xml/compare/virt-install-xen-pv.xml
===================================================================
--- virt-manager-1.5.1.orig/tests/cli-test-xml/compare/virt-install-xen-pv.xml
+++ virt-manager-1.5.1/tests/cli-test-xml/compare/virt-install-xen-pv.xml
@@ -17,6 +17,7 @@
       <source file="/dev/default-pool/testvol1.img"/>
       <target dev="xvda" bus="xen"/>
     </disk>
+    <controller type="xenbus" index="0" maxGrantFrames="64"/>
     <interface type="bridge">
       <source bridge="eth0"/>
       <mac address="00:11:22:33:44:55"/>
@@ -38,6 +39,7 @@
       <source file="/dev/default-pool/testvol1.img"/>
       <target dev="xvda" bus="xen"/>
     </disk>
+    <controller type="xenbus" index="0" maxGrantFrames="64"/>
     <interface type="bridge">
       <source bridge="eth0"/>
       <mac address="00:11:22:33:44:55"/>
Index: virt-manager-1.5.1/tests/clitest.py
===================================================================
--- virt-manager-1.5.1.orig/tests/clitest.py
+++ virt-manager-1.5.1/tests/clitest.py
@@ -508,6 +508,7 @@ c.add_compare(""" \
 --controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 \
 --controller usb,model=ich9-uhci2,address=0:0:4.1,index=0,master=2 \
 --controller usb,model=ich9-uhci3,address=0:0:4.2,index=0,master=4 \
+--controller xenbus,maxGrantFrames=64 \
 \
 --input type=keyboard,bus=usb \
 --input tablet \
@@ -839,7 +840,7 @@ c.add_compare("--init /usr/bin/httpd", "
 c = vinst.add_category("xen", "--connect %(URI-XEN)s --noautoconsole")
 c.add_valid("--disk %(EXISTIMG1)s --location %(TREEDIR)s --paravirt --graphics none")  # Xen PV install headless
 c.add_compare("--disk %(EXISTIMG1)s --import", "xen-default")  # Xen default
-c.add_compare("--disk %(EXISTIMG1)s --location %(TREEDIR)s --paravirt", "xen-pv")  # Xen PV
+c.add_compare("--disk %(EXISTIMG1)s --location %(TREEDIR)s --paravirt --controller xenbus,maxGrantFrames=64", "xen-pv")  # Xen PV
 c.add_compare("--disk %(BLOCKVOL)s --cdrom %(EXISTIMG1)s --livecd --hvm", "xen-hvm")  # Xen HVM
 
 
Index: virt-manager-1.5.1/virtinst/cli.py
===================================================================
--- virt-manager-1.5.1.orig/virtinst/cli.py
+++ virt-manager-1.5.1/virtinst/cli.py
@@ -2243,6 +2243,7 @@ ParserNetwork.add_arg("link_state", "lin
 
 ParserNetwork.add_arg("driver_name", "driver_name")
 ParserNetwork.add_arg("driver_queues", "driver_queues")
+ParserNetwork.add_arg("maxGrantFrames", "maxGrantFrames")
 
 ParserNetwork.add_arg("rom_file", "rom_file")
 ParserNetwork.add_arg("rom_bar", "rom_bar", is_onoff=True)
Index: virt-manager-1.5.1/virtinst/devicecontroller.py
===================================================================
--- virt-manager-1.5.1.orig/virtinst/devicecontroller.py
+++ virt-manager-1.5.1/virtinst/devicecontroller.py
@@ -32,10 +32,11 @@ class VirtualController(VirtualDevice):
     TYPE_USB             = "usb"
     TYPE_PCI             = "pci"
     TYPE_CCID            = "ccid"
+    TYPE_XENBUS          = "xenbus"
     TYPES = [TYPE_IDE, TYPE_FDC,
              TYPE_SCSI, TYPE_SATA,
              TYPE_VIRTIOSERIAL, TYPE_USB,
-             TYPE_PCI, TYPE_CCID]
+             TYPE_PCI, TYPE_CCID, TYPE_XENBUS]
 
     @staticmethod
     def pretty_type(ctype):
@@ -48,6 +49,7 @@ class VirtualController(VirtualDevice):
             VirtualController.TYPE_USB:             "USB",
             VirtualController.TYPE_PCI:             "PCI",
             VirtualController.TYPE_CCID:            "CCID",
+            VirtualController.TYPE_XENBUS:          "XENBUS",
        }
 
         if ctype not in pretty_mappings:
@@ -94,13 +96,14 @@ class VirtualController(VirtualDevice):
         return ctrl
 
 
-    _XML_PROP_ORDER = ["type", "index", "model", "master_startport"]
+    _XML_PROP_ORDER = ["type", "index", "model", "master_startport", "maxGrantFrames"]
 
     type = XMLProperty("./@type")
     model = XMLProperty("./@model")
     vectors = XMLProperty("./@vectors", is_int=True)
     ports = XMLProperty("./@ports", is_int=True)
     master_startport = XMLProperty("./master/@startport", is_int=True)
+    maxGrantFrames = XMLProperty("./@maxGrantFrames", is_int=True)
 
     index = XMLProperty("./@index", is_int=True, default_cb=lambda s: 0)
 
