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

vz: implement memory setting functions

Quite straigthforward as vz sdk memory setting function makes
just what we want to that is set "amount of physical memory
allocated to a domain".

'useflags' is introduced for non flag function implementation.
We can't just use combination of flags like "live | config" or
we fail for inactive domains. Other combinations have drawbacks
too.
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 3fbb7dba
......@@ -1479,6 +1479,40 @@ vzConnectUnregisterCloseCallback(virConnectPtr conn, virConnectCloseFunc cb)
return ret;
}
static int vzDomainSetMemoryFlagsImpl(virDomainPtr domain, unsigned long memory,
unsigned int flags, bool useflags)
{
virDomainObjPtr dom = NULL;
int ret = -1;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
if (!(dom = vzDomObjFromDomain(domain)))
return -1;
if (useflags && vzCheckConfigUpdateFlags(dom, &flags) < 0)
goto cleanup;
ret = prlsdkSetMemsize(dom, memory >> 10);
cleanup:
virObjectUnlock(dom);
return ret;
}
static int vzDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
unsigned int flags)
{
return vzDomainSetMemoryFlagsImpl(domain, memory, flags, true);
}
static int vzDomainSetMemory(virDomainPtr domain, unsigned long memory)
{
return vzDomainSetMemoryFlagsImpl(domain, memory, 0, false);
}
static virHypervisorDriver vzDriver = {
.name = "vz",
.connectOpen = vzConnectOpen, /* 0.10.0 */
......@@ -1543,6 +1577,8 @@ static virHypervisorDriver vzDriver = {
.domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */
.connectRegisterCloseCallback = vzConnectRegisterCloseCallback, /* 1.3.2 */
.connectUnregisterCloseCallback = vzConnectUnregisterCloseCallback, /* 1.3.2 */
.domainSetMemoryFlags = vzDomainSetMemoryFlags, /* 1.3.4 */
.domainSetMemory = vzDomainSetMemory, /* 1.3.4 */
};
static virConnectDriver vzConnectDriver = {
......
......@@ -4302,3 +4302,27 @@ prlsdkGetMemoryStats(virDomainObjPtr dom,
return ret;
}
/* memsize is in MiB */
int prlsdkSetMemsize(virDomainObjPtr dom, unsigned int memsize)
{
vzDomObjPtr privdom = dom->privateData;
PRL_HANDLE job;
PRL_RESULT pret;
job = PrlVm_BeginEdit(privdom->sdkdom);
if (PRL_FAILED(waitJob(job)))
goto error;
pret = PrlVmCfg_SetRamSize(privdom->sdkdom, memsize);
prlsdkCheckRetGoto(pret, error);
job = PrlVm_CommitEx(privdom->sdkdom, 0);
if (PRL_FAILED(waitJob(job)))
goto error;
return 0;
error:
return -1;
}
......@@ -80,3 +80,5 @@ int
prlsdkGetMemoryStats(virDomainObjPtr dom, virDomainMemoryStatPtr stats, unsigned int nr_stats);
void
prlsdkDomObjFreePrivate(void *p);
/* memsize is in MiB */
int prlsdkSetMemsize(virDomainObjPtr dom, unsigned int memsize);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册