In case when user provides custom paths (those not covered by the JSON firmware descriptor files or the default locations) for the loader and nvram template no auto-detection will be performed and user's config will be taken at face value. Historically when 'templateFormat' didn't exist we assumed that the 'format' field covers both. Thus if 'templateFormat' is VIR_STORAGE_FILE_NONE we need to skip the check forbidding image format conversion for 'file' backed to avoid breaking legacy configs with manual/non-detected format assuming that user picked the correct format. Add a comment to the declaration of 'nvramTemplateFormat' noting the above for future reference. Resolves: https://issues.redhat.com/browse/RHEL-81731 Fixes: 2aa644a2fc8 Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/domain_conf.h | 7 +++++++ src/qemu/qemu_process.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d4fa79cb84..1fcc3fdb98 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2362,6 +2362,13 @@ struct _virDomainLoaderDef { virStorageSource *nvram; bool newStyleNVRAM; char *nvramTemplate; /* user override of path to master nvram */ + /* Historically it was assumed that the format of the template and the + * actual nvram image are identical, which is no longer true. + * + * Note: if 'nvramTemplate' comes from the user and is not overriden by + * auto-detection nvramTemplateFormat may be VIR_STORAGE_FILE_NONE. Code + * shall assume that the template format matches if it isn't provided. + */ virStorageFileFormat nvramTemplateFormat; }; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0d9b8bcb93..7b7b5c17e3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4709,7 +4709,10 @@ qemuPrepareNVRAMFile(virQEMUDriver *driver, return -1; } - if (loader->nvram->format != loader->nvramTemplateFormat) { + /* If 'nvramTemplateFormat' is empty it means that it's a user-provided + * template which we couldn't verify. Assume the user knows what they're doing */ + if (loader->nvramTemplateFormat != VIR_STORAGE_FILE_NONE && + loader->nvram->format != loader->nvramTemplateFormat) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("conversion of the nvram template to another target format is not supported")); return -1; -- 2.48.1