[PATCH v2 0/2] qemu: Don't complain when <transient/> disk overlay is left behind

v2: - remove the overlay unconditionally - document the overlay filename template Peter Krempa (2): qemu: snapshot: Delete leftover overlay files for <transient/> disks docs: formatdomain: Document the temporary file for transient disks docs/formatdomain.rst | 7 +++++++ src/qemu/qemu_snapshot.c | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) -- 2.47.0

When a VM is terminated by host reboot libvirt doesn't get to cleaning out the temporary overlay file used for transient disks. Since we create those files with a very specific suffix it's almost guaranteed that if it exists it's a leftover from a libvirt run. Delete them instead of complaining to preserve functionality. Closes: https://gitlab.com/libvirt/libvirt/-/issues/684 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_snapshot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 1187ebf276..795522da21 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1287,10 +1287,12 @@ qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk, domdisk->src->path, suffix); if (virFileExists(snapdisk->src->path)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("Overlay file '%1$s' for transient disk '%2$s' already exists"), - snapdisk->src->path, domdisk->dst); - return NULL; + if (unlink(snapdisk->src->path) != 0) { + virReportSystemError(errno, + _("Failed to delete overlay file '%1$s' for transient disk '%2$s'"), + snapdisk->src->path, domdisk->dst); + return NULL; + } } return g_steal_pointer(&snapdisk); -- 2.47.0

Mention that hypervisors may need a temporary file and document the qemu template for creating them. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index e6f09a728f..3253a28e5a 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3479,6 +3479,13 @@ paravirtualized driver is specified via the ``disk`` element. ``shareBacking`` attribute should be set to ``yes``. Note that hypervisor drivers may need to hotplug such disk and thus it works only with configurations supporting hotplug. :since:`Since 7.4.0` + + Hypervisors may need to store a temporary file containing the data written + by the domain while running, which may be stored in the same location + as the original source of the disk (The ``qemu`` driver stores the temporary + files as ``$(origsource).TRANSIENT-$(vmname)``, where ``$(origsource)`` is + the full original path of the disk source and ``$(vmname)`` is the name of the + domain). ``serial`` If present, this specify serial number of virtual hard drive. For example, it may look like ``<serial>WD-WMAP9A966149</serial>``. Not supported for -- 2.47.0

On Fri, Oct 18, 2024 at 04:21:01PM +0200, Peter Krempa wrote:
v2: - remove the overlay unconditionally - document the overlay filename template
Peter Krempa (2): qemu: snapshot: Delete leftover overlay files for <transient/> disks docs: formatdomain: Document the temporary file for transient disks
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrangé
-
Peter Krempa