]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Filter firmwares based on format
authorAndrea Bolognani <abologna@redhat.com>
Tue, 31 Jan 2023 16:46:58 +0000 (17:46 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 3 Mar 2023 12:51:04 +0000 (13:51 +0100)
If the user has requested a specific firmware format, then
all firmware builds that are not in that format should be
ignored while looking for matches.

The legacy hardcoded firmware list predates firmware
descriptors and their "format" field, so we can safely
assume that all builds listed in there are in raw format.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_firmware.c

index be6d8d451905b55facb27b1272e0d5e2f5dcbc83..a0167f860c95e9008425eec4042243b838ead8e0 100644 (file)
@@ -1171,12 +1171,26 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
                       flash->executable.format);
             return false;
         }
+        if (loader &&
+            STRNEQ(flash->executable.format, virStorageFileFormatTypeToString(loader->format))) {
+            VIR_DEBUG("Discarding loader with mismatching flash format '%s' != '%s'",
+                      flash->executable.format,
+                      virStorageFileFormatTypeToString(loader->format));
+            return false;
+        }
         if (flash->mode == QEMU_FIRMWARE_FLASH_MODE_SPLIT) {
             if (STRNEQ(flash->nvram_template.format, "raw")) {
                 VIR_DEBUG("Discarding loader with unsupported nvram template format '%s'",
                           flash->nvram_template.format);
                 return false;
             }
+            if (loader && loader->nvram &&
+                STRNEQ(flash->nvram_template.format, virStorageFileFormatTypeToString(loader->nvram->format))) {
+                VIR_DEBUG("Discarding loader with mismatching nvram template format '%s' != '%s'",
+                          flash->nvram_template.format,
+                          virStorageFileFormatTypeToString(loader->nvram->format));
+                return false;
+            }
         }
     }
 
@@ -1424,6 +1438,12 @@ qemuFirmwareFillDomainLegacy(virQEMUDriver *driver,
         return 0;
     }
 
+    if (loader->format != VIR_STORAGE_FILE_RAW) {
+        VIR_DEBUG("Ignoring legacy entries for loader with flash format '%s'",
+                  virStorageFileFormatTypeToString(loader->format));
+        return 1;
+    }
+
     for (i = 0; i < cfg->nfirmwares; i++) {
         virFirmware *fw = cfg->firmwares[i];