Up until now there are just two ways how to specify UEFI paths to
libvirt. The first one is editing qemu.conf, the other is editing
qemu_conf.c and recompile. Therefore, two new configure options
are invented: --with-default-loader --with-default-nvram.

At the same time, the list of default paths is extended to AAVMF.
which is an aarch64 port of OVMF.

Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---

diff to v1:
-introduce configure options too

 configure.ac                       | 22 ++++++++++++++++++++++
 src/qemu/qemu.conf                 | 12 +++++++++---
 src/qemu/qemu_conf.c               | 24 ++++++++++++++++++++----
 src/qemu/test_libvirtd_qemu.aug.in |  1 +
 4 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9fd44b2..c22ac75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2786,6 +2786,28 @@ AC_ARG_WITH([default-editor],
   [DEFAULT_EDITOR=vi])
 AC_DEFINE_UNQUOTED([DEFAULT_EDITOR], ["$DEFAULT_EDITOR"], [Default editor to 
use])
 
+AC_ARG_WITH([default-loader],
+  [AS_HELP_STRING([--with-default-loader],
+    [Default UEFI loader path @<:@default=paths to OVMF and its clones@:>@])],
+  [with_default_loader=${withval}],
+  [with_default_loader=no])
+AC_ARG_WITH([default-nvram],
+  [AS_HELP_STRING([--with-default-nvram],
+    [Default UEFI NVRAM path @<:@default=paths to OVMF and its clones@:>@])],
+  [with_default_nvram=${withval}],
+  [with_default_nvram=no])
+
+if test "$with_default_loader:$with_default_nvram" != "no:no"; then
+    if test "$with_default_loader" = "no"; then
+        AC_MSG_ERROR([Can't use nvram without loader])
+    fi
+    if test "$with_default_nvram" = "no"; then
+        AC_MSG_ERROR([Can't use loader without nvram])
+    fi
+    AC_DEFINE_UNQUOTED([DEFAULT_LOADER], ["$with_default_loader"], [Default 
UEFI loader])
+    AC_DEFINE_UNQUOTED([DEFAULT_NVRAM], ["$with_default_nvram"], [Default UEFI 
nvram])
+fi
+
 # Some GNULIB base64 symbols clash with a kerberos library
 AC_DEFINE_UNQUOTED([isbase64],[libvirt_gl_isbase64],[Hack to avoid symbol 
clash])
 AC_DEFINE_UNQUOTED([base64_encode],[libvirt_gl_base64_encode],[Hack to avoid 
symbol clash])
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index c6db568..1c589a2 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -506,6 +506,12 @@
 # however, have different variables store. Therefore the nvram is
 # a list of strings when a single item is in form of:
 #   ${PATH_TO_UEFI_FW}:${PATH_TO_UEFI_VARS}.
-# Later, when libvirt creates per domain variable store, this
-# list is searched for the master image.
-#nvram = [ "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" ]
+# Later, when libvirt creates per domain variable store, this list is
+# searched for the master image. The UEFI firmware can be called
+# differently for different guest architectures. For instance, it's OVMF
+# for x86_64 and i686, but it's AAVMF for aarch64. The libvirt default
+# follows this scheme.
+#nvram = [
+#   "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd",
+#   "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd"
+#]
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4764bef..d268fc3 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -107,8 +107,10 @@ void qemuDomainCmdlineDefFree(qemuDomainCmdlineDefPtr def)
     VIR_FREE(def);
 }
 
-#define VIR_QEMU_LOADER_FILE_PATH "/usr/share/OVMF/OVMF_CODE.fd"
-#define VIR_QEMU_NVRAM_FILE_PATH "/usr/share/OVMF/OVMF_VARS.fd"
+#define VIR_QEMU_OVMF_LOADER_PATH "/usr/share/AAVMF/AAVMF_CODE.fd"
+#define VIR_QEMU_OVMF_NVRAM_PATH "/usr/share/AAVMF/AAVMF_VARS.fd"
+#define VIR_QEMU_AAVMF_LOADER_PATH "/usr/share/OVMF/OVMF_CODE.fd"
+#define VIR_QEMU_AAVMF_NVRAM_PATH "/usr/share/OVMF/OVMF_VARS.fd"
 
 virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
 {
@@ -258,15 +260,29 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool 
privileged)
 
     cfg->logTimestamp = true;
 
+#if defined(DEFAULT_LOADER) && defined(DEFAULT_NVRAM)
     if (VIR_ALLOC_N(cfg->loader, 1) < 0 ||
         VIR_ALLOC_N(cfg->nvram, 1) < 0)
         goto error;
     cfg->nloader = 1;
 
-    if (VIR_STRDUP(cfg->loader[0], VIR_QEMU_LOADER_FILE_PATH) < 0 ||
-        VIR_STRDUP(cfg->nvram[0], VIR_QEMU_NVRAM_FILE_PATH) < 0)
+    if (VIR_STRDUP(cfg->loader[0], DEFAULT_LOADER) < 0 ||
+        VIR_STRDUP(cfg->nvram[0], DEFAULT_NVRAM) < 0)
         goto error;
 
+#else /* defined(DEFAULT_LOADER && defined(DEFAULT_NVRAM) */
+
+    if (VIR_ALLOC_N(cfg->loader, 2) < 0 ||
+        VIR_ALLOC_N(cfg->nvram, 2) < 0)
+        goto error;
+    cfg->nloader = 2;
+
+    if (VIR_STRDUP(cfg->loader[0], VIR_QEMU_OVMF_LOADER_PATH) < 0 ||
+        VIR_STRDUP(cfg->nvram[0], VIR_QEMU_OVMF_NVRAM_PATH) < 0 ||
+        VIR_STRDUP(cfg->loader[1], VIR_QEMU_AAVMF_LOADER_PATH) < 0 ||
+        VIR_STRDUP(cfg->nvram[1], VIR_QEMU_AAVMF_NVRAM_PATH) < 0)
+        goto error;
+#endif /* defined(DEFAULT_LOADER && defined(DEFAULT_NVRAM) */
     return cfg;
 
  error:
diff --git a/src/qemu/test_libvirtd_qemu.aug.in 
b/src/qemu/test_libvirtd_qemu.aug.in
index 30fd27e..fc4935b 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -76,4 +76,5 @@ module Test_libvirtd_qemu =
 { "log_timestamp" = "0" }
 { "nvram"
     { "1" = "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" }
+    { "2" = "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd" }
 }
-- 
2.0.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to