[libvirt PATCH 14/30] qemu_snapshot: introduce qemuSnapshotDeleteChildren
Peter Krempa
pkrempa at redhat.com
Tue Dec 13 13:14:13 UTC 2022
On Thu, Dec 08, 2022 at 14:30:50 +0100, Pavel Hrdina wrote:
> Extract code that deletes children of specific snapshot to separate
> function.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> src/qemu/qemu_snapshot.c | 108 ++++++++++++++++++++++++---------------
> 1 file changed, 67 insertions(+), 41 deletions(-)
>
> diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
> index 47239e9e9c..3d5467457b 100644
> --- a/src/qemu/qemu_snapshot.c
> +++ b/src/qemu/qemu_snapshot.c
> @@ -2311,18 +2311,76 @@ qemuSnapshotDeleteSingle(virDomainObj *vm,
> }
>
>
> -int
> -qemuSnapshotDelete(virDomainObj *vm,
> - virDomainSnapshotPtr snapshot,
> - unsigned int flags)
> +/**
> + * qemuSnapshotDeleteChildren:
> + * @vm: domain object
> + * @snap: snapshot object
> + * @metadata_only: boolean
'boolean' is quite obvious from the function prototype, but it's not
that obvious what it actually means.
@metadata_only: If true, delete only snapshot metadata, leave data
intact.
> + * @flags: bitwise-OR of virDomainSnapshotDeleteFlags
In fact the only thing you use from @flags is
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY. Additionally you already
pass 'metadata_only' as boolean which is originally also part of 'flags.
Preferrably extract VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY as a
boolean too and pass it to this function instead of flags.
> + *
> + * Delete children snapshots of snapshot proved by @snap. Based on what @flags
s/proved/provided/ ?
> + * are provided it will delete children snapshots including @snap or only
> + * children snapshots. If @metadata_only is true only libvirt metadata files
> + * are deleted but the actual snapshots are left intact.
> + *
> + * Returns 0 on success, -1 on error.
> + */
> +static int
> +qemuSnapshotDeleteChildren(virDomainObj *vm,
> + virDomainMomentObj *snap,
> + bool metadata_only,
> + unsigned int flags)
With the above:
Reviewed-by: Peter Krempa <pkrempa at redhat.com>
More information about the libvir-list
mailing list