libvirt/libvirt-qemuPrepareNVRAMFile-Fix-NVRAM-image-conversion-check.patch
Jiri Denemark 3257a92f4c libvirt-10.10.0-13.el9
- qemuPrepareNVRAMFile: Fix NVRAM image conversion check (RHEL-97758)

Resolves: RHEL-97758
2025-06-18 17:07:22 +02:00

68 lines
2.9 KiB
Diff

From 6e265f4f5faa468497e9bbdd86701d17480fcd38 Mon Sep 17 00:00:00 2001
Message-ID: <6e265f4f5faa468497e9bbdd86701d17480fcd38.1750259242.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-97758
---
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 961b7b056c..20be6f7c05 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 64683ecfe0..a78aa8569d 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