mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
vz: use domain list infrastructure to deal with private domain
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
c2f5dc24c5
commit
8dd169d1c1
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user