qemu: Filter firmwares based on format

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>
This commit is contained in:
Andrea Bolognani 2023-01-31 17:46:58 +01:00
parent 9c39840673
commit 0569c6a13c

View File

@ -1171,12 +1171,26 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
flash->executable.format); flash->executable.format);
return false; 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 (flash->mode == QEMU_FIRMWARE_FLASH_MODE_SPLIT) {
if (STRNEQ(flash->nvram_template.format, "raw")) { if (STRNEQ(flash->nvram_template.format, "raw")) {
VIR_DEBUG("Discarding loader with unsupported nvram template format '%s'", VIR_DEBUG("Discarding loader with unsupported nvram template format '%s'",
flash->nvram_template.format); flash->nvram_template.format);
return false; 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; 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++) { for (i = 0; i < cfg->nfirmwares; i++) {
virFirmware *fw = cfg->firmwares[i]; virFirmware *fw = cfg->firmwares[i];