[libvirt PATCH] qemu_snapshot: fix memory leak when reverting external snapshot

Pavel Hrdina posted 1 patch 4 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/5c6b31ad74da2c67526fe17c2907d8c8478d7be9.1716832935.git.phrdina@redhat.com
src/qemu/qemu_snapshot.c | 4 ++++
1 file changed, 4 insertions(+)
[libvirt PATCH] qemu_snapshot: fix memory leak when reverting external snapshot
Posted by Pavel Hrdina 4 months, 3 weeks ago
The code cleaning up virStorageSource doesn't free data allocated by
virStorageSourceInit() so we need to call virStorageSourceDeinit()
explicitly.

Fixes: 8e664737813378d2a1bdeacc2ca8e942327e2cab
Resolves: https://issues.redhat.com/browse/RHEL-33044
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/qemu/qemu_snapshot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 09ec959f10..f5260c4a22 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2260,6 +2260,8 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm,
                          snapdisk->src->path);
             }
 
+            virStorageSourceDeinit(snapdisk->src);
+
             virDomainSnapshotDiskDefClear(snapdisk);
         }
 
@@ -2277,6 +2279,8 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm,
                 VIR_WARN("Failed to remove snapshot image '%s'",
                          snapdisk->src->path);
             }
+
+            virStorageSourceDeinit(snapdisk->src);
         }
     }
 
-- 
2.45.1
Re: [libvirt PATCH] qemu_snapshot: fix memory leak when reverting external snapshot
Posted by Jiri Denemark 4 months, 3 weeks ago
On Mon, May 27, 2024 at 20:02:39 +0200, Pavel Hrdina wrote:
> The code cleaning up virStorageSource doesn't free data allocated by
> virStorageSourceInit() so we need to call virStorageSourceDeinit()
> explicitly.
> 
> Fixes: 8e664737813378d2a1bdeacc2ca8e942327e2cab
> Resolves: https://issues.redhat.com/browse/RHEL-33044
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/qemu/qemu_snapshot.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
> index 09ec959f10..f5260c4a22 100644
> --- a/src/qemu/qemu_snapshot.c
> +++ b/src/qemu/qemu_snapshot.c
> @@ -2260,6 +2260,8 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm,
>                           snapdisk->src->path);
>              }
>  
> +            virStorageSourceDeinit(snapdisk->src);
> +
>              virDomainSnapshotDiskDefClear(snapdisk);
>          }
>  
> @@ -2277,6 +2279,8 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm,
>                  VIR_WARN("Failed to remove snapshot image '%s'",
>                           snapdisk->src->path);
>              }
> +
> +            virStorageSourceDeinit(snapdisk->src);
>          }
>      }
>  

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>