Re: [libvirt RFC 10/24] qemu_snapshot: extract single snapshot deletion to separate function

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

 



On Tue, Aug 23, 2022 at 18:32:13 +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
> ---
>  src/qemu/qemu_snapshot.c | 46 ++++++++++++++++++++++++++--------------
>  1 file changed, 30 insertions(+), 16 deletions(-)
> 
> diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
> index c1c67ac445..b5e6a87566 100644
> --- a/src/qemu/qemu_snapshot.c
> +++ b/src/qemu/qemu_snapshot.c
> @@ -2281,6 +2281,35 @@ qemuSnapshotChildrenReparent(void *payload,
>  }
>  
>  
> +static int
> +qemuSnapshotDeleteSingle(virDomainObj *vm,
> +                         virDomainMomentObj *snap,
> +                         virQEMUDriver *driver,
> +                         bool metadata_only)
> +{

'driver' can be extracted from the the private data of 'vm', removing
the need to pass it in. Doing that will also remove the need to pass it
in via 'struct qemuSnapshotDeleteAllData' in upcoming patch.

> +    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
> +
> +    if (snap->nchildren) {
> +        virQEMUMomentReparent rep;
> +
> +        rep.dir = cfg->snapshotDir;
> +        rep.parent = snap->parent;
> +        rep.vm = vm;
> +        rep.err = 0;
> +        rep.xmlopt = driver->xmlopt;
> +        rep.writeMetadata = qemuDomainSnapshotWriteMetadata;
> +        virDomainMomentForEachChild(snap,
> +                                    qemuSnapshotChildrenReparent,
> +                                    &rep);
> +        if (rep.err < 0)
> +            return -1;
> +        virDomainMomentMoveChildren(snap, snap->parent);
> +    }
> +
> +    return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);

You actually may be better off refactoring qemuDomainSnapshotDiscard
first to remove the argument.




[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