[libvirt] [PATCH v10 09/19] backup: Allow for lists of checkpoint objects

Daniel P. Berrangé berrange at redhat.com
Wed Jul 24 16:15:08 UTC 2019


On Wed, Jul 24, 2019 at 12:55:59AM -0500, Eric Blake wrote:
> Create a new file for managing a list of checkpoint objects, borrowing
> heavily from existing virDomainSnapshotObjList paradigms.
> 
> Note that while snapshots definitely have a use case for multiple
> children to a single parent (create a base snapshot, create a child
> snapshot, revert to the base, then create another child snapshot),
> it's harder to predict how checkpoints will play out with reverting to
> prior points in time. Thus, in initial use, given a list of
> checkpoints, you never have more than one child, and we can treat the
> most-recent leaf node as the parent of the next node creation, without
> having to expose a notion of a current node in XML or public API.
> However, as the snapshot machinery is already generic, it is easier to
> reuse the generic machinery that tracks relations between domain
> moments than it is to open-code a new list-management scheme just for
> checkpoints (hence, we still have internal functions related to a
> current checkpoint, even though that has no observable effect
> externally).
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  src/conf/checkpoint_conf.h            |   7 +
>  src/conf/domain_conf.h                |   2 +
>  src/conf/virconftypes.h               |   6 +
>  src/conf/virdomaincheckpointobjlist.h |  72 ++++++++
>  src/conf/virdomainmomentobjlist.h     |   1 +
>  src/conf/virdomainobjlist.h           |   7 +-
>  src/conf/Makefile.inc.am              |   2 +
>  src/conf/checkpoint_conf.c            |  62 +++++++
>  src/conf/domain_conf.c                |   6 +
>  src/conf/virdomaincheckpointobjlist.c | 243 ++++++++++++++++++++++++++
>  src/conf/virdomainmomentobjlist.c     |  17 +-
>  src/conf/virdomainobjlist.c           |  11 ++
>  src/libvirt_private.syms              |  19 ++
>  13 files changed, 453 insertions(+), 2 deletions(-)
>  create mode 100644 src/conf/virdomaincheckpointobjlist.h
>  create mode 100644 src/conf/virdomaincheckpointobjlist.c

I probably would have split the patch in two - first introducing
the virDomainCheckpointObjListPtr and APIs, the second doing the
virDomainObj integration, but that's not a big deal.

Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>


> diff --git a/src/conf/virdomaincheckpointobjlist.h b/src/conf/virdomaincheckpointobjlist.h
> new file mode 100644
> index 0000000000..3a51a46e68
> --- /dev/null
> +++ b/src/conf/virdomaincheckpointobjlist.h
> @@ -0,0 +1,72 @@
> +/*
> + * virdomaincheckpointobjlist.h: handle a tree of checkpoint objects
> + *                  (derived from virdomainsnapshotobjlist.h)
> + *
> + * Copyright (C) 2006-2019 Red Hat, Inc.
> + * Copyright (C) 2006-2008 Daniel P. Berrange
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library.  If not, see
> + * <http://www.gnu.org/licenses/>.
> + */
> +
> +#pragma once
> +
> +#include "internal.h"
> +#include "virdomainmomentobjlist.h"
> +#include "virbuffer.h"
> +
> +virDomainCheckpointObjListPtr virDomainCheckpointObjListNew(void);
> +void virDomainCheckpointObjListFree(virDomainCheckpointObjListPtr checkpoints);
> +
> +virDomainMomentObjPtr virDomainCheckpointAssignDef(virDomainCheckpointObjListPtr checkpoints,
> +                                                   virDomainCheckpointDefPtr def);
> +
> +virDomainMomentObjPtr virDomainCheckpointFindByName(virDomainCheckpointObjListPtr checkpoints,
> +                                                    const char *name);
> +virDomainMomentObjPtr virDomainCheckpointGetCurrent(virDomainCheckpointObjListPtr checkpoints);
> +const char *virDomainCheckpointGetCurrentName(virDomainCheckpointObjListPtr checkpoints);
> +void virDomainCheckpointSetCurrent(virDomainCheckpointObjListPtr checkpoints,
> +                                   virDomainMomentObjPtr checkpoint);
> +bool virDomainCheckpointObjListRemove(virDomainCheckpointObjListPtr checkpoints,
> +                                      virDomainMomentObjPtr checkpoint);
> +void virDomainCheckpointObjListRemoveAll(virDomainCheckpointObjListPtr checkpoints);
> +int virDomainCheckpointForEach(virDomainCheckpointObjListPtr checkpoints,
> +                               virHashIterator iter,
> +                               void *data);
> +void virDomainCheckpointLinkParent(virDomainCheckpointObjListPtr checkpoints,
> +                                   virDomainMomentObjPtr chk);
> +int virDomainCheckpointUpdateRelations(virDomainCheckpointObjListPtr checkpoints,
> +                                       virDomainMomentObjPtr *leaf);
> +int virDomainCheckpointCheckCycles(virDomainCheckpointObjListPtr checkpoints,
> +                                   virDomainCheckpointDefPtr def,
> +                                   const char *domname);

I'd suggest putting the return types all on a separate line
so these don't get so wide.


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 :|




More information about the libvir-list mailing list