2009/10/14 Daniel P. Berrange <berrange(a)redhat.com>:
The virDomainObjPtr object stores state about a running domain.
This object is shared across all drivers so it is not appropriate
to include driver specific state here. This patch adds the ability
to request a blob of private data per domain object instance. The
driver must provide a allocator & deallocator for this purpose
THis patch abuses the virCapabilitiesPtr structure for storing the
allocator/deallocator callbacks, since it is already being abused
for other internal things relating to parsing. This should be moved
out into a separate object at some point.
* src/conf/capabilities.h: Add privateDataAllocFunc and
privateDataFreeFunc fields
* src/conf/domain_conf.c: Invoke the driver allocators / deallocators
when creating/freeing virDomainObjPtr instances.
* src/conf/domain_conf.h: Pass virCapsPtr into virDomainAssignDef
to allow access to the driver specific allocator function
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c: Update for
change in virDomainAssignDef contract
---
src/conf/capabilities.h | 2 ++
src/conf/domain_conf.c | 23 +++++++++++++++++++----
src/conf/domain_conf.h | 4 ++++
src/lxc/lxc_driver.c | 6 ++++--
src/opennebula/one_driver.c | 6 ++++--
src/openvz/openvz_driver.c | 6 ++++--
src/qemu/qemu_driver.c | 5 +++++
src/test/test_driver.c | 15 ++++++++++-----
src/uml/uml_driver.c | 2 ++
9 files changed, 54 insertions(+), 15 deletions(-)
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 2f24605..7234cf4 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -115,6 +115,8 @@ struct _virCaps {
virCapsGuestPtr *guests;
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
unsigned int emulatorRequired : 1;
+ void *(*privateDataAllocFunc)(void);
+ void (*privateDataFreeFunc)(void *);
};
Maybe add a comment here that this should be moved out into a separate
object at some point.
ACK.
PS: What's the specific use case for this?
Matthias