[virt-tools-list] [PATCH virt-manager 05/10] domain: Move use_device_boot_order to guest

Marc Hartmayer mhartmay at linux.ibm.com
Wed Feb 6 09:55:38 UTC 2019


Move use_device_boot_order to guest XML builder and rename it into
'set_device_boot_order'.

Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
 virtManager/domain.py | 18 +-----------------
 virtinst/guest.py     | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 9c1a8e49cbe3..77dc6a3d7206 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -521,22 +521,6 @@ class vmmDomain(vmmLibvirtObject):
 
         self._redefine_xmlobj(guest)
 
-    def __use_device_boot_order(self, boot_order, guest):
-        # Unset the traditional boot order
-        guest.os.bootorder = []
-
-        # Unset device boot order
-        for dev in guest.devices.get_all():
-            dev.boot.order = None
-
-        dev_map = dict((dev.get_xml_id(), dev) for dev in
-                       guest.get_bootable_devices(exclude_redirdev=True))
-        for boot_order_idx, dev_xml_id in enumerate(boot_order, 1):
-            try:
-                dev_map[dev_xml_id].boot.order = boot_order_idx
-            except KeyError:
-                pass
-
     def define_boot(self, boot_order=_SENTINEL, boot_menu=_SENTINEL,
                     kernel=_SENTINEL, initrd=_SENTINEL, dtb=_SENTINEL,
                     kernel_args=_SENTINEL, init=_SENTINEL, initargs=_SENTINEL):
@@ -544,7 +528,7 @@ class vmmDomain(vmmLibvirtObject):
         guest = self._make_xmlobj_to_define()
         if boot_order != _SENTINEL:
             if self.can_use_device_boot_order():
-                self.__use_device_boot_order(boot_order, guest)
+                guest.set_device_boot_order(boot_order)
             else:
                 guest.os.bootorder = boot_order
 
diff --git a/virtinst/guest.py b/virtinst/guest.py
index c1c175b6d75d..bc70abbe99ab 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -312,6 +312,23 @@ class Guest(XMLBuilder):
         return self.__osinfo
     osinfo = property(_get_osinfo)
 
+    def set_device_boot_order(self, boot_order):
+        """Sets the new device boot order for the domain"""
+        # Unset the traditional boot order
+        self.os.bootorder = []
+
+        # Unset device boot order
+        for dev in self.devices.get_all():
+            dev.boot.order = None
+
+        dev_map = dict((dev.get_xml_id(), dev) for dev in
+                       self.get_bootable_devices(exclude_redirdev=True))
+        for boot_idx, dev_xml_id in enumerate(boot_order, 1):
+            try:
+                dev_map[dev_xml_id].boot.order = boot_idx
+            except KeyError:
+                pass
+
     def set_os_name(self, name):
         obj = OSDB.lookup_os(name)
         if obj is None:
-- 
2.17.0




More information about the virt-tools-list mailing list