Re: [PATCH v3 2/4] qemu: block: use the delete flag to delete snapshot images if requested

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 21, 2019 at 11:00:45 +0100, Pavel Mores wrote:
> When blockcommit finishes successfully, one of the
> qemuBlockJobProcessEventCompletedCommit() and
> qemuBlockJobProcessEventCompletedActiveCommit() event handlers is called.
> This is where the delete flag (stored in qemuBlockJobCommitData since the
> previous commit) can actually be used to delete the committed snapshot
> images if requested.
> 
> We use virFileRemove() instead of a simple unlink() to cover the case where
> the image to be removed is on an NFS volume.  To acquire the uid/gid arguments
> for the virFileRemove() call, we call qemuDomainGetImageIds() which was
> previously static in its file so we first have to export it.
> 
> Signed-off-by: Pavel Mores <pmores@xxxxxxxxxx>
> ---
>  src/qemu/qemu_blockjob.c | 39 +++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_domain.c   |  2 +-
>  src/qemu/qemu_domain.h   |  6 ++++++
>  3 files changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
> index 7d94a6ce38..1bf23dac3c 100644
> --- a/src/qemu/qemu_blockjob.c
> +++ b/src/qemu/qemu_blockjob.c
> @@ -965,6 +965,37 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr driver,
>  }
>  
>  
> +/**
> + * Helper for qemuBlockJobProcessEventCompletedCommit() and
> + * qemuBlockJobProcessEventCompletedActiveCommit().  Relies on adjustments
> + * these functions perform on the 'backingStore' chain to function correctly.
> + *
> + * TODO look into removing backing store for non-local snapshots too
> + */
> +static void
> +qemuBlockJobUnlinkCommittedStorage(virQEMUDriverPtr driver,
> +                                   virDomainObjPtr vm,
> +                                   virDomainDiskDefPtr disk,
> +                                   virStorageSourcePtr top)
> +{
> +    virStorageSourcePtr p = top;
> +    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);

The reference acquired here is leaked from this function. You can use
g_autoptr for it.


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux