From: Andrea Bolognani Date: Wed, 21 Jan 2026 17:25:37 +0000 (+0100) Subject: qemu_firmware: Generate varstore path when necessary X-Git-Tag: v12.1.0-rc1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dd118cceee833ff905e6c24785a2acda8ccc80b;p=thirdparty%2Flibvirt.git qemu_firmware: Generate varstore path when necessary Introduce qemuFirmwareEnsureVarstore(), which performs the same task as the existing qemuFirmwareEnsureNVRAM() but for the varstore element. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik Acked-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé --- diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 5a07e3181f..d8633c6b28 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1069,6 +1069,38 @@ qemuFirmwareEnsureNVRAM(virDomainDef *def, } +/** + * qemuFirmwareEnsureVarstore: + * @def: domain definition + * @driver: QEMU driver + * + * Make sure that information for the varstore is present. This might + * involve automatically generating the corresponding path. + */ +static void +qemuFirmwareEnsureVarstore(virDomainDef *def, + virQEMUDriver *driver) +{ + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); + virDomainLoaderDef *loader = def->os.loader; + virDomainVarstoreDef *varstore = def->os.varstore; + + if (!loader) + return; + + if (loader->type != VIR_DOMAIN_LOADER_TYPE_ROM) + return; + + if (!varstore) + return; + + if (varstore->path) + return; + + varstore->path = g_strdup_printf("%s/%s.json", + cfg->varstoreDir, def->name); +} + /** * qemuFirmwareSetOsFeatures: @@ -2063,10 +2095,11 @@ qemuFirmwareFillDomain(virQEMUDriver *driver, } } - /* Always ensure that the NVRAM path is present, even if we - * haven't found a match: the configuration might simply be - * referring to a custom firmware build */ + /* Always ensure that the NVRAM/varstore is configured where + * appropriate, even if we haven't found a match: the configuration + * might simply be referring to a custom firmware build */ qemuFirmwareEnsureNVRAM(def, driver, abiUpdate); + qemuFirmwareEnsureVarstore(def, driver); return 0; }