Now that we have made virDomainMomentObj sufficiently generic to
support both snapshots and checkpoints, it is time to rename the file
that it lives in. The split between a generic object and a list of the
generic objects doesn't buy us as much, so it will be easier to stick
all the moment list code in one file, with more code moving in the
next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
...snapshotobj.h => virdomainmomentobjlist.h} | 26 ++++++++++---------
src/conf/virdomainsnapshotobjlist.h | 7 ++++-
src/conf/Makefile.inc.am | 4 +--
...snapshotobj.c => virdomainmomentobjlist.c} | 12 ++++-----
src/libvirt_private.syms | 18 ++++++-------
5 files changed, 37 insertions(+), 30 deletions(-)
rename src/conf/{virdomainsnapshotobj.h => virdomainmomentobjlist.h} (72%)
rename src/conf/{virdomainsnapshotobj.c => virdomainmomentobjlist.c} (95%)
diff --git a/src/conf/virdomainsnapshotobj.h b/src/conf/virdomainmomentobjlist.h
similarity index 72%
rename from src/conf/virdomainsnapshotobj.h
rename to src/conf/virdomainmomentobjlist.h
index 86c5f6860b..dceb55fca2 100644
--- a/src/conf/virdomainsnapshotobj.h
+++ b/src/conf/virdomainmomentobjlist.h
@@ -1,5 +1,5 @@
/*
- * virdomainsnapshotobj.h: handle snapshot objects
+ * virdomainmomentobjlist.h: handle a tree of moment objects
* (derived from snapshot_conf.h)
*
* Copyright (C) 2006-2019 Red Hat, Inc.
@@ -20,25 +20,33 @@
* <http://www.gnu.org/licenses/>.
*/
-#ifndef LIBVIRT_VIRDOMAINSNAPSHOTOBJ_H
-# define LIBVIRT_VIRDOMAINSNAPSHOTOBJ_H
+#ifndef LIBVIRT_VIRDOMAINMOMENTOBJLIST_H
+# define LIBVIRT_VIRDOMAINMOMENTOBJLIST_H
# include "internal.h"
# include "virconftypes.h"
# include "virhash.h"
+/* Struct that allows tracing hierarchical relationships between
+ * multiple virDomainMoment objects. The opaque type
+ * virDomainMomentObjList then maintains both a hash of these structs
+ * (for quick lookup by name) and a metaroot (which is the parent of
+ * all user-visible roots), so that all other objects always have a
+ * valid parent object; the tree structure is currently maintained via
+ * a linked list. */
struct _virDomainMomentObj {
+ /* Public field */
virDomainMomentDefPtr def; /* non-NULL except for metaroot */
+ /* Private fields, use accessors instead */
virDomainMomentObjPtr parent; /* non-NULL except for metaroot, before
- virDomainSnapshotUpdateRelations, or
+ virDomainMomentUpdateRelations, or
after virDomainMomentDropParent */
virDomainMomentObjPtr sibling; /* NULL if last child of parent */
size_t nchildren;
virDomainMomentObjPtr first_child; /* NULL if no children */
};
-
int virDomainMomentForEachChild(virDomainMomentObjPtr moment,
virHashIterator iter,
void *data);
@@ -52,10 +60,4 @@ void virDomainMomentMoveChildren(virDomainMomentObjPtr from,
void virDomainMomentSetParent(virDomainMomentObjPtr moment,
virDomainMomentObjPtr parent);
-static inline virDomainSnapshotDefPtr
-virDomainSnapshotObjGetDef(virDomainMomentObjPtr obj)
-{
- return (virDomainSnapshotDefPtr) obj->def;
-}
-
-#endif /* LIBVIRT_VIRDOMAINSNAPSHOTOBJ_H */
+#endif /* LIBVIRT_VIRDOMAINMOMENTOBJLIST_H */
diff --git a/src/conf/virdomainsnapshotobjlist.h b/src/conf/virdomainsnapshotobjlist.h
index 1af367639d..c36b498751 100644
--- a/src/conf/virdomainsnapshotobjlist.h
+++ b/src/conf/virdomainsnapshotobjlist.h
@@ -24,7 +24,7 @@
# define LIBVIRT_VIRDOMAINSNAPSHOTOBJLIST_H
# include "internal.h"
-# include "virdomainsnapshotobj.h"
+# include "virdomainmomentobjlist.h"
# include "virbuffer.h"
/* Filter that returns true if a given moment matches the filter flags */
@@ -80,4 +80,9 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotPtr **snaps,
unsigned int flags);
+static inline virDomainSnapshotDefPtr
+virDomainSnapshotObjGetDef(virDomainMomentObjPtr obj)
+{
+ return (virDomainSnapshotDefPtr) obj->def;
+}
#endif /* LIBVIRT_VIRDOMAINSNAPSHOTOBJLIST_H */
diff --git a/src/conf/Makefile.inc.am b/src/conf/Makefile.inc.am
index d2ff8be8fd..6eb64db9de 100644
--- a/src/conf/Makefile.inc.am
+++ b/src/conf/Makefile.inc.am
@@ -31,8 +31,8 @@ DOMAIN_CONF_SOURCES = \
conf/virconftypes.h \
conf/virdomainobjlist.c \
conf/virdomainobjlist.h \
- conf/virdomainsnapshotobj.c \
- conf/virdomainsnapshotobj.h \
+ conf/virdomainmomentobjlist.c \
+ conf/virdomainmomentobjlist.h \
conf/virdomainsnapshotobjlist.c \
conf/virdomainsnapshotobjlist.h \
$(NULL)
diff --git a/src/conf/virdomainsnapshotobj.c b/src/conf/virdomainmomentobjlist.c
similarity index 95%
rename from src/conf/virdomainsnapshotobj.c
rename to src/conf/virdomainmomentobjlist.c
index 877a0a9079..766d7fe2e4 100644
--- a/src/conf/virdomainsnapshotobj.c
+++ b/src/conf/virdomainmomentobjlist.c
@@ -1,5 +1,5 @@
/*
- * virdomainsnapshotobj.c: handle snapshot objects
+ * virdomainmomentobjlist.c: handle snapshot/checkpoint objects
* (derived from snapshot_conf.c)
*
* Copyright (C) 2006-2019 Red Hat, Inc.
@@ -23,15 +23,15 @@
#include <config.h>
#include "internal.h"
-#include "virdomainsnapshotobj.h"
-#include "snapshot_conf.h"
-#include "virdomainsnapshotobjlist.h"
+#include "virdomainmomentobjlist.h"
#include "virlog.h"
#include "virerror.h"
+#include "virstring.h"
+#include "moment_conf.h"
-#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT
+#define VIR_FROM_THIS VIR_FROM_DOMAIN
-VIR_LOG_INIT("conf.virdomainsnapshotobj");
+VIR_LOG_INIT("conf.virdomainmomentobjlist");
/* Run iter(data) on all direct children of moment, while ignoring all
* other entries in moments. Return the number of children
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 02f383fdba..10cdfad4fd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -960,6 +960,15 @@ virChrdevFree;
virChrdevOpen;
+# conf/virdomainmomentobjlist.h
+virDomainMomentDropChildren;
+virDomainMomentDropParent;
+virDomainMomentForEachChild;
+virDomainMomentForEachDescendant;
+virDomainMomentMoveChildren;
+virDomainMomentSetParent;
+
+
# conf/virdomainobjlist.h
virDomainObjListAdd;
virDomainObjListCollect;
@@ -979,15 +988,6 @@ virDomainObjListRemoveLocked;
virDomainObjListRename;
-# conf/virdomainsnapshotobj.h
-virDomainMomentDropChildren;
-virDomainMomentDropParent;
-virDomainMomentForEachChild;
-virDomainMomentForEachDescendant;
-virDomainMomentMoveChildren;
-virDomainMomentSetParent;
-
-
# conf/virdomainsnapshotobjlist.h
virDomainListSnapshots;
virDomainSnapshotAssignDef;
--
2.20.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 3/20/19 1:41 AM, Eric Blake wrote:
> Now that we have made virDomainMomentObj sufficiently generic to
> support both snapshots and checkpoints, it is time to rename the file
> that it lives in. The split between a generic object and a list of the
> generic objects doesn't buy us as much, so it will be easier to stick
> all the moment list code in one file, with more code moving in the
> next patch.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> ...snapshotobj.h => virdomainmomentobjlist.h} | 26 ++++++++++---------
> src/conf/virdomainsnapshotobjlist.h | 7 ++++-
> src/conf/Makefile.inc.am | 4 +--
> ...snapshotobj.c => virdomainmomentobjlist.c} | 12 ++++-----
> src/libvirt_private.syms | 18 ++++++-------
> 5 files changed, 37 insertions(+), 30 deletions(-)
> rename src/conf/{virdomainsnapshotobj.h => virdomainmomentobjlist.h} (72%)
> rename src/conf/{virdomainsnapshotobj.c => virdomainmomentobjlist.c} (95%)
>
I have to say it's "weird" the order that occurs in gitk and the patches
is different... IIRC you have some hook that places the .h files up
front in the sent patch, but for some reason gitk has it's own freaking
mind /-|
Reviewed-by: John Ferlan <jferlan@redhat.com>
John
> diff --git a/src/conf/virdomainsnapshotobj.c b/src/conf/virdomainmomentobjlist.c
> similarity index 95%
> rename from src/conf/virdomainsnapshotobj.c
> rename to src/conf/virdomainmomentobjlist.c
> index 877a0a9079..766d7fe2e4 100644
> --- a/src/conf/virdomainsnapshotobj.c
> +++ b/src/conf/virdomainmomentobjlist.c
> @@ -1,5 +1,5 @@
> /*
> - * virdomainsnapshotobj.c: handle snapshot objects
> + * virdomainmomentobjlist.c: handle snapshot/checkpoint objects
> * (derived from snapshot_conf.c)
> *
> * Copyright (C) 2006-2019 Red Hat, Inc.
> @@ -23,15 +23,15 @@
> #include <config.h>
>
> #include "internal.h"
> -#include "virdomainsnapshotobj.h"
> -#include "snapshot_conf.h"
> -#include "virdomainsnapshotobjlist.h"
> +#include "virdomainmomentobjlist.h"
> #include "virlog.h"
> #include "virerror.h"
> +#include "virstring.h"
> +#include "moment_conf.h"
>
> -#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT
> +#define VIR_FROM_THIS VIR_FROM_DOMAIN
Hmm... Almost feels like we should have a VIR_FROM_DOMAIN_MOMENT, but
there's only one virReportError and it's a hash lookup. Maybe something
for the future.
>
> -VIR_LOG_INIT("conf.virdomainsnapshotobj");
> +VIR_LOG_INIT("conf.virdomainmomentobjlist");
>
> /* Run iter(data) on all direct children of moment, while ignoring all
> * other entries in moments. Return the number of children
[...]
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 3/21/19 6:56 PM, John Ferlan wrote:
>
>
> On 3/20/19 1:41 AM, Eric Blake wrote:
>> Now that we have made virDomainMomentObj sufficiently generic to
>> support both snapshots and checkpoints, it is time to rename the file
>> that it lives in. The split between a generic object and a list of the
>> generic objects doesn't buy us as much, so it will be easier to stick
>> all the moment list code in one file, with more code moving in the
>> next patch.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>> ...snapshotobj.h => virdomainmomentobjlist.h} | 26 ++++++++++---------
>> src/conf/virdomainsnapshotobjlist.h | 7 ++++-
>> src/conf/Makefile.inc.am | 4 +--
>> ...snapshotobj.c => virdomainmomentobjlist.c} | 12 ++++-----
>> src/libvirt_private.syms | 18 ++++++-------
>> 5 files changed, 37 insertions(+), 30 deletions(-)
>> rename src/conf/{virdomainsnapshotobj.h => virdomainmomentobjlist.h} (72%)
>> rename src/conf/{virdomainsnapshotobj.c => virdomainmomentobjlist.c} (95%)
>>
>
> I have to say it's "weird" the order that occurs in gitk and the patches
> is different... IIRC you have some hook that places the .h files up
> front in the sent patch, but for some reason gitk has it's own freaking
> mind /-|
Teach gitk who's boss:
$ echo /.order >> .git/info/exclude
$ git config diff.orderFile .order
$ cat > .order <<\EOF
*err*
*.h
*
$
Now, any diff you perform in your directory will hoist error files
first, .h second, and all remaining files at the end. Make .order as
fancy as you want for favoring particular files earlier, if it makes
reviews easier to see certain files first.
>>
>> -#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT
>> +#define VIR_FROM_THIS VIR_FROM_DOMAIN
>
> Hmm... Almost feels like we should have a VIR_FROM_DOMAIN_MOMENT, but
> there's only one virReportError and it's a hash lookup. Maybe something
> for the future.
Well, 'moment' is an internal implementation detail, so external users
aren't going to benefit from it. And when the code is shared between
snapshot and checkpoint, reporting a "domain snapshot" error on a
checkpoint object is going to sound weird, but reporting a "domain"
error for either a snapshot or a checkpoint associated with a domain
sounds plausible.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.