virt-manager/007-c9d070da-guest-Add-reorder_boot_order-method.patch
Charles Arnold 2677655bda - jsc#SLE-6262, fate#327048: KVM: Boot Configuration Override
001-adf30349-cli-refactor-get_prop.patch
  002-60c7e778-xmlapi-add-set_prop.patch
  003-5bad22e8-tests-Use-get-set_prop.patch
  004-ee5f3eab-support-Add-SUPPORT_CONN_DEVICE_BOOT_ORDER.patch
  005-7768eb17-cli-Add-check-if-device-boot-order-is-supported.patch
  006-ecc0861c-tests-xmlparse-refactor-method-for-generating-out-file-path.patch
  007-c9d070da-guest-Add-reorder_boot_order-method.patch
  008-1b535940-tests-Add-test-case-for-reorder_boot_order-method.patch
  009-b83a0a61-cli-Use-reorder_boot_order-for-setting-the-boot-order.patch
  010-c896d19d-tests-cli-Add-boot.order-tests.patch
  011-29f9f2ac-virt-xml-Add-no-define-argument.patch
  012-c2bff509-tests-cli-Add-test-case-for-no-define-argument.patch
  013-90b1a3ab-virt-xml-Add-support-for-starting-the-domain.patch
  014-908b8e8d-tests-virt-xml-Add-test-cases-for-start-option.patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=468
2019-05-23 15:40:50 +00:00

60 lines
2.2 KiB
Diff

References: jsc#SLE-6262, fate#327048: KVM: Boot Configuration Override (virt-manager)
Subject: guest: Add reorder_boot_order method
From: Marc Hartmayer mhartmay@linux.ibm.com Tue Feb 26 10:56:37 2019 +0100
Date: Wed Mar 6 13:15:38 2019 -0500:
Git: c9d070da4c3d31c3c504f52dbff775483ebf5e35
Add `reorder_boot_order` method to Guest class. It sets the boot order
of the passed `dev` to `boot_index` and adapts all other boot indices
of the guest accordingly.
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Index: virt-manager-2.1.0/virtinst/guest.py
===================================================================
--- virt-manager-2.1.0.orig/virtinst/guest.py
+++ virt-manager-2.1.0/virtinst/guest.py
@@ -257,6 +257,40 @@ class Guest(XMLBuilder):
return self.__osinfo
osinfo = property(_get_osinfo)
+ def reorder_boot_order(self, dev, boot_index):
+ """Sets boot order of `dev` to `boot_index`
+
+ Sets the boot order for device `dev` to value `boot_index` and
+ adjusts all other boot indices accordingly. Additionally the
+ boot order defined in the 'os' node of a domain definition is
+ disabled since they are mutually exclusive in libvirt.
+
+ """
+ # unset legacy boot order
+ self.os.bootorder = []
+
+ # Sort the bootable devices by boot order
+ devs_sorted = sorted([device for device in self.get_bootable_devices()
+ if device.boot.order is not None],
+ key=lambda device: device.boot.order)
+
+ # set new boot order
+ dev.boot.order = boot_index
+
+ next_boot_index = None
+ for device in devs_sorted:
+ if device is dev:
+ continue
+
+ if device.boot.order in [next_boot_index, boot_index]:
+ next_boot_index = device.boot.order + 1
+ device.boot.order = next_boot_index
+ continue
+
+ if next_boot_index is not None:
+ # we found a hole so we can stop here
+ break
+
def set_os_name(self, name):
obj = OSDB.lookup_os(name)
if obj is None: