qemu: Don't pick firmware with unsupported format

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>
This commit is contained in:
Andrea Bolognani 2023-01-27 17:39:25 +01:00
parent 22d0b644de
commit 4b2d79fa7f

View 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;