1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

qemuPrepareNVRAMFile: Fix NVRAM image conversion check

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@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Peter Krempa 2025-02-28 14:00:23 +01:00
parent a479c3465e
commit e088895a62
2 changed files with 11 additions and 1 deletions

View File

@ -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;
};

View File

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