]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Don't pick firmware with unsupported format
authorAndrea Bolognani <abologna@redhat.com>
Fri, 27 Jan 2023 16:39:25 +0000 (17:39 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 3 Mar 2023 12:49:56 +0000 (13:49 +0100)
Right now, if the descriptor with the highest priority happens
to describe a firmware in a format other than raw, no domain
that uses autoselection will be able to start.

A better approach is to filter out descriptors that advertise
unsupported formats during autoselection.

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

index c24bca618368a84d512f6d8c440466107470d768..72036bd82be211a734c1b1a50e6422992f443956 100644 (file)
@@ -1130,6 +1130,19 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
                 return false;
             }
         }
+
+        if (STRNEQ(flash->executable.format, "raw")) {
+            VIR_DEBUG("Discarding loader with unsupported flash format '%s'",
+                      flash->executable.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 (def->sec) {
@@ -1183,24 +1196,10 @@ qemuFirmwareEnableFeatures(virQEMUDriver *driver,
         loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
         loader->readonly = VIR_TRISTATE_BOOL_YES;
 
-        if (STRNEQ(flash->executable.format, "raw")) {
-            virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
-                           _("unsupported flash format '%s'"),
-                           flash->executable.format);
-            return -1;
-        }
-
         VIR_FREE(loader->path);
         loader->path = g_strdup(flash->executable.filename);
 
         if (flash->mode == QEMU_FIRMWARE_FLASH_MODE_SPLIT) {
-            if (STRNEQ(flash->nvram_template.format, "raw")) {
-                virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
-                               _("unsupported nvram template format '%s'"),
-                               flash->nvram_template.format);
-                return -1;
-            }
-
             if (!loader->nvram) {
                 loader->nvram = virStorageSourceNew();
                 loader->nvram->type = VIR_STORAGE_TYPE_FILE;