[PATCH v3 19/38] qemu_firmware: Support extended syntax for ROM firmware descriptors

Andrea Bolognani via Devel posted 38 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH v3 19/38] qemu_firmware: Support extended syntax for ROM firmware descriptors
Posted by Andrea Bolognani via Devel 1 week, 5 days ago
The existing syntax can only describe stateless firmware builds,
while the extended one can additionally describe builds intended
for use with the uefi-vars device. This involves including the
path to the corresponding varstore template.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_firmware.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 4b2155f311..f64ea287b4 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -95,6 +95,7 @@ struct _qemuFirmwareMappingFlash {
 typedef struct _qemuFirmwareMappingMemory qemuFirmwareMappingMemory;
 struct _qemuFirmwareMappingMemory {
     char *filename;
+    char *template;
 };
 
 
@@ -219,6 +220,7 @@ static void
 qemuFirmwareMappingMemoryFreeContent(qemuFirmwareMappingMemory *memory)
 {
     g_free(memory->filename);
+    g_free(memory->template);
 }
 
 
@@ -406,7 +408,11 @@ qemuFirmwareMappingMemoryParse(const char *path,
                                virJSONValue *doc,
                                qemuFirmwareMappingMemory *memory)
 {
+    virJSONValue *uefi_vars;
     const char *filename;
+    const char *template;
+
+    uefi_vars = virJSONValueObjectGet(doc, "uefi-vars");
 
     if (!(filename = virJSONValueObjectGetString(doc, "filename"))) {
         VIR_DEBUG("missing 'filename' in '%s'", path);
@@ -415,6 +421,15 @@ qemuFirmwareMappingMemoryParse(const char *path,
 
     memory->filename = g_strdup(filename);
 
+    if (uefi_vars) {
+        if (!(template = virJSONValueObjectGetString(uefi_vars, "template"))) {
+            VIR_DEBUG("missing 'template' for 'uefi-vars' in '%s'", path);
+            return -1;
+        }
+
+        memory->template = g_strdup(template);
+    }
+
     return 0;
 }
 
@@ -702,6 +717,20 @@ qemuFirmwareMappingMemoryFormat(virJSONValue *mapping,
                                        memory->filename) < 0)
         return -1;
 
+    if (memory->template) {
+        g_autoptr(virJSONValue) uefi_vars = virJSONValueNewObject();
+
+        if (virJSONValueObjectAppendString(uefi_vars,
+                                           "template",
+                                           memory->template) < 0)
+            return -1;
+
+        if (virJSONValueObjectAppend(mapping,
+                                     "uefi-vars",
+                                     &uefi_vars) < 0)
+            return -1;
+    }
+
     return 0;
 }
 
-- 
2.53.0
Re: [PATCH v3 19/38] qemu_firmware: Support extended syntax for ROM firmware descriptors
Posted by Daniel P. Berrangé via Devel 1 week ago
On Wed, Feb 18, 2026 at 01:05:42PM +0100, Andrea Bolognani via Devel wrote:
> The existing syntax can only describe stateless firmware builds,
> while the extended one can additionally describe builds intended
> for use with the uefi-vars device. This involves including the
> path to the corresponding varstore template.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/qemu/qemu_firmware.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|