[virt-tools-list] [PATCH virt-manager 11/14] domain: convert _change_boot_order to a instance method
Marc Hartmayer
mhartmay at linux.ibm.com
Tue Dec 18 13:45:00 UTC 2018
This avoids the access of non-local variables of the closure.
Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
virtManager/domain.py | 52 +++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 4fcc716eddf7..1577b213f533 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -575,37 +575,37 @@ class vmmDomain(vmmLibvirtObject):
self._redefine_xmlobj(guest)
+ def __use_device_boot_order(self, boot_order, guest):
+ boot_dev_order = []
+ devmap = dict((dev.get_xml_id(), dev) for dev in
+ self.get_bootable_devices())
+ for b in boot_order:
+ if b in devmap:
+ boot_dev_order.append(devmap[b])
+
+ # Unset the traditional boot order
+ guest.os.bootorder = []
+
+ # Unset device boot order
+ for dev in guest.devices.get_all():
+ dev.boot.order = None
+
+ count = 1
+ for origdev in boot_dev_order:
+ dev = self._lookup_device_to_define(guest, origdev, False)
+ if not dev:
+ continue
+ dev.boot.order = count
+ count += 1
+
def define_boot(self, boot_order=_SENTINEL, boot_menu=_SENTINEL,
- kernel=_SENTINEL, initrd=_SENTINEL, dtb=_SENTINEL,
- kernel_args=_SENTINEL, init=_SENTINEL, initargs=_SENTINEL):
+ kernel=_SENTINEL, initrd=_SENTINEL, dtb=_SENTINEL,
+ kernel_args=_SENTINEL, init=_SENTINEL, initargs=_SENTINEL):
guest = self._make_xmlobj_to_define()
- def _change_boot_order():
- boot_dev_order = []
- devmap = dict((dev.get_xml_id(), dev) for dev in
- self.get_bootable_devices())
- for b in boot_order:
- if b in devmap:
- boot_dev_order.append(devmap[b])
-
- # Unset the traditional boot order
- guest.os.bootorder = []
-
- # Unset device boot order
- for dev in guest.devices.get_all():
- dev.boot.order = None
-
- count = 1
- for origdev in boot_dev_order:
- dev = self._lookup_device_to_define(guest, origdev, False)
- if not dev:
- continue
- dev.boot.order = count
- count += 1
-
if boot_order != _SENTINEL:
if self.can_use_device_boot_order():
- _change_boot_order()
+ self.__use_device_boot_order(boot_order, guest)
else:
guest.os.bootorder = boot_order
--
2.17.0
More information about the virt-tools-list
mailing list