On Wed, Feb 18, 2026 at 01:05:55PM +0100, Andrea Bolognani via Devel wrote:
Simply mimicking what is currently done for NVRAM files works. A few user-visible messages are updated to reflect the fact that they apply both to NVRAM and varstore.
https://issues.redhat.com/browse/RHEL-82645
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_driver.c | 15 ++++++++++----- src/qemu/qemu_process.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9620f737ba..c9e9e970e7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6646,22 +6646,27 @@ qemuDomainUndefineFlags(virDomainPtr dom, } }
- if (vm->def->os.loader && vm->def->os.loader->nvram && - virStorageSourceIsLocalStorage(vm->def->os.loader->nvram)) { - nvram_path = g_strdup(vm->def->os.loader->nvram->path); + if (vm->def->os.loader) { + if (vm->def->os.loader->nvram && + virStorageSourceIsLocalStorage(vm->def->os.loader->nvram)) { + nvram_path = g_strdup(vm->def->os.loader->nvram->path); + } + if (vm->def->os.varstore && vm->def->os.varstore->path) {
"else if" to make it clear these are mutually exclusive scenarios, otherwise a static analyser is liable to complain that the next assignment to nvram_path leaks memory from the previous assignment.
+ nvram_path = g_strdup(vm->def->os.varstore->path); + } }
if (nvram_path && virFileExists(nvram_path)) { if ((flags & VIR_DOMAIN_UNDEFINE_NVRAM)) { if (unlink(nvram_path) < 0) { virReportSystemError(errno, - _("failed to remove nvram: %1$s"), + _("Failed to remove NVRAM/varstore: %1$s"), nvram_path); goto endjob; } } else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot undefine domain with nvram")); + _("Cannot undefine domain with NVRAM/varstore")); goto endjob; } }
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 :|