]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Warn verbosely if using old loader:nvram pairs
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 11 Nov 2019 16:22:50 +0000 (17:22 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 12 Nov 2019 07:34:37 +0000 (08:34 +0100)
There are two ways for specifying loader:nvram pairs:

  1) --with-loader-nvram configure option
  2) nvram variable in qemu.conf

Since we have FW descriptors, using this old style is
discouraged, but not as strong as one would expect. Produce more
warnings:

  1) produce a warning if somebody tries the configure option
  2) produce a warning if somebody sets nvram variable and at
     least on FW descriptor was found

The reason for producing warning in case 1) is that package
maintainers, who set the configure option in the first place
should start moving towards FW descriptors and abandon the
configure option. After all, the warning is printed into config
output only in this case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1763477

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
m4/virt-loader-nvram.m4
src/qemu/qemu.conf
src/qemu/qemu_conf.c

index d7e0c8ca187eb57e9b27524e33ef257cbd27b167..ed2ae0cf27ba002a743520ebca07edc2ef2c8264 100644 (file)
@@ -30,6 +30,8 @@ AC_DEFUN([LIBVIRT_CHECK_LOADER_NVRAM], [
     l=$(echo $with_loader_nvram | tr ':' '\n' | wc -l)
     if test $(expr $l % 2) -ne 0 ; then
       AC_MSG_ERROR([Malformed --with-loader-nvram argument])
+    elif test $l -gt 0 ; then
+      AC_MSG_WARN([Note that --with-loader-nvram is obsolete and will be removed soon])
     fi
     AC_DEFINE_UNQUOTED([DEFAULT_LOADER_NVRAM], ["$with_loader_nvram"],
                        [List of loader:nvram pairs])
@@ -37,5 +39,11 @@ AC_DEFUN([LIBVIRT_CHECK_LOADER_NVRAM], [
 ])
 
 AC_DEFUN([LIBVIRT_RESULT_LOADER_NVRAM], [
-  LIBVIRT_RESULT([Loader/NVRAM], [$with_loader_nvram])
+  if test "x$with_loader_nvram" != "xno" && \
+     test "x$with_loader_nvram" != "x" ; then
+    LIBVIRT_RESULT([Loader/NVRAM], [$with_loader_nvram],
+                   [!!! Using this configure option is strongly discouraged !!!])
+  else
+    LIBVIRT_RESULT([Loader/NVRAM], [$with_loader_nvram])
+  fi
 ])
index b3a3428e4c8912716fa2d374819f0095c8bbf7a2..7a056b037ed562fe5cdcae343084c914f72383a2 100644 (file)
 # source tree. These metadata files are distributed alongside any
 # firmware images intended for use with QEMU.
 #
+# NOTE: if ANY firmware metadata files are detected, this setting
+# will be COMPLETELY IGNORED.
+#
 # ------------------------------------------
 #
 # When a domain is configured to use UEFI instead of standard
index fae697a2ef7b6ced4ef1bb3452ab23cbdacaaeb6..293f2635cca266c81b8ad7c9c6fd69a3a65cc774 100644 (file)
@@ -32,6 +32,7 @@
 #include "qemu_conf.h"
 #include "qemu_capabilities.h"
 #include "qemu_domain.h"
+#include "qemu_firmware.h"
 #include "qemu_security.h"
 #include "viruuid.h"
 #include "virbuffer.h"
@@ -799,7 +800,8 @@ virQEMUDriverConfigLoadLogEntry(virQEMUDriverConfigPtr cfg,
 
 static int
 virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfigPtr cfg,
-                                  virConfPtr conf)
+                                  virConfPtr conf,
+                                  bool privileged)
 {
     VIR_AUTOSTRINGLIST nvram = NULL;
     size_t i;
@@ -807,8 +809,21 @@ virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfigPtr cfg,
     if (virConfGetValueStringList(conf, "nvram", false, &nvram) < 0)
         return -1;
     if (nvram) {
+        VIR_AUTOSTRINGLIST fwList = NULL;
+
         virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares);
 
+        if (qemuFirmwareFetchConfigs(&fwList, privileged) < 0)
+            return -1;
+
+        if (fwList) {
+            VIR_WARN("Obsolete nvram variable is set while firmware metadata "
+                     "files found. Note that the nvram config file variable is "
+                     "going to be ignored.");
+            cfg->nfirmwares = 0;
+            return 0;
+        }
+
         cfg->nfirmwares = virStringListLength((const char *const *)nvram);
         if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) < 0)
             return -1;
@@ -1041,7 +1056,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
     if (virQEMUDriverConfigLoadLogEntry(cfg, conf) < 0)
         return -1;
 
-    if (virQEMUDriverConfigLoadNVRAMEntry(cfg, conf) < 0)
+    if (virQEMUDriverConfigLoadNVRAMEntry(cfg, conf, privileged) < 0)
         return -1;
 
     if (virQEMUDriverConfigLoadGlusterDebugEntry(cfg, conf) < 0)