Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/vz/vz_driver.c | 7 ++++++- src/vz/vz_sdk.c | 13 ------------- src/vz/vz_sdk.h | 2 -- src/vz/vz_utils.c | 34 ++++++++++++++++++++++++++-------- src/vz/vz_utils.h | 3 +++ 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 01dd204..8abf6f1 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -294,6 +294,10 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, return ret; } +static virDomainXMLPrivateDataCallbacks vzDomainXMLPrivateDataCallbacksPtr = { + .alloc = vzDomObjAlloc, + .free = vzDomObjFree, +}; static virDomainDefParserConfig vzDomainDefParserConfig = { .macPrefix = {0x42, 0x1C, 0x00}, @@ -316,7 +320,8 @@ vzDriverObjNew(void) if (!(driver->caps = vzBuildCapabilities()) || !(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig, - NULL, NULL)) || + &vzDomainXMLPrivateDataCallbacksPtr, + NULL)) || !(driver->domains = virDomainObjListNew()) || !(driver->domainEventState = virObjectEventStateNew()) || (vzInitVersion(driver) < 0) || diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 40979c6..d1eb6f6 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -470,19 +470,6 @@ prlsdkGetDomainState(PRL_HANDLE sdkdom, VIRTUAL_MACHINE_STATE_PTR vmState) return ret; } -void -prlsdkDomObjFreePrivate(void *p) -{ - vzDomObjPtr pdom = p; - - if (!pdom) - return; - - PrlHandle_Free(pdom->sdkdom); - PrlHandle_Free(pdom->stats); - VIR_FREE(p); -}; - static int prlsdkAddDomainVideoInfo(PRL_HANDLE sdkdom, virDomainDefPtr def) { diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h index 03c6aa1..9d143ce 100644 --- a/src/vz/vz_sdk.h +++ b/src/vz/vz_sdk.h @@ -78,8 +78,6 @@ int prlsdkGetVcpuStats(PRL_HANDLE sdkstas, int idx, unsigned long long *time); int prlsdkGetMemoryStats(PRL_HANDLE sdkstas, virDomainMemoryStatPtr stats, unsigned int nr_stats); -void -prlsdkDomObjFreePrivate(void *p); /* memsize is in MiB */ int prlsdkSetMemsize(virDomainObjPtr dom, unsigned int memsize); int diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index db23b72..eef9db2 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -164,15 +164,10 @@ vzNewDomain(vzDriverPtr driver, const char *name, const unsigned char *uuid) { virDomainDefPtr def = NULL; virDomainObjPtr dom = NULL; - vzDomObjPtr pdom = NULL; if (!(def = virDomainDefNewFull(name, uuid, -1))) goto error; - if (VIR_ALLOC(pdom) < 0) - goto error; - - pdom->stats = PRL_INVALID_HANDLE; def->virtType = VIR_DOMAIN_VIRT_VZ; if (!(dom = virDomainObjListAdd(driver->domains, def, @@ -180,14 +175,11 @@ vzNewDomain(vzDriverPtr driver, const char *name, const unsigned char *uuid) 0, NULL))) goto error; - dom->privateData = pdom; - dom->privateDataFreeFunc = prlsdkDomObjFreePrivate; dom->persistent = 1; return dom; error: virDomainDefFree(def); - VIR_FREE(pdom); return NULL; } @@ -481,3 +473,29 @@ int vzGetDefaultSCSIModel(vzDriverPtr driver, } return 0; } + +void* +vzDomObjAlloc(void) +{ + vzDomObjPtr pdom = NULL; + + if (VIR_ALLOC(pdom) < 0) + return NULL; + + pdom->stats = PRL_INVALID_HANDLE; + + return pdom; +} + +void +vzDomObjFree(void* p) +{ + vzDomObjPtr pdom = p; + + if (!pdom) + return; + + PrlHandle_Free(pdom->sdkdom); + PrlHandle_Free(pdom->stats); + VIR_FREE(pdom); +}; diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index a65ad21..9069340 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -102,6 +102,9 @@ struct vzDomObj { typedef struct vzDomObj *vzDomObjPtr; +void* vzDomObjAlloc(void); +void vzDomObjFree(void *p); + virDomainObjPtr vzDomObjFromDomain(virDomainPtr domain); virDomainObjPtr vzDomObjFromDomainRef(virDomainPtr domain); -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list