提交 8dd169d1 编写于 作者: N Nikolay Shirokovskiy 提交者: Maxim Nestratov

vz: use domain list infrastructure to deal with private domain

Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 c2f5dc24
......@@ -292,6 +292,10 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
return 0;
}
static virDomainXMLPrivateDataCallbacks vzDomainXMLPrivateDataCallbacksPtr = {
.alloc = vzDomObjAlloc,
.free = vzDomObjFree,
};
static virDomainDefParserConfig vzDomainDefParserConfig = {
.macPrefix = {0x42, 0x1C, 0x00},
......@@ -314,7 +318,8 @@ vzDriverObjNew(void)
if (!(driver->caps = vzBuildCapabilities()) ||
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
NULL, NULL)) ||
&vzDomainXMLPrivateDataCallbacksPtr,
NULL)) ||
!(driver->domains = virDomainObjListNew()) ||
!(driver->domainEventState = virObjectEventStateNew()) ||
(vzInitVersion(driver) < 0) ||
......
......@@ -476,19 +476,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
prlsdkAddDomainVideoInfoCt(virDomainDefPtr def)
{
......
......@@ -76,8 +76,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
......
......@@ -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;
}
......@@ -610,3 +602,29 @@ int vzCheckUnsupportedGraphics(virDomainGraphicsDefPtr gr)
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);
};
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册