libvirt/SOURCES/libvirt-qemuPrepareNVRAMFile-Fix-NVRAM-image-conversion-check.patch

68 lines
2.9 KiB
Diff

From 164d32e435c715b71b0d604d3f4e2d09ceb52bac Mon Sep 17 00:00:00 2001
Message-ID: <164d32e435c715b71b0d604d3f4e2d09ceb52bac.1750849847.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Fri, 28 Feb 2025 14:00:23 +0100
Subject: [PATCH] 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>
(cherry picked from commit e088895a6246ac3b7f160e1895f2940c4b13b0cc)
https://issues.redhat.com/browse/RHEL-97757
---
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 2d38e8fa51..10b00e2403 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2361,6 +2361,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 16b8991c3c..8bddb415ac 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4727,7 +4727,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.49.0