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@xxxxxxxxxx> --- 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
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list