File 0001-Handle-alternative-UEFI-boot-loader-locations-on-SLE.patch of Package openstack-nova

From 4d50e2e6470477d690dff07eb24dfbb89a37b77d Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Thu, 28 Jul 2016 16:39:19 +0200
Subject: [PATCH] Handle alternative UEFI boot loader locations on SLES

These EDKs are located in a different path here with no symlinks,
so just probe for all of those paths in an order and pick one
that exists. This kludges around a problem on UEFI images on SLES.

Change-Id: I28afdb09d300be39981606d5234fd837ea738e1d
Closes-Bug: 1607400
---
 nova/virt/libvirt/driver.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Index: nova-18.3.1.dev89/nova/virt/libvirt/driver.py
===================================================================
--- nova-18.3.1.dev89.orig/nova/virt/libvirt/driver.py
+++ nova-18.3.1.dev89/nova/virt/libvirt/driver.py
@@ -139,8 +139,10 @@ DEFAULT_FIREWALL_DRIVER = "%s.%s" % (
     libvirt_firewall.IptablesFirewallDriver.__name__)
 
 DEFAULT_UEFI_LOADER_PATH = {
-    "x86_64": "/usr/share/OVMF/OVMF_CODE.fd",
-    "aarch64": "/usr/share/AAVMF/AAVMF_CODE.fd"
+    "x86_64": ['/usr/share/OVMF/OVMF_CODE.fd',
+               '/usr/share/qemu/ovmf-x86_64-code.bin'],
+    "aarch64": ['/usr/share/AAVMF/AAVMF_CODE.fd',
+                '/usr/share/qemu/aavmf-aarch64-code.bin']
 }
 
 MAX_CONSOLE_BYTES = 100 * units.Ki
@@ -4969,8 +4971,12 @@ class LibvirtDriver(driver.ComputeDriver
         supported_archs = [fields.Architecture.X86_64,
                            fields.Architecture.AARCH64]
         caps = self._host.get_capabilities()
+        # TODO(dmllr): Instead of probing UEFI_LOADER_PATHS, we should query
+        # libvirt domCapabilities that should be configured correctly
+        # whether UEFI is available or not
         return ((caps.host.cpu.arch in supported_archs) and
-                os.path.exists(DEFAULT_UEFI_LOADER_PATH[caps.host.cpu.arch]))
+                any((os.path.exists(p)
+                     for p in DEFAULT_UEFI_LOADER_PATH[caps.host.cpu.arch])))
 
     def _get_supported_perf_events(self):
 
@@ -5030,8 +5036,10 @@ class LibvirtDriver(driver.ComputeDriver
                                     "functional testing and therefore "
                                     "considered experimental.")
                         uefi_logged = True
-                    guest.os_loader = DEFAULT_UEFI_LOADER_PATH[
-                        caps.host.cpu.arch]
+                    for candidate in \
+                            DEFAULT_UEFI_LOADER_PATH[caps.host.cpu.arch]:
+                        if os.path.exists(candidate):
+                            guest.os_loader = candidate
                     guest.os_loader_type = "pflash"
                 else:
                     raise exception.UEFINotSupported()
openSUSE Build Service is sponsored by