[PATCH] qemuDomainRestoreInternal: Preserve error on cleanup path
From: Peter Krempa <pkrempa@redhat.com> Preserve the error on cleanup path as cleanup of the 'libivrt_iohelper' process may overwrite it with an unactionable error, such as when attempting to restore a save image while the VM is already running: $ virsh list Id Name State -------------------------- 9 cd running $ virsh restore /tmp/cd.save error: Failed to restore domain from /tmp/cd.save error: internal error: Child process (LIBVIRT_LOG_OUTPUTS=1:stderr /home/pipo/build/libvirt/gcc/src/libvirt_iohelper /tmp/cd.save 0) unexpected fatal signal 13 After this patch the original error is reported: $ virsh restore /tmp/cd.save error: Failed to restore domain from /tmp/cd.save error: Requested operation is not valid: domain 'cd' is already active Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 61d95bfbbf..25ba6695bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5985,6 +5985,7 @@ qemuDomainRestoreInternal(virQEMUDriver *driver, bool sparse = false; bool bypass_cache = (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0; g_autoptr(qemuMigrationParams) restoreParams = NULL; + virErrorPtr save_err = NULL; virCheckFlags(QEMU_DOMAIN_RESTORE_FLAGS, -1); @@ -6109,6 +6110,7 @@ qemuDomainRestoreInternal(virQEMUDriver *driver, qemuProcessEndJob(vmNew); cleanup: + virErrorPreserveLast(&save_err); VIR_FORCE_CLOSE(fd); if (virFileWrapperFdClose(wrapperFd) < 0) ret = -1; @@ -6117,6 +6119,7 @@ qemuDomainRestoreInternal(virQEMUDriver *driver, if (vmNew && ret < 0) qemuDomainRemoveInactive(vmNew, 0, false); virDomainObjEndAPI(&vmNew); + virErrorRestore(&save_err); return ret; } -- 2.55.0
On Tue, Aug 18, 2026 at 05:16:33PM +0200, Peter Krempa via Devel wrote:
From: Peter Krempa <pkrempa@redhat.com>
Preserve the error on cleanup path as cleanup of the 'libivrt_iohelper'
s/libivrt_iohelper/libvirt_iohelper/
process may overwrite it with an unactionable error, such as when attempting to restore a save image while the VM is already running:
$ virsh list Id Name State -------------------------- 9 cd running
$ virsh restore /tmp/cd.save error: Failed to restore domain from /tmp/cd.save error: internal error: Child process (LIBVIRT_LOG_OUTPUTS=1:stderr /home/pipo/build/libvirt/gcc/src/libvirt_iohelper /tmp/cd.save 0) unexpected fatal signal 13
After this patch the original error is reported:
$ virsh restore /tmp/cd.save error: Failed to restore domain from /tmp/cd.save error: Requested operation is not valid: domain 'cd' is already active
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 3 +++ 1 file changed, 3 insertions(+)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
On Tue, Aug 18, 2026 at 05:16:33PM +0200, Peter Krempa via Devel wrote:
From: Peter Krempa <pkrempa@redhat.com>
Preserve the error on cleanup path as cleanup of the 'libivrt_iohelper' process may overwrite it with an unactionable error, such as when attempting to restore a save image while the VM is already running:
$ virsh list Id Name State -------------------------- 9 cd running
$ virsh restore /tmp/cd.save error: Failed to restore domain from /tmp/cd.save error: internal error: Child process (LIBVIRT_LOG_OUTPUTS=1:stderr /home/pipo/build/libvirt/gcc/src/libvirt_iohelper /tmp/cd.save 0) unexpected fatal signal 13
After this patch the original error is reported:
$ virsh restore /tmp/cd.save error: Failed to restore domain from /tmp/cd.save error: Requested operation is not valid: domain 'cd' is already active
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
--- src/qemu/qemu_driver.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 61d95bfbbf..25ba6695bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5985,6 +5985,7 @@ qemuDomainRestoreInternal(virQEMUDriver *driver, bool sparse = false; bool bypass_cache = (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0; g_autoptr(qemuMigrationParams) restoreParams = NULL; + virErrorPtr save_err = NULL;
virCheckFlags(QEMU_DOMAIN_RESTORE_FLAGS, -1);
@@ -6109,6 +6110,7 @@ qemuDomainRestoreInternal(virQEMUDriver *driver, qemuProcessEndJob(vmNew);
cleanup: + virErrorPreserveLast(&save_err); VIR_FORCE_CLOSE(fd); if (virFileWrapperFdClose(wrapperFd) < 0) ret = -1; @@ -6117,6 +6119,7 @@ qemuDomainRestoreInternal(virQEMUDriver *driver, if (vmNew && ret < 0) qemuDomainRemoveInactive(vmNew, 0, false); virDomainObjEndAPI(&vmNew); + virErrorRestore(&save_err); return ret; }
-- 2.55.0
I appreciate the detailed exploration of preserving errors in the cleanup path within `qemuDomainRestoreInternal`. It's crucial to maintain a robust error handling mechanism, especially given the complexities involved in virtualization. I wonder if you’ve considered implementing log levels that could help developers better diagnose issues as they arise? Improved logging can significantly enhance troubleshooting efforts. Looking forward to seeing how this discussion evolves! https://snowrider3d.com
participants (4)
-
Martin Kletzander -
nicklesteele532@gmail.com -
Pavel Hrdina -
Peter Krempa