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.
DONOTMERGE: The extended syntax has not been accepted into the
official spec yet.
Signed-off-by: Andrea Bolognani <[email protected]>
---
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 fff6c81177..f41c09db72 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