mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
conf: Replace access to def->mem.max_balloon with accessor functions
As there are two possible approaches to define a domain's memory size - one used with legacy, non-NUMA VMs configured in the <memory> element and per-node based approach on NUMA machines - the user needs to make sure that both are specified correctly in the NUMA case. To avoid this burden on the user I'd like to replace the NUMA case with automatic totaling of the memory size. To achieve this I need to replace direct access to the virDomainMemtune's 'max_balloon' field with two separate getters depending on the desired size. The two sizes are needed as: 1) Startup memory size doesn't include memory modules in some hypervisors. 2) After startup these count as the usable memory size. Note that the comments for the functions are future aware and document state that will be present after a few later patches.
This commit is contained in:
parent
51f9f03a4c
commit
4f9907cd11
@ -237,7 +237,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
|
|||||||
/* Memory */
|
/* Memory */
|
||||||
virCommandAddArg(cmd, "-m");
|
virCommandAddArg(cmd, "-m");
|
||||||
virCommandAddArgFormat(cmd, "%llu",
|
virCommandAddArgFormat(cmd, "%llu",
|
||||||
VIR_DIV_UP(def->mem.max_balloon, 1024));
|
VIR_DIV_UP(virDomainDefGetMemoryInitial(def), 1024));
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON)
|
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON)
|
||||||
@ -322,7 +322,7 @@ virBhyveProcessBuildBhyveloadCmd(virDomainDefPtr def, virDomainDiskDefPtr disk)
|
|||||||
/* Memory (MB) */
|
/* Memory (MB) */
|
||||||
virCommandAddArg(cmd, "-m");
|
virCommandAddArg(cmd, "-m");
|
||||||
virCommandAddArgFormat(cmd, "%llu",
|
virCommandAddArgFormat(cmd, "%llu",
|
||||||
VIR_DIV_UP(def->mem.max_balloon, 1024));
|
VIR_DIV_UP(virDomainDefGetMemoryInitial(def), 1024));
|
||||||
|
|
||||||
/* Image path */
|
/* Image path */
|
||||||
virCommandAddArg(cmd, "-d");
|
virCommandAddArg(cmd, "-d");
|
||||||
@ -477,7 +477,7 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
|
|||||||
/* Memory in MB */
|
/* Memory in MB */
|
||||||
virCommandAddArg(cmd, "--memory");
|
virCommandAddArg(cmd, "--memory");
|
||||||
virCommandAddArgFormat(cmd, "%llu",
|
virCommandAddArgFormat(cmd, "%llu",
|
||||||
VIR_DIV_UP(def->mem.max_balloon, 1024));
|
VIR_DIV_UP(virDomainDefGetMemoryInitial(def), 1024));
|
||||||
|
|
||||||
if ((bhyveDriverGetGrubCaps(conn) & BHYVE_GRUB_CAP_CONSDEV) != 0 &&
|
if ((bhyveDriverGetGrubCaps(conn) & BHYVE_GRUB_CAP_CONSDEV) != 0 &&
|
||||||
def->nserials > 0) {
|
def->nserials > 0) {
|
||||||
|
@ -303,7 +303,7 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
info->state = virDomainObjGetState(vm, NULL);
|
info->state = virDomainObjGetState(vm, NULL);
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = vm->def->vcpus;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -3208,24 +3208,26 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->mem.cur_balloon > def->mem.max_balloon) {
|
if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def)) {
|
||||||
/* Older libvirt could get into this situation due to
|
/* Older libvirt could get into this situation due to
|
||||||
* rounding; if the discrepancy is less than 4MiB, we silently
|
* rounding; if the discrepancy is less than 4MiB, we silently
|
||||||
* round down, otherwise we flag the issue. */
|
* round down, otherwise we flag the issue. */
|
||||||
if (VIR_DIV_UP(def->mem.cur_balloon, 4096) >
|
if (VIR_DIV_UP(def->mem.cur_balloon, 4096) >
|
||||||
VIR_DIV_UP(def->mem.max_balloon, 4096)) {
|
VIR_DIV_UP(virDomainDefGetMemoryActual(def), 4096)) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("current memory '%lluk' exceeds "
|
_("current memory '%lluk' exceeds "
|
||||||
"maximum '%lluk'"),
|
"maximum '%lluk'"),
|
||||||
def->mem.cur_balloon, def->mem.max_balloon);
|
def->mem.cur_balloon,
|
||||||
|
virDomainDefGetMemoryActual(def));
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
VIR_DEBUG("Truncating current %lluk to maximum %lluk",
|
VIR_DEBUG("Truncating current %lluk to maximum %lluk",
|
||||||
def->mem.cur_balloon, def->mem.max_balloon);
|
def->mem.cur_balloon,
|
||||||
def->mem.cur_balloon = def->mem.max_balloon;
|
virDomainDefGetMemoryActual(def));
|
||||||
|
def->mem.cur_balloon = virDomainDefGetMemoryActual(def);
|
||||||
}
|
}
|
||||||
} else if (def->mem.cur_balloon == 0) {
|
} else if (def->mem.cur_balloon == 0) {
|
||||||
def->mem.cur_balloon = def->mem.max_balloon;
|
def->mem.cur_balloon = virDomainDefGetMemoryActual(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6972,6 +6974,51 @@ virDomainParseMemoryLimit(const char *xpath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainDefGetMemoryInitial:
|
||||||
|
* @def: domain definition
|
||||||
|
*
|
||||||
|
* Returns the size of the initial amount of guest memory. The initial amount
|
||||||
|
* is the memory size is either the configured amount in the <memory> element
|
||||||
|
* or the sum of memory sizes of NUMA nodes in case NUMA is enabled in @def.
|
||||||
|
*/
|
||||||
|
unsigned long long
|
||||||
|
virDomainDefGetMemoryInitial(virDomainDefPtr def)
|
||||||
|
{
|
||||||
|
return def->mem.max_balloon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainDefSetMemoryInitial:
|
||||||
|
* @def: domain definition
|
||||||
|
* @size: size to set
|
||||||
|
*
|
||||||
|
* Sets the initial memory size in @def.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virDomainDefSetMemoryInitial(virDomainDefPtr def,
|
||||||
|
unsigned long long size)
|
||||||
|
{
|
||||||
|
def->mem.max_balloon = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainDefGetMemoryActual:
|
||||||
|
* @def: domain definition
|
||||||
|
*
|
||||||
|
* Returns the current maximum memory size usable by the domain described by
|
||||||
|
* @def. This size is a sum of size returned by virDomainDefGetMemoryInitial
|
||||||
|
* and possible additional memory devices.
|
||||||
|
*/
|
||||||
|
unsigned long long
|
||||||
|
virDomainDefGetMemoryActual(virDomainDefPtr def)
|
||||||
|
{
|
||||||
|
return virDomainDefGetMemoryInitial(def);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
|
virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
|
||||||
const char *model)
|
const char *model)
|
||||||
@ -16108,10 +16155,11 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->mem.max_balloon != dst->mem.max_balloon) {
|
if (virDomainDefGetMemoryInitial(src) != virDomainDefGetMemoryInitial(dst)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Target domain max memory %lld does not match source %lld"),
|
_("Target domain max memory %lld does not match source %lld"),
|
||||||
dst->mem.max_balloon, src->mem.max_balloon);
|
virDomainDefGetMemoryInitial(dst),
|
||||||
|
virDomainDefGetMemoryInitial(src));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (src->mem.cur_balloon != dst->mem.cur_balloon) {
|
if (src->mem.cur_balloon != dst->mem.cur_balloon) {
|
||||||
@ -19885,7 +19933,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
virBufferAsprintf(buf, " dumpCore='%s'",
|
virBufferAsprintf(buf, " dumpCore='%s'",
|
||||||
virTristateSwitchTypeToString(def->mem.dump_core));
|
virTristateSwitchTypeToString(def->mem.dump_core));
|
||||||
virBufferAsprintf(buf, " unit='KiB'>%llu</memory>\n",
|
virBufferAsprintf(buf, " unit='KiB'>%llu</memory>\n",
|
||||||
def->mem.max_balloon);
|
virDomainDefGetMemoryActual(def));
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<currentMemory unit='KiB'>%llu</currentMemory>\n",
|
virBufferAsprintf(buf, "<currentMemory unit='KiB'>%llu</currentMemory>\n",
|
||||||
def->mem.cur_balloon);
|
def->mem.cur_balloon);
|
||||||
|
@ -2194,6 +2194,10 @@ struct _virDomainDef {
|
|||||||
xmlNodePtr metadata;
|
xmlNodePtr metadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
|
||||||
|
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
|
||||||
|
unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_DOMAIN_TAINT_CUSTOM_ARGV, /* Custom ARGV passthrough from XML */
|
VIR_DOMAIN_TAINT_CUSTOM_ARGV, /* Custom ARGV passthrough from XML */
|
||||||
VIR_DOMAIN_TAINT_CUSTOM_MONITOR, /* Custom monitor commands issued */
|
VIR_DOMAIN_TAINT_CUSTOM_MONITOR, /* Custom monitor commands issued */
|
||||||
|
@ -870,7 +870,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
if (VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes) < 0)
|
if (VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
def->mem.max_balloon = memorySettingData->data->Limit * 1024; /* megabyte to kilobyte */
|
virDomainDefSetMemoryInitial(def, memorySettingData->data->Limit * 1024); /* megabyte to kilobyte */
|
||||||
def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
|
def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
|
||||||
|
|
||||||
def->vcpus = processorSettingData->data->VirtualQuantity;
|
def->vcpus = processorSettingData->data->VirtualQuantity;
|
||||||
|
@ -198,6 +198,8 @@ virDomainDefFormatConvertXMLFlags;
|
|||||||
virDomainDefFormatInternal;
|
virDomainDefFormatInternal;
|
||||||
virDomainDefFree;
|
virDomainDefFree;
|
||||||
virDomainDefGetDefaultEmulator;
|
virDomainDefGetDefaultEmulator;
|
||||||
|
virDomainDefGetMemoryActual;
|
||||||
|
virDomainDefGetMemoryInitial;
|
||||||
virDomainDefGetSecurityLabelDef;
|
virDomainDefGetSecurityLabelDef;
|
||||||
virDomainDefHasDeviceAddress;
|
virDomainDefHasDeviceAddress;
|
||||||
virDomainDefMaybeAddController;
|
virDomainDefMaybeAddController;
|
||||||
@ -209,6 +211,7 @@ virDomainDefParseFile;
|
|||||||
virDomainDefParseNode;
|
virDomainDefParseNode;
|
||||||
virDomainDefParseString;
|
virDomainDefParseString;
|
||||||
virDomainDefPostParse;
|
virDomainDefPostParse;
|
||||||
|
virDomainDefSetMemoryInitial;
|
||||||
virDomainDeleteConfig;
|
virDomainDeleteConfig;
|
||||||
virDomainDeviceAddressIsValid;
|
virDomainDeviceAddressIsValid;
|
||||||
virDomainDeviceAddressTypeToString;
|
virDomainDeviceAddressTypeToString;
|
||||||
|
@ -659,7 +659,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
b_info->sched_params.weight = 1000;
|
b_info->sched_params.weight = 1000;
|
||||||
b_info->max_memkb = def->mem.max_balloon;
|
b_info->max_memkb = virDomainDefGetMemoryInitial(def);
|
||||||
b_info->target_memkb = def->mem.cur_balloon;
|
b_info->target_memkb = def->mem.cur_balloon;
|
||||||
if (hvm) {
|
if (hvm) {
|
||||||
char bootorder[VIR_DOMAIN_BOOT_LAST + 1];
|
char bootorder[VIR_DOMAIN_BOOT_LAST + 1];
|
||||||
|
@ -1075,7 +1075,7 @@ libxlDomainGetMaxMemory(virDomainPtr dom)
|
|||||||
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = vm->def->mem.max_balloon;
|
ret = virDomainDefGetMemoryActual(vm->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -1157,7 +1157,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
if (flags & VIR_DOMAIN_MEM_CONFIG) {
|
if (flags & VIR_DOMAIN_MEM_CONFIG) {
|
||||||
/* Help clang 2.8 decipher the logic flow. */
|
/* Help clang 2.8 decipher the logic flow. */
|
||||||
sa_assert(persistentDef);
|
sa_assert(persistentDef);
|
||||||
persistentDef->mem.max_balloon = newmem;
|
virDomainDefSetMemoryInitial(persistentDef, newmem);
|
||||||
if (persistentDef->mem.cur_balloon > newmem)
|
if (persistentDef->mem.cur_balloon > newmem)
|
||||||
persistentDef->mem.cur_balloon = newmem;
|
persistentDef->mem.cur_balloon = newmem;
|
||||||
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
|
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
|
||||||
@ -1167,7 +1167,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
} else {
|
} else {
|
||||||
/* resize the current memory */
|
/* resize the current memory */
|
||||||
|
|
||||||
if (newmem > vm->def->mem.max_balloon) {
|
if (newmem > virDomainDefGetMemoryActual(vm->def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("cannot set memory higher than max memory"));
|
_("cannot set memory higher than max memory"));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -1241,7 +1241,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
} else {
|
} else {
|
||||||
if (libxl_domain_info(priv->ctx, &d_info, vm->def->id) != 0) {
|
if (libxl_domain_info(priv->ctx, &d_info, vm->def->id) != 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
@ -146,7 +146,7 @@ static int virLXCCgroupSetupMemTune(virDomainDefPtr def,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (virCgroupSetMemory(cgroup, def->mem.max_balloon) < 0)
|
if (virCgroupSetMemory(cgroup, virDomainDefGetMemoryInitial(def)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virMemoryLimitIsSet(def->mem.hard_limit))
|
if (virMemoryLimitIsSet(def->mem.hard_limit))
|
||||||
|
@ -617,7 +617,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = vm->def->vcpus;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -686,7 +686,7 @@ lxcDomainGetMaxMemory(virDomainPtr dom)
|
|||||||
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = vm->def->mem.max_balloon;
|
ret = virDomainDefGetMemoryActual(vm->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -735,7 +735,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
persistentDef->mem.max_balloon = newmem;
|
virDomainDefSetMemoryInitial(persistentDef, newmem);
|
||||||
if (persistentDef->mem.cur_balloon > newmem)
|
if (persistentDef->mem.cur_balloon > newmem)
|
||||||
persistentDef->mem.cur_balloon = newmem;
|
persistentDef->mem.cur_balloon = newmem;
|
||||||
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
|
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
|
||||||
@ -745,10 +745,10 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
unsigned long oldmax = 0;
|
unsigned long oldmax = 0;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE)
|
if (flags & VIR_DOMAIN_AFFECT_LIVE)
|
||||||
oldmax = vm->def->mem.max_balloon;
|
oldmax = virDomainDefGetMemoryActual(vm->def);
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
if (!oldmax || oldmax > persistentDef->mem.max_balloon)
|
if (!oldmax || oldmax > virDomainDefGetMemoryActual(persistentDef))
|
||||||
oldmax = persistentDef->mem.max_balloon;
|
oldmax = virDomainDefGetMemoryActual(persistentDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newmem > oldmax) {
|
if (newmem > oldmax) {
|
||||||
|
@ -166,12 +166,12 @@ static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
|
|||||||
|
|
||||||
if (STREQ(line, "MemTotal") &&
|
if (STREQ(line, "MemTotal") &&
|
||||||
(virMemoryLimitIsSet(def->mem.hard_limit) ||
|
(virMemoryLimitIsSet(def->mem.hard_limit) ||
|
||||||
def->mem.max_balloon)) {
|
virDomainDefGetMemoryActual(def))) {
|
||||||
virBufferAsprintf(new_meminfo, "MemTotal: %8llu kB\n",
|
virBufferAsprintf(new_meminfo, "MemTotal: %8llu kB\n",
|
||||||
meminfo.memtotal);
|
meminfo.memtotal);
|
||||||
} else if (STREQ(line, "MemFree") &&
|
} else if (STREQ(line, "MemFree") &&
|
||||||
(virMemoryLimitIsSet(def->mem.hard_limit) ||
|
(virMemoryLimitIsSet(def->mem.hard_limit) ||
|
||||||
def->mem.max_balloon)) {
|
virDomainDefGetMemoryActual(def))) {
|
||||||
virBufferAsprintf(new_meminfo, "MemFree: %8llu kB\n",
|
virBufferAsprintf(new_meminfo, "MemFree: %8llu kB\n",
|
||||||
(meminfo.memtotal - meminfo.memusage));
|
(meminfo.memtotal - meminfo.memusage));
|
||||||
} else if (STREQ(line, "Buffers")) {
|
} else if (STREQ(line, "Buffers")) {
|
||||||
|
@ -772,7 +772,7 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
|
|||||||
if (lxcConvertSize(value->str, &size) < 0)
|
if (lxcConvertSize(value->str, &size) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
size = size / 1024;
|
size = size / 1024;
|
||||||
def->mem.max_balloon = size;
|
virDomainDefSetMemoryInitial(def, size);
|
||||||
def->mem.hard_limit = virMemoryLimitTruncate(size);
|
def->mem.hard_limit = virMemoryLimitTruncate(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,7 +1012,7 @@ lxcParseConfigString(const char *config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vmdef->id = -1;
|
vmdef->id = -1;
|
||||||
vmdef->mem.max_balloon = 64 * 1024;
|
virDomainDefSetMemoryInitial(vmdef, 64 * 1024);
|
||||||
|
|
||||||
vmdef->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
|
vmdef->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
|
||||||
vmdef->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
|
vmdef->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
|
||||||
|
@ -458,7 +458,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = vm->def->vcpus;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -534,7 +534,7 @@ parallelsDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
info->state = virDomainObjGetState(privdom, NULL);
|
info->state = virDomainObjGetState(privdom, NULL);
|
||||||
info->memory = privdom->def->mem.cur_balloon;
|
info->memory = privdom->def->mem.cur_balloon;
|
||||||
info->maxMem = privdom->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
|
||||||
info->nrVirtCpu = privdom->def->vcpus;
|
info->nrVirtCpu = privdom->def->vcpus;
|
||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -1211,9 +1211,9 @@ prlsdkLoadDomain(parallelsConnPtr privconn,
|
|||||||
/* get RAM parameters */
|
/* get RAM parameters */
|
||||||
pret = PrlVmCfg_GetRamSize(sdkdom, &ram);
|
pret = PrlVmCfg_GetRamSize(sdkdom, &ram);
|
||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
def->mem.max_balloon = ram << 10; /* RAM size obtained in Mbytes,
|
virDomainDefSetMemoryInitial(def, ram << 10); /* RAM size obtained in Mbytes,
|
||||||
convert to Kbytes */
|
convert to Kbytes */
|
||||||
def->mem.cur_balloon = def->mem.max_balloon;
|
def->mem.cur_balloon = ram << 10;
|
||||||
|
|
||||||
if (prlsdkConvertCpuInfo(sdkdom, def) < 0)
|
if (prlsdkConvertCpuInfo(sdkdom, def) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1767,14 +1767,14 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->mem.max_balloon != def->mem.cur_balloon) {
|
if (virDomainDefGetMemoryActual(def) != def->mem.cur_balloon) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("changing balloon parameters is not supported "
|
_("changing balloon parameters is not supported "
|
||||||
"by parallels driver"));
|
"by parallels driver"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->mem.max_balloon % (1 << 10) != 0) {
|
if (virDomainDefGetMemoryActual(def) % (1 << 10) != 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Memory size should be multiple of 1Mb."));
|
_("Memory size should be multiple of 1Mb."));
|
||||||
return -1;
|
return -1;
|
||||||
@ -2873,7 +2873,7 @@ prlsdkDoApplyConfig(PRL_HANDLE sdkdom,
|
|||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
pret = PrlVmCfg_SetRamSize(sdkdom, def->mem.max_balloon >> 10);
|
pret = PrlVmCfg_SetRamSize(sdkdom, virDomainDefGetMemoryActual(def) >> 10);
|
||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
|
|
||||||
pret = PrlVmCfg_SetCpuCount(sdkdom, def->vcpus);
|
pret = PrlVmCfg_SetCpuCount(sdkdom, def->vcpus);
|
||||||
|
@ -3252,6 +3252,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
LIBSSH2_SESSION *session = phyp_driver->session;
|
LIBSSH2_SESSION *session = phyp_driver->session;
|
||||||
virDomainDef def;
|
virDomainDef def;
|
||||||
char *managed_system = phyp_driver->managed_system;
|
char *managed_system = phyp_driver->managed_system;
|
||||||
|
unsigned long long memory;
|
||||||
|
|
||||||
/* Flags checked by virDomainDefFormat */
|
/* Flags checked by virDomainDefFormat */
|
||||||
|
|
||||||
@ -3273,12 +3274,13 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((def.mem.max_balloon =
|
if ((memory = phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0) {
|
||||||
phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0) {
|
|
||||||
VIR_ERROR(_("Unable to determine domain's max memory."));
|
VIR_ERROR(_("Unable to determine domain's max memory."));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virDomainDefSetMemoryInitial(&def, memory);
|
||||||
|
|
||||||
if ((def.mem.cur_balloon =
|
if ((def.mem.cur_balloon =
|
||||||
phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0) {
|
phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0) {
|
||||||
VIR_ERROR(_("Unable to determine domain's memory."));
|
VIR_ERROR(_("Unable to determine domain's memory."));
|
||||||
@ -3491,7 +3493,7 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!def->mem.max_balloon) {
|
if (!virDomainDefGetMemoryInitial(def)) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Field <memory> on the domain XML file is missing or "
|
_("Field <memory> on the domain XML file is missing or "
|
||||||
"has invalid value"));
|
"has invalid value"));
|
||||||
@ -3517,7 +3519,8 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
|
|||||||
virBufferAsprintf(&buf, " -r lpar -p %s -i min_mem=%lld,desired_mem=%lld,"
|
virBufferAsprintf(&buf, " -r lpar -p %s -i min_mem=%lld,desired_mem=%lld,"
|
||||||
"max_mem=%lld,desired_procs=%d,virtual_scsi_adapters=%s",
|
"max_mem=%lld,desired_procs=%d,virtual_scsi_adapters=%s",
|
||||||
def->name, def->mem.cur_balloon,
|
def->name, def->mem.cur_balloon,
|
||||||
def->mem.cur_balloon, def->mem.max_balloon,
|
def->mem.cur_balloon,
|
||||||
|
virDomainDefGetMemoryInitial(def),
|
||||||
(int) def->vcpus, virDomainDiskGetSource(def->disks[0]));
|
(int) def->vcpus, virDomainDiskGetSource(def->disks[0]));
|
||||||
ret = phypExecBuffer(session, &buf, &exit_status, conn, false);
|
ret = phypExecBuffer(session, &buf, &exit_status, conn, false);
|
||||||
|
|
||||||
|
@ -8496,8 +8496,9 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
* XML to reflect our rounding.
|
* XML to reflect our rounding.
|
||||||
*/
|
*/
|
||||||
virCommandAddArg(cmd, "-m");
|
virCommandAddArg(cmd, "-m");
|
||||||
def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
|
virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(virDomainDefGetMemoryInitial(def), 1024));
|
||||||
virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
|
virCommandAddArgFormat(cmd, "%llu", virDomainDefGetMemoryInitial(def) / 1024);
|
||||||
|
|
||||||
if (def->mem.nhugepages && !virDomainNumaGetNodeCount(def->numa)) {
|
if (def->mem.nhugepages && !virDomainNumaGetNodeCount(def->numa)) {
|
||||||
const long system_page_size = virGetSystemPageSizeKB();
|
const long system_page_size = virGetSystemPageSizeKB();
|
||||||
char *mem_path = NULL;
|
char *mem_path = NULL;
|
||||||
@ -10480,8 +10481,11 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
* space just to be safe (some finer tuning might be
|
* space just to be safe (some finer tuning might be
|
||||||
* nice, though).
|
* nice, though).
|
||||||
*/
|
*/
|
||||||
memKB = virMemoryLimitIsSet(def->mem.hard_limit) ?
|
if (virMemoryLimitIsSet(def->mem.hard_limit))
|
||||||
def->mem.hard_limit : def->mem.max_balloon + 1024 * 1024;
|
memKB = def->mem.hard_limit;
|
||||||
|
else
|
||||||
|
memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
|
||||||
|
|
||||||
virCommandSetMaxMemLock(cmd, memKB * 1024);
|
virCommandSetMaxMemLock(cmd, memKB * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12045,7 +12049,8 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
def->id = -1;
|
def->id = -1;
|
||||||
def->mem.cur_balloon = def->mem.max_balloon = 64 * 1024;
|
def->mem.cur_balloon = 64 * 1024;
|
||||||
|
virDomainDefSetMemoryInitial(def, def->mem.cur_balloon);
|
||||||
def->maxvcpus = 1;
|
def->maxvcpus = 1;
|
||||||
def->vcpus = 1;
|
def->vcpus = 1;
|
||||||
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
|
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
|
||||||
@ -12253,7 +12258,8 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
|||||||
_("cannot parse memory level '%s'"), val);
|
_("cannot parse memory level '%s'"), val);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
def->mem.cur_balloon = def->mem.max_balloon = mem * 1024;
|
virDomainDefSetMemoryInitial(def, mem * 1024);
|
||||||
|
def->mem.cur_balloon = mem * 1024;
|
||||||
} else if (STREQ(arg, "-smp")) {
|
} else if (STREQ(arg, "-smp")) {
|
||||||
WANT_VALUE();
|
WANT_VALUE();
|
||||||
if (qemuParseCommandLineSmp(def, val) < 0)
|
if (qemuParseCommandLineSmp(def, val) < 0)
|
||||||
|
@ -2259,7 +2259,7 @@ qemuDomainGetMaxMemory(virDomainPtr dom)
|
|||||||
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = vm->def->mem.max_balloon;
|
ret = virDomainDefGetMemoryActual(vm->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuDomObjEndAPI(&vm);
|
qemuDomObjEndAPI(&vm);
|
||||||
@ -2321,7 +2321,8 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
persistentDef->mem.max_balloon = newmem;
|
virDomainDefSetMemoryInitial(persistentDef, newmem);
|
||||||
|
|
||||||
if (persistentDef->mem.cur_balloon > newmem)
|
if (persistentDef->mem.cur_balloon > newmem)
|
||||||
persistentDef->mem.cur_balloon = newmem;
|
persistentDef->mem.cur_balloon = newmem;
|
||||||
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
|
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
|
||||||
@ -2333,10 +2334,10 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
unsigned long oldmax = 0;
|
unsigned long oldmax = 0;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE)
|
if (flags & VIR_DOMAIN_AFFECT_LIVE)
|
||||||
oldmax = vm->def->mem.max_balloon;
|
oldmax = virDomainDefGetMemoryActual(vm->def);
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
if (!oldmax || oldmax > persistentDef->mem.max_balloon)
|
if (!oldmax || oldmax > virDomainDefGetMemoryActual(persistentDef))
|
||||||
oldmax = persistentDef->mem.max_balloon;
|
oldmax = virDomainDefGetMemoryActual(persistentDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newmem > oldmax) {
|
if (newmem > oldmax) {
|
||||||
@ -2598,14 +2599,14 @@ static int qemuDomainGetInfo(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
|
|
||||||
if (virDomainObjIsActive(vm)) {
|
if (virDomainObjIsActive(vm)) {
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
if ((vm->def->memballoon != NULL) &&
|
if ((vm->def->memballoon != NULL) &&
|
||||||
(vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)) {
|
(vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)) {
|
||||||
info->memory = vm->def->mem.max_balloon;
|
info->memory = virDomainDefGetMemoryActual(vm->def);
|
||||||
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
|
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
} else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
|
} else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
|
||||||
@ -2631,7 +2632,7 @@ static int qemuDomainGetInfo(virDomainPtr dom,
|
|||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
} else if (err == 0) {
|
} else if (err == 0) {
|
||||||
/* Balloon not supported, so maxmem is always the allocation */
|
/* Balloon not supported, so maxmem is always the allocation */
|
||||||
info->memory = vm->def->mem.max_balloon;
|
info->memory = virDomainDefGetMemoryActual(vm->def);
|
||||||
} else {
|
} else {
|
||||||
info->memory = balloon;
|
info->memory = balloon;
|
||||||
}
|
}
|
||||||
@ -18897,7 +18898,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
if (dom->def->memballoon &&
|
if (dom->def->memballoon &&
|
||||||
dom->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
|
dom->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
|
||||||
cur_balloon = dom->def->mem.max_balloon;
|
cur_balloon = virDomainDefGetMemoryActual(dom->def);
|
||||||
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
|
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
|
||||||
cur_balloon = dom->def->mem.cur_balloon;
|
cur_balloon = dom->def->mem.cur_balloon;
|
||||||
} else {
|
} else {
|
||||||
@ -18915,7 +18916,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
"balloon.maximum",
|
"balloon.maximum",
|
||||||
dom->def->mem.max_balloon) < 0)
|
virDomainDefGetMemoryActual(dom->def)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1250,9 +1250,11 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|||||||
* Kibibytes, but virProcessSetMaxMemLock expects the value in
|
* Kibibytes, but virProcessSetMaxMemLock expects the value in
|
||||||
* bytes.
|
* bytes.
|
||||||
*/
|
*/
|
||||||
memKB = virMemoryLimitIsSet(vm->def->mem.hard_limit)
|
if (virMemoryLimitIsSet(vm->def->mem.hard_limit))
|
||||||
? vm->def->mem.hard_limit
|
memKB = vm->def->mem.hard_limit;
|
||||||
: vm->def->mem.max_balloon + (1024 * 1024);
|
else
|
||||||
|
memKB = virDomainDefGetMemoryActual(vm->def) + (1024 * 1024);
|
||||||
|
|
||||||
virProcessSetMaxMemLock(vm->pid, memKB * 1024);
|
virProcessSetMaxMemLock(vm->pid, memKB * 1024);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -4568,7 +4568,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
*/
|
*/
|
||||||
if (virDomainDefNeedsPlacementAdvice(vm->def)) {
|
if (virDomainDefNeedsPlacementAdvice(vm->def)) {
|
||||||
nodeset = virNumaGetAutoPlacementAdvice(vm->def->vcpus,
|
nodeset = virNumaGetAutoPlacementAdvice(vm->def->vcpus,
|
||||||
vm->def->mem.max_balloon);
|
virDomainDefGetMemoryActual(vm->def));
|
||||||
if (!nodeset)
|
if (!nodeset)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -2151,7 +2151,7 @@ static int testDomainGetInfo(virDomainPtr domain,
|
|||||||
|
|
||||||
info->state = virDomainObjGetState(privdom, NULL);
|
info->state = virDomainObjGetState(privdom, NULL);
|
||||||
info->memory = privdom->def->mem.cur_balloon;
|
info->memory = privdom->def->mem.cur_balloon;
|
||||||
info->maxMem = privdom->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
|
||||||
info->nrVirtCpu = privdom->def->vcpus;
|
info->nrVirtCpu = privdom->def->vcpus;
|
||||||
info->cpuTime = ((tv.tv_sec * 1000ll * 1000ll * 1000ll) + (tv.tv_usec * 1000ll));
|
info->cpuTime = ((tv.tv_sec * 1000ll * 1000ll * 1000ll) + (tv.tv_usec * 1000ll));
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -2519,7 +2519,7 @@ testDomainGetMaxMemory(virDomainPtr domain)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = privdom->def->mem.max_balloon;
|
ret = virDomainDefGetMemoryActual(privdom->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (privdom)
|
if (privdom)
|
||||||
@ -2545,7 +2545,7 @@ static int testDomainSetMaxMemory(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX validate not over host memory wrt to other domains */
|
/* XXX validate not over host memory wrt to other domains */
|
||||||
privdom->def->mem.max_balloon = memory;
|
virDomainDefSetMemoryInitial(privdom->def, memory);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -2571,7 +2571,7 @@ static int testDomainSetMemory(virDomainPtr domain,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memory > privdom->def->mem.max_balloon) {
|
if (memory > virDomainDefGetMemoryActual(privdom->def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1802,7 +1802,7 @@ umlDomainGetMaxMemory(virDomainPtr dom)
|
|||||||
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = vm->def->mem.max_balloon;
|
ret = virDomainDefGetMemoryActual(vm->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -1838,7 +1838,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm->def->mem.max_balloon = newmax;
|
virDomainDefSetMemoryInitial(vm->def, newmax);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -1875,7 +1875,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newmem > vm->def->mem.max_balloon) {
|
if (newmem > virDomainDefGetMemoryActual(vm->def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("cannot set memory higher than max memory"));
|
_("cannot set memory higher than max memory"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1922,7 +1922,7 @@ static int umlDomainGetInfo(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = vm->def->vcpus;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -3894,7 +3894,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
* reading and while dumping xml
|
* reading and while dumping xml
|
||||||
*/
|
*/
|
||||||
/* def->mem.max_balloon = maxMemorySize * 1024; */
|
/* def->mem.max_balloon = maxMemorySize * 1024; */
|
||||||
def->mem.max_balloon = memorySize * 1024;
|
virDomainDefSetMemoryInitial(def, memorySize * 1024);
|
||||||
|
|
||||||
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
|
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
|
||||||
def->maxvcpus = def->vcpus = CPUCount;
|
def->maxvcpus = def->vcpus = CPUCount;
|
||||||
@ -6055,7 +6055,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||||||
* the notation here seems to be inconsistent while
|
* the notation here seems to be inconsistent while
|
||||||
* reading and while dumping xml
|
* reading and while dumping xml
|
||||||
*/
|
*/
|
||||||
def->dom->mem.max_balloon = memorySize * 1024;
|
virDomainDefSetMemoryInitial(def->dom, memorySize * 1024);
|
||||||
if (VIR_STRDUP(def->dom->os.type, "hvm") < 0)
|
if (VIR_STRDUP(def->dom->os.type, "hvm") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def->dom->os.arch = virArchFromHost();
|
def->dom->os.arch = virArchFromHost();
|
||||||
|
@ -1126,7 +1126,7 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
|
|
||||||
info->state = virDomainObjGetState(vm, NULL);
|
info->state = virDomainObjGetState(vm, NULL);
|
||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
info->maxMem = vm->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = vm->def->vcpus;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -1375,7 +1375,7 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->mem.max_balloon = memsize * 1024; /* Scale from megabytes to kilobytes */
|
virDomainDefSetMemoryInitial(def, memsize * 1024); /* Scale from megabytes to kilobytes */
|
||||||
|
|
||||||
/* vmx:sched.mem.max -> def:mem.cur_balloon */
|
/* vmx:sched.mem.max -> def:mem.cur_balloon */
|
||||||
if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,
|
if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,
|
||||||
@ -1388,8 +1388,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
|
|
||||||
def->mem.cur_balloon = sched_mem_max * 1024; /* Scale from megabytes to kilobytes */
|
def->mem.cur_balloon = sched_mem_max * 1024; /* Scale from megabytes to kilobytes */
|
||||||
|
|
||||||
if (def->mem.cur_balloon > def->mem.max_balloon)
|
if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def))
|
||||||
def->mem.cur_balloon = def->mem.max_balloon;
|
def->mem.cur_balloon = virDomainDefGetMemoryActual(def);
|
||||||
|
|
||||||
/* vmx:sched.mem.minsize -> def:mem.min_guarantee */
|
/* vmx:sched.mem.minsize -> def:mem.min_guarantee */
|
||||||
if (virVMXGetConfigLong(conf, "sched.mem.minsize", &sched_mem_minsize, 0,
|
if (virVMXGetConfigLong(conf, "sched.mem.minsize", &sched_mem_minsize, 0,
|
||||||
@ -1402,8 +1402,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
|
|
||||||
def->mem.min_guarantee = sched_mem_minsize * 1024; /* Scale from megabytes to kilobytes */
|
def->mem.min_guarantee = sched_mem_minsize * 1024; /* Scale from megabytes to kilobytes */
|
||||||
|
|
||||||
if (def->mem.min_guarantee > def->mem.max_balloon)
|
if (def->mem.min_guarantee > virDomainDefGetMemoryActual(def))
|
||||||
def->mem.min_guarantee = def->mem.max_balloon;
|
def->mem.min_guarantee = virDomainDefGetMemoryActual(def);
|
||||||
|
|
||||||
/* vmx:numvcpus -> def:vcpus */
|
/* vmx:numvcpus -> def:vcpus */
|
||||||
if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0)
|
if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0)
|
||||||
@ -3084,7 +3084,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
|
|||||||
|
|
||||||
/* def:mem.max_balloon -> vmx:memsize */
|
/* def:mem.max_balloon -> vmx:memsize */
|
||||||
/* max-memory must be a multiple of 4096 kilobyte */
|
/* max-memory must be a multiple of 4096 kilobyte */
|
||||||
max_balloon = VIR_DIV_UP(def->mem.max_balloon, 4096) * 4096;
|
max_balloon = VIR_DIV_UP(virDomainDefGetMemoryActual(def), 4096) * 4096;
|
||||||
|
|
||||||
virBufferAsprintf(&buffer, "memsize = \"%llu\"\n",
|
virBufferAsprintf(&buffer, "memsize = \"%llu\"\n",
|
||||||
max_balloon / 1024); /* Scale from kilobytes to megabytes */
|
max_balloon / 1024); /* Scale from kilobytes to megabytes */
|
||||||
|
@ -479,7 +479,7 @@ xenXMDomainGetInfo(virConnectPtr conn,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
memset(info, 0, sizeof(virDomainInfo));
|
memset(info, 0, sizeof(virDomainInfo));
|
||||||
info->maxMem = entry->def->mem.max_balloon;
|
info->maxMem = virDomainDefGetMemoryActual(entry->def);
|
||||||
info->memory = entry->def->mem.cur_balloon;
|
info->memory = entry->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = entry->def->vcpus;
|
info->nrVirtCpu = entry->def->vcpus;
|
||||||
info->state = VIR_DOMAIN_SHUTOFF;
|
info->state = VIR_DOMAIN_SHUTOFF;
|
||||||
@ -557,8 +557,8 @@ xenXMDomainSetMemory(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
entry->def->mem.cur_balloon = memory;
|
entry->def->mem.cur_balloon = memory;
|
||||||
if (entry->def->mem.cur_balloon > entry->def->mem.max_balloon)
|
if (entry->def->mem.cur_balloon > virDomainDefGetMemoryActual(entry->def))
|
||||||
entry->def->mem.cur_balloon = entry->def->mem.max_balloon;
|
entry->def->mem.cur_balloon = virDomainDefGetMemoryActual(entry->def);
|
||||||
|
|
||||||
/* If this fails, should we try to undo our changes to the
|
/* If this fails, should we try to undo our changes to the
|
||||||
* in-memory representation of the config file. I say not!
|
* in-memory representation of the config file. I say not!
|
||||||
@ -600,10 +600,10 @@ xenXMDomainSetMaxMemory(virConnectPtr conn,
|
|||||||
if (!(entry = virHashLookup(priv->configCache, filename)))
|
if (!(entry = virHashLookup(priv->configCache, filename)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
entry->def->mem.max_balloon = memory;
|
if (entry->def->mem.cur_balloon > memory)
|
||||||
if (entry->def->mem.cur_balloon > entry->def->mem.max_balloon)
|
entry->def->mem.cur_balloon = memory;
|
||||||
entry->def->mem.cur_balloon = entry->def->mem.max_balloon;
|
|
||||||
|
|
||||||
|
virDomainDefSetMemoryInitial(entry->def, memory);
|
||||||
/* If this fails, should we try to undo our changes to the
|
/* If this fails, should we try to undo our changes to the
|
||||||
* in-memory representation of the config file. I say not!
|
* in-memory representation of the config file. I say not!
|
||||||
*/
|
*/
|
||||||
@ -636,7 +636,7 @@ xenXMDomainGetMaxMemory(virConnectPtr conn,
|
|||||||
if (!(entry = virHashLookup(priv->configCache, filename)))
|
if (!(entry = virHashLookup(priv->configCache, filename)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = entry->def->mem.max_balloon;
|
ret = virDomainDefGetMemoryActual(entry->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
xenUnifiedUnlock(priv);
|
xenUnifiedUnlock(priv);
|
||||||
|
@ -1492,7 +1492,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
VIR_FREE(val);
|
VIR_FREE(val);
|
||||||
}
|
}
|
||||||
memory = xenapiDomainGetMaxMemory(dom);
|
memory = xenapiDomainGetMaxMemory(dom);
|
||||||
defPtr->mem.max_balloon = memory;
|
virDomainDefSetMemoryInitial(defPtr, memory);
|
||||||
if (xen_vm_get_memory_dynamic_max(session, &dynamic_mem, vm)) {
|
if (xen_vm_get_memory_dynamic_max(session, &dynamic_mem, vm)) {
|
||||||
defPtr->mem.cur_balloon = (unsigned long) (dynamic_mem / 1024);
|
defPtr->mem.cur_balloon = (unsigned long) (dynamic_mem / 1024);
|
||||||
} else {
|
} else {
|
||||||
|
@ -499,8 +499,8 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
|
|||||||
|
|
||||||
if (def->mem.cur_balloon)
|
if (def->mem.cur_balloon)
|
||||||
(*record)->memory_static_max = (int64_t) (def->mem.cur_balloon * 1024);
|
(*record)->memory_static_max = (int64_t) (def->mem.cur_balloon * 1024);
|
||||||
if (def->mem.max_balloon)
|
if (virDomainDefGetMemoryActual(def))
|
||||||
(*record)->memory_dynamic_max = (int64_t) (def->mem.max_balloon * 1024);
|
(*record)->memory_dynamic_max = (int64_t) (virDomainDefGetMemoryActual(def) * 1024);
|
||||||
else
|
else
|
||||||
(*record)->memory_dynamic_max = (*record)->memory_static_max;
|
(*record)->memory_dynamic_max = (*record)->memory_static_max;
|
||||||
|
|
||||||
|
@ -305,16 +305,18 @@ xenConfigSetString(virConfPtr conf, const char *setting, const char *str)
|
|||||||
static int
|
static int
|
||||||
xenParseMem(virConfPtr conf, virDomainDefPtr def)
|
xenParseMem(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
|
unsigned long long memory;
|
||||||
|
|
||||||
if (xenConfigGetULongLong(conf, "memory", &def->mem.cur_balloon,
|
if (xenConfigGetULongLong(conf, "memory", &def->mem.cur_balloon,
|
||||||
MIN_XEN_GUEST_SIZE * 2) < 0)
|
MIN_XEN_GUEST_SIZE * 2) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon,
|
if (xenConfigGetULongLong(conf, "maxmem", &memory,
|
||||||
def->mem.cur_balloon) < 0)
|
def->mem.cur_balloon) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
def->mem.cur_balloon *= 1024;
|
def->mem.cur_balloon *= 1024;
|
||||||
def->mem.max_balloon *= 1024;
|
virDomainDefSetMemoryInitial(def, memory * 1024);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1383,7 +1385,7 @@ static int
|
|||||||
xenFormatMem(virConfPtr conf, virDomainDefPtr def)
|
xenFormatMem(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
if (xenConfigSetInt(conf, "maxmem",
|
if (xenConfigSetInt(conf, "maxmem",
|
||||||
VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
|
VIR_DIV_UP(virDomainDefGetMemoryActual(def), 1024)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenConfigSetInt(conf, "memory",
|
if (xenConfigSetInt(conf, "memory",
|
||||||
|
@ -1155,10 +1155,11 @@ xenParseSxpr(const struct sexpr *root,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def->mem.max_balloon = (sexpr_u64(root, "domain/maxmem") << 10);
|
virDomainDefSetMemoryInitial(def, (sexpr_u64(root, "domain/maxmem") << 10));
|
||||||
def->mem.cur_balloon = (sexpr_u64(root, "domain/memory") << 10);
|
def->mem.cur_balloon = (sexpr_u64(root, "domain/memory") << 10);
|
||||||
if (def->mem.cur_balloon > def->mem.max_balloon)
|
|
||||||
def->mem.cur_balloon = def->mem.max_balloon;
|
if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def))
|
||||||
|
def->mem.cur_balloon = virDomainDefGetMemoryActual(def);
|
||||||
|
|
||||||
if (cpus != NULL) {
|
if (cpus != NULL) {
|
||||||
if (virBitmapParse(cpus, 0, &def->cpumask,
|
if (virBitmapParse(cpus, 0, &def->cpumask,
|
||||||
@ -2213,7 +2214,7 @@ xenFormatSxpr(virConnectPtr conn,
|
|||||||
virBufferEscapeSexpr(&buf, "(name '%s')", def->name);
|
virBufferEscapeSexpr(&buf, "(name '%s')", def->name);
|
||||||
virBufferAsprintf(&buf, "(memory %llu)(maxmem %llu)",
|
virBufferAsprintf(&buf, "(memory %llu)(maxmem %llu)",
|
||||||
VIR_DIV_UP(def->mem.cur_balloon, 1024),
|
VIR_DIV_UP(def->mem.cur_balloon, 1024),
|
||||||
VIR_DIV_UP(def->mem.max_balloon, 1024));
|
VIR_DIV_UP(virDomainDefGetMemoryActual(def), 1024));
|
||||||
virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
|
virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
|
||||||
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
||||||
either 32, or 64 on a platform where long is big enough. */
|
either 32, or 64 on a platform where long is big enough. */
|
||||||
|
Loading…
Reference in New Issue
Block a user