[libvirt] [PATCH v6 7/8] snapshot: Create virDomainMoment base class

Ján Tomko jtomko at redhat.com
Fri Mar 15 13:34:02 UTC 2019


On Fri, Mar 15, 2019 at 12:02:32AM -0500, Eric Blake wrote:
>Upcoming patches want to add virDomainCheckpoint that behaves very
>similarly to virDomainCheckpoint; th eeasiest way to share common code
>is to give both classes a common base class.  Thanks to the accessor
>functions in the previous patch, we have very few changes required
>outside of datatypes.[ch].  This also gets rid of the temporary rename
>hack that the previous patch used for compiler verification.
>
>Note that virClassNew() supports a NULL dispose method for a class
>that has nothing to clean up, but VIR_CLASS_NEW has no easy way to
>register such a class without a #define hack.
>
>I promised my teenage daughter Evelyn that I'd give her credit for her
>contribution to this commit. I asked her "What would be a good name
>for a base class for DomainSnapshot and DomainCheckpoint". After
>explaining what a base class was (using the classic OOB Square and
>Circle inherit from Shape), she came up with "DomainMoment", which is
>way better than my initial thought of "DomainPointInTime" or
>"DomainPIT".
>

Naming-suggested-by: Evelyn

>Signed-off-by: Eric Blake <eblake at redhat.com>
>---
> src/datatypes.h               |  23 +++++--
> src/datatypes.c               | 110 ++++++++++++++++++++--------------
> src/libvirt-domain-snapshot.c |   2 +-
> 3 files changed, 85 insertions(+), 50 deletions(-)
>
>diff --git a/src/datatypes.h b/src/datatypes.h
>index dcba279bec..b675251500 100644
>--- a/src/datatypes.h
>+++ b/src/datatypes.h
>@@ -31,6 +31,7 @@
>
> extern virClassPtr virConnectClass;
> extern virClassPtr virDomainClass;
>+extern virClassPtr virDomainMomentClass;
> extern virClassPtr virDomainSnapshotClass;
> extern virClassPtr virInterfaceClass;
> extern virClassPtr virNetworkClass;
>@@ -668,27 +669,39 @@ struct _virStream {
>     virFreeCallback ff;
> };
>
>+/**
>+ * _virDomainMoment
>+ *
>+ * Internal abstract structure serving as a base class to a named
>+ * point in time object related to a domain
>+ */
>+typedef struct _virDomainMoment virDomainMoment;
>+typedef virDomainMoment *virDomainMomentPtr;
>+struct _virDomainMoment {
>+    virObject parent;
>+    char *name;
>+    virDomainPtr domain;
>+};
>+
> /**
>  * _virDomainSnapshot
>  *
>  * Internal structure associated with a domain snapshot
>  */
> struct _virDomainSnapshot {
>-    virObject parent;
>-    char *_name;
>-    virDomainPtr _domain;
>+    virDomainMoment parent;

This breaks the test suite, saying:
error : object size 32 of virDomainSnapshot is smaller than parent class 32

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190315/895e4c1e/attachment-0001.sig>


More information about the libvir-list mailing list