mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static virDomainXMLPrivateDataCallbacks vzDomainXMLPrivateDataCallbacksPtr = {
|
||||||
|
.alloc = vzDomObjAlloc,
|
||||||
|
.free = vzDomObjFree,
|
||||||
|
};
|
||||||
|
|
||||||
static virDomainDefParserConfig vzDomainDefParserConfig = {
|
static virDomainDefParserConfig vzDomainDefParserConfig = {
|
||||||
.macPrefix = {0x42, 0x1C, 0x00},
|
.macPrefix = {0x42, 0x1C, 0x00},
|
||||||
@ -314,7 +318,8 @@ vzDriverObjNew(void)
|
|||||||
|
|
||||||
if (!(driver->caps = vzBuildCapabilities()) ||
|
if (!(driver->caps = vzBuildCapabilities()) ||
|
||||||
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
||||||
NULL, NULL)) ||
|
&vzDomainXMLPrivateDataCallbacksPtr,
|
||||||
|
NULL)) ||
|
||||||
!(driver->domains = virDomainObjListNew()) ||
|
!(driver->domains = virDomainObjListNew()) ||
|
||||||
!(driver->domainEventState = virObjectEventStateNew()) ||
|
!(driver->domainEventState = virObjectEventStateNew()) ||
|
||||||
(vzInitVersion(driver) < 0) ||
|
(vzInitVersion(driver) < 0) ||
|
||||||
|
@ -476,19 +476,6 @@ prlsdkGetDomainState(PRL_HANDLE sdkdom, VIRTUAL_MACHINE_STATE_PTR vmState)
|
|||||||
return ret;
|
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
|
static int
|
||||||
prlsdkAddDomainVideoInfoCt(virDomainDefPtr def)
|
prlsdkAddDomainVideoInfoCt(virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
|
@ -76,8 +76,6 @@ int
|
|||||||
prlsdkGetVcpuStats(PRL_HANDLE sdkstas, int idx, unsigned long long *time);
|
prlsdkGetVcpuStats(PRL_HANDLE sdkstas, int idx, unsigned long long *time);
|
||||||
int
|
int
|
||||||
prlsdkGetMemoryStats(PRL_HANDLE sdkstas, virDomainMemoryStatPtr stats, unsigned int nr_stats);
|
prlsdkGetMemoryStats(PRL_HANDLE sdkstas, virDomainMemoryStatPtr stats, unsigned int nr_stats);
|
||||||
void
|
|
||||||
prlsdkDomObjFreePrivate(void *p);
|
|
||||||
/* memsize is in MiB */
|
/* memsize is in MiB */
|
||||||
int prlsdkSetMemsize(virDomainObjPtr dom, unsigned int memsize);
|
int prlsdkSetMemsize(virDomainObjPtr dom, unsigned int memsize);
|
||||||
int
|
int
|
||||||
|
@ -164,15 +164,10 @@ vzNewDomain(vzDriverPtr driver, const char *name, const unsigned char *uuid)
|
|||||||
{
|
{
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
virDomainObjPtr dom = NULL;
|
virDomainObjPtr dom = NULL;
|
||||||
vzDomObjPtr pdom = NULL;
|
|
||||||
|
|
||||||
if (!(def = virDomainDefNewFull(name, uuid, -1)))
|
if (!(def = virDomainDefNewFull(name, uuid, -1)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_ALLOC(pdom) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
pdom->stats = PRL_INVALID_HANDLE;
|
|
||||||
def->virtType = VIR_DOMAIN_VIRT_VZ;
|
def->virtType = VIR_DOMAIN_VIRT_VZ;
|
||||||
|
|
||||||
if (!(dom = virDomainObjListAdd(driver->domains, def,
|
if (!(dom = virDomainObjListAdd(driver->domains, def,
|
||||||
@ -180,14 +175,11 @@ vzNewDomain(vzDriverPtr driver, const char *name, const unsigned char *uuid)
|
|||||||
0, NULL)))
|
0, NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
dom->privateData = pdom;
|
|
||||||
dom->privateDataFreeFunc = prlsdkDomObjFreePrivate;
|
|
||||||
dom->persistent = 1;
|
dom->persistent = 1;
|
||||||
return dom;
|
return dom;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
VIR_FREE(pdom);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,3 +602,29 @@ int vzCheckUnsupportedGraphics(virDomainGraphicsDefPtr gr)
|
|||||||
|
|
||||||
return 0;
|
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;
|
typedef struct vzDomObj *vzDomObjPtr;
|
||||||
|
|
||||||
|
void* vzDomObjAlloc(void);
|
||||||
|
void vzDomObjFree(void *p);
|
||||||
|
|
||||||
virDomainObjPtr vzDomObjFromDomain(virDomainPtr domain);
|
virDomainObjPtr vzDomObjFromDomain(virDomainPtr domain);
|
||||||
virDomainObjPtr vzDomObjFromDomainRef(virDomainPtr domain);
|
virDomainObjPtr vzDomObjFromDomainRef(virDomainPtr domain);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user