def->description = virXPathString("string(./description[1])", ctxt);
/* Extract domain memory */
- if (virXPathULong("string(./memory[1])", ctxt, &def->maxmem) < 0) {
+ if (virXPathULong("string(./memory[1])", ctxt,
+ &def->mem.max_balloon) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing memory element"));
goto error;
}
- if (virXPathULong("string(./currentMemory[1])", ctxt, &def->memory) < 0)
- def->memory = def->maxmem;
+ if (virXPathULong("string(./currentMemory[1])", ctxt,
+ &def->mem.cur_balloon) < 0)
+ def->mem.cur_balloon = def->mem.max_balloon;
node = virXPathNode("./memoryBacking/hugepages", ctxt);
if (node)
- def->hugepage_backed = 1;
+ def->mem.hugepage_backed = 1;
+
+ /* Extract other memory tunables */
+ if (virXPathULong("string(./memtune/hard_limit)", ctxt,
+ &def->mem.hard_limit) < 0)
+ def->mem.hard_limit = 0;
+
+ if (virXPathULong("string(./memtune/soft_limit[1])", ctxt,
+ &def->mem.soft_limit) < 0)
+ def->mem.soft_limit = 0;
+
+ if (virXPathULong("string(./memtune/min_guarantee[1])", ctxt,
+ &def->mem.min_guarantee) < 0)
+ def->mem.min_guarantee = 0;
+
+ if (virXPathULong("string(./memtune/swap_hard_limit[1])", ctxt,
+ &def->mem.swap_hard_limit) < 0)
+ def->mem.swap_hard_limit = 0;
if (virXPathULong("string(./vcpu[1])", ctxt, &def->vcpus) < 0)
def->vcpus = 1;
virBufferEscapeString(&buf, " <description>%s</description>\n",
def->description);
- virBufferVSprintf(&buf, " <memory>%lu</memory>\n", def->maxmem);
+ virBufferVSprintf(&buf, " <memory>%lu</memory>\n", def->mem.max_balloon);
virBufferVSprintf(&buf, " <currentMemory>%lu</currentMemory>\n",
- def->memory);
- if (def->hugepage_backed) {
+ def->mem.cur_balloon);
+
+ /* add memtune only if there are any */
+ if(def->mem.hard_limit || def->mem.hard_limit || def->mem.hard_limit)
+ virBufferVSprintf(&buf, " <memtune>\n");
+ if (def->mem.hard_limit) {
+ virBufferVSprintf(&buf, " <hard_limit>%lu</hard_limit>\n",
+ def->mem.hard_limit);
+ }
+ if (def->mem.soft_limit) {
+ virBufferVSprintf(&buf, " <soft_limit>%lu</soft_limit>\n",
+ def->mem.soft_limit);
+ }
+ if (def->mem.swap_hard_limit) {
+ virBufferVSprintf(&buf, " <swap_hard_limit>%lu</swap_hard_limit>\n",
+ def->mem.swap_hard_limit);
+ }
+ if(def->mem.hard_limit || def->mem.hard_limit || def->mem.hard_limit)
+ virBufferVSprintf(&buf, " </memtune>\n");
+
+ if (def->mem.hugepage_backed) {
virBufferAddLit(&buf, " <memoryBacking>\n");
virBufferAddLit(&buf, " <hugepages/>\n");
virBufferAddLit(&buf, " </memoryBacking>\n");
char *name;
char *description;
- unsigned long memory;
- unsigned long maxmem;
- unsigned char hugepage_backed;
+ struct {
+ unsigned long max_balloon;
+ unsigned long cur_balloon;
+ unsigned long hugepage_backed;
+ unsigned long hard_limit;
+ unsigned long soft_limit;
+ unsigned long min_guarantee;
+ unsigned long swap_hard_limit;
+ } mem;
unsigned long vcpus;
int cpumasklen;
char *cpumask;
def->id = <value> <=> ??? # not representable
def->uuid = <value> <=> uuid.bios = "<value>"
def->name = <value> <=> displayName = "<value>"
-def->maxmem = <value kilobyte> <=> memsize = "<value megabyte>" # must be a multiple of 4, defaults to 32
-def->memory = <value kilobyte> <=> sched.mem.max = "<value megabyte>" # defaults to "unlimited" -> def->memory = def->maxmem
+def->mem.max_balloon = <value kilobyte> <=> memsize = "<value megabyte>" # must be a multiple of 4, defaults to 32
+def->mem.cur_balloon = <value kilobyte> <=> sched.mem.max = "<value megabyte>" # defaults to "unlimited" -> def->mem.cur_balloon = def->mem.max_balloon
def->vcpus = <value> <=> numvcpus = "<value>" # must be 1 or a multiple of 2, defaults to 1
def->cpumask = <uint list> <=> sched.cpu.affinity = "<uint list>"
*tmp2 = '\0';
}
- /* vmx:memsize -> def:maxmem */
+ /* vmx:memsize -> def:mem.max_balloon */
if (esxUtil_GetConfigLong(conf, "memsize", &memsize, 32, true) < 0) {
goto cleanup;
}
goto cleanup;
}
- def->maxmem = memsize * 1024; /* Scale from megabytes to kilobytes */
+ def->mem.max_balloon = memsize * 1024; /* Scale from megabytes to kilobytes */
/* vmx:sched.mem.max -> def:memory */
if (esxUtil_GetConfigLong(conf, "sched.mem.max", &memory, memsize,
memory = memsize;
}
- def->memory = memory * 1024; /* Scale from megabytes to kilobytes */
+ def->mem.cur_balloon = memory * 1024; /* Scale from megabytes to kilobytes */
- if (def->memory > def->maxmem) {
- def->memory = def->maxmem;
+ if (def->mem.cur_balloon > def->mem.max_balloon) {
+ def->mem.cur_balloon = def->mem.max_balloon;
}
/* vmx:numvcpus -> def:vcpus */
virBufferVSprintf(&buffer, "annotation = \"%s\"\n", annotation);
}
- /* def:maxmem -> vmx:memsize */
- if (def->maxmem <= 0 || def->maxmem % 4096 != 0) {
+ /* def:mem.max_balloon -> vmx:memsize */
+ if (def->mem.max_balloon <= 0 || def->mem.max_balloon % 4096 != 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'memory' to be an unsigned "
"integer (multiple of 4096) but found %lld"),
- (unsigned long long)def->maxmem);
+ (unsigned long long)def->mem.max_balloon);
goto cleanup;
}
/* Scale from kilobytes to megabytes */
virBufferVSprintf(&buffer, "memsize = \"%d\"\n",
- (int)(def->maxmem / 1024));
+ (int)(def->mem.max_balloon / 1024));
/* def:memory -> vmx:sched.mem.max */
- if (def->memory < def->maxmem) {
- if (def->memory <= 0 || def->memory % 1024 != 0) {
+ if (def->mem.cur_balloon < def->mem.max_balloon) {
+ if (def->mem.cur_balloon <= 0 || def->mem.cur_balloon % 1024 != 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'currentMemory' to be an "
"unsigned integer (multiple of 1024) but found %lld"),
- (unsigned long long)def->memory);
+ (unsigned long long)def->mem.cur_balloon);
goto cleanup;
}
/* Scale from kilobytes to megabytes */
virBufferVSprintf(&buffer, "sched.mem.max = \"%d\"\n",
- (int)(def->memory / 1024));
+ (int)(def->mem.cur_balloon / 1024));
}
/* def:vcpus -> vmx:numvcpus */
goto cleanup;
}
- rc = virCgroupSetMemory(cgroup, def->maxmem);
+ rc = virCgroupSetMemory(cgroup, def->mem.max_balloon);
if (rc != 0) {
virReportSystemError(-rc,
_("Unable to set memory limit for domain %s"),
if (!virDomainObjIsActive(vm) || driver->cgroup == NULL) {
info->cpuTime = 0;
- info->memory = vm->def->memory;
+ info->memory = vm->def->mem.cur_balloon;
} else {
if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
}
}
- info->maxMem = vm->def->maxmem;
+ info->maxMem = vm->def->mem.max_balloon;
info->nrVirtCpu = 1;
ret = 0;
goto cleanup;
}
- ret = vm->def->maxmem;
+ ret = vm->def->mem.max_balloon;
cleanup:
if (vm)
goto cleanup;
}
- if (newmax < vm->def->memory) {
+ if (newmax < vm->def->mem.cur_balloon) {
lxcError(VIR_ERR_INVALID_ARG,
"%s", _("Cannot set max memory lower than current memory"));
goto cleanup;
}
- vm->def->maxmem = newmax;
+ vm->def->mem.max_balloon = newmax;
ret = 0;
cleanup:
goto cleanup;
}
- if (newmem > vm->def->maxmem) {
+ if (newmem > vm->def->mem.max_balloon) {
lxcError(VIR_ERR_INVALID_ARG,
"%s", _("Cannot set memory higher than max memory"));
goto cleanup;
virBufferVSprintf(&buf,"#OpenNebula Template automatically generated by libvirt\nNAME = %s\nCPU = %ld\nMEMORY = %ld\n",
def->name,
def->vcpus,
- (def->maxmem)/1024);
+ (def->mem.max_balloon)/1024);
/*Optional Booting OpenNebula Information:*/
if (def->os.kernel) {
cptr=strstr(vm_info,"MEMORY");
cptr=index(cptr,':');
cptr++;
- vm->def->memory = atoi(cptr);
+ vm->def->mem.cur_balloon = atoi(cptr);
//run time:
cptr=strstr(vm_info,"START TIME");
}
info->state = vm->state;
- info->maxMem = vm->def->maxmem;
- info->memory = vm->def->memory;
+ info->maxMem = vm->def->mem.max_balloon;
+ info->memory = vm->def->mem.cur_balloon;
info->nrVirtCpu = vm->def->vcpus;
virDomainObjUnlock(vm);
NULL, /* domainRevertToSnapshot */
NULL, /* domainSnapshotDelete */
NULL, /* qemuDomainMonitorCommand */
+ NULL, /* domainSetMemoryParameters */
+ NULL, /* domainGetMemoryParameters */
};
static virStateDriver oneStateDriver = {
}
}
- info->maxMem = vm->def->maxmem;
- info->memory = vm->def->memory;
+ info->maxMem = vm->def->mem.max_balloon;
+ info->memory = vm->def->mem.cur_balloon;
info->nrVirtCpu = vm->def->vcpus;
ret = 0;
}
}
- if (vm->def->memory > 0) {
- if (openvzDomainSetMemoryInternal(vm, vm->def->memory) < 0) {
+ if (vm->def->mem.cur_balloon > 0) {
+ if (openvzDomainSetMemoryInternal(vm, vm->def->mem.cur_balloon) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not set memory size"));
goto cleanup;
goto err;
}
- if ((def.maxmem =
+ if ((def.mem.max_balloon =
phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0) {
VIR_ERROR0(_("Unable to determine domain's max memory."));
goto err;
}
- if ((def.memory =
+ if ((def.mem.cur_balloon =
phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0) {
VIR_ERROR0(_("Unable to determine domain's memory."));
goto err;
int exit_status = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (!def->memory) {
+ if (!def->mem.cur_balloon) {
PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
_("Field \"<memory>\" on the domain XML file is missing or has "
"invalid value."));
goto err;
}
- if (!def->maxmem) {
+ if (!def->mem.max_balloon) {
PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
_("Field \"<currentMemory>\" on the domain XML file is missing or"
" has invalid value."));
virBufferVSprintf(&buf, " -m %s", managed_system);
virBufferVSprintf(&buf, " -r lpar -p %s -i min_mem=%d,desired_mem=%d,"
"max_mem=%d,desired_procs=%d,virtual_scsi_adapters=%s",
- def->name, (int) def->memory, (int) def->memory,
- (int) def->maxmem, (int) def->vcpus, def->disks[0]->src);
+ def->name, (int) def->mem.cur_balloon,
+ (int) def->mem.cur_balloon, (int) def->mem.max_balloon,
+ (int) def->vcpus, def->disks[0]->src);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
* is set post-startup using the balloon driver. If balloon driver
* is not supported, then they're out of luck anyway
*/
- snprintf(memory, sizeof(memory), "%lu", def->maxmem/1024);
+ snprintf(memory, sizeof(memory), "%lu", def->mem.max_balloon/1024);
snprintf(domid, sizeof(domid), "%d", def->id);
ADD_ENV_LIT("LC_ALL=C");
ADD_ARG_LIT("-enable-kvm");
ADD_ARG_LIT("-m");
ADD_ARG_LIT(memory);
- if (def->hugepage_backed) {
+ if (def->mem.hugepage_backed) {
if (!driver->hugetlbfs_mount) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("hugetlbfs filesystem is not mounted"));
virUUIDGenerate(def->uuid);
def->id = -1;
- def->memory = def->maxmem = 64 * 1024;
+ def->mem.cur_balloon = def->mem.max_balloon = 64 * 1024;
def->vcpus = 1;
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
def->features = (1 << VIR_DOMAIN_FEATURE_ACPI)
_("cannot parse memory level '%s'"), val);
goto error;
}
- def->memory = def->maxmem = mem * 1024;
+ def->mem.cur_balloon = def->mem.max_balloon = mem * 1024;
} else if (STREQ(arg, "-smp")) {
WANT_VALUE();
if (qemuParseCommandLineSmp(def, val) < 0)
DEBUG0("Setting initial memory amount");
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorSetBalloon(priv->mon, vm->def->memory) < 0) {
+ if (qemuMonitorSetBalloon(priv->mon, vm->def->mem.cur_balloon) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
goto cleanup;
}
goto cleanup;
}
- ret = vm->def->maxmem;
+ ret = vm->def->mem.max_balloon;
cleanup:
if (vm)
goto cleanup;
}
- if (newmem > vm->def->maxmem) {
+ if (newmem > vm->def->mem.max_balloon) {
qemuReportError(VIR_ERR_INVALID_ARG,
"%s", _("cannot set memory higher than max memory"));
goto cleanup;
}
}
- info->maxMem = vm->def->maxmem;
+ info->maxMem = vm->def->mem.max_balloon;
if (virDomainObjIsActive(vm)) {
qemuDomainObjPrivatePtr priv = vm->privateData;
if ((vm->def->memballoon != NULL) &&
(vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)) {
- info->memory = vm->def->maxmem;
+ info->memory = vm->def->mem.max_balloon;
} else if (!priv->jobActive) {
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
if (err == 0)
/* Balloon not supported, so maxmem is always the allocation */
- info->memory = vm->def->maxmem;
+ info->memory = vm->def->mem.max_balloon;
else
info->memory = balloon;
goto cleanup;
}
} else {
- info->memory = vm->def->memory;
+ info->memory = vm->def->mem.cur_balloon;
}
} else {
- info->memory = vm->def->memory;
+ info->memory = vm->def->mem.cur_balloon;
}
info->nrVirtCpu = vm->def->vcpus;
if (err < 0)
goto cleanup;
if (err > 0)
- vm->def->memory = balloon;
+ vm->def->mem.cur_balloon = balloon;
/* err == 0 indicates no balloon support, so ignore it */
}
}
}
info->state = privdom->state;
- info->memory = privdom->def->memory;
- info->maxMem = privdom->def->maxmem;
+ info->memory = privdom->def->mem.cur_balloon;
+ info->maxMem = privdom->def->mem.max_balloon;
info->nrVirtCpu = privdom->def->vcpus;
info->cpuTime = ((tv.tv_sec * 1000ll * 1000ll * 1000ll) + (tv.tv_usec * 1000ll));
ret = 0;
goto cleanup;
}
- ret = privdom->def->maxmem;
+ ret = privdom->def->mem.max_balloon;
cleanup:
if (privdom)
}
/* XXX validate not over host memory wrt to other domains */
- privdom->def->maxmem = memory;
+ privdom->def->mem.max_balloon = memory;
ret = 0;
cleanup:
goto cleanup;
}
- if (memory > privdom->def->maxmem) {
+ if (memory > privdom->def->mem.max_balloon) {
testError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto cleanup;
}
- privdom->def->memory = memory;
+ privdom->def->mem.cur_balloon = memory;
ret = 0;
cleanup:
} \
} while (0)
- snprintf(memory, sizeof(memory), "%luK", vm->def->memory);
+ snprintf(memory, sizeof(memory), "%luK", vm->def->mem.cur_balloon);
ADD_ENV_LIT("LC_ALL=C");
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
- ret = vm->def->maxmem;
+ ret = vm->def->mem.max_balloon;
cleanup:
if (vm)
goto cleanup;
}
- if (newmax < vm->def->memory) {
+ if (newmax < vm->def->mem.cur_balloon) {
umlReportError(VIR_ERR_INVALID_ARG, "%s",
_("cannot set max memory lower than current memory"));
goto cleanup;
}
- vm->def->maxmem = newmax;
+ vm->def->mem.max_balloon = newmax;
ret = 0;
cleanup:
goto cleanup;
}
- if (newmem > vm->def->maxmem) {
+ if (newmem > vm->def->mem.max_balloon) {
umlReportError(VIR_ERR_INVALID_ARG, "%s",
_("cannot set memory higher than max memory"));
goto cleanup;
}
- vm->def->memory = newmem;
+ vm->def->mem.cur_balloon = newmem;
ret = 0;
cleanup:
}
}
- info->maxMem = vm->def->maxmem;
- info->memory = vm->def->memory;
+ info->maxMem = vm->def->mem.max_balloon;
+ info->memory = vm->def->mem.cur_balloon;
info->nrVirtCpu = vm->def->vcpus;
ret = 0;
if (STREQ(dom->name, machineName)) {
/* Get the Machine State (also match it with
* virDomainState). Get the Machine memory and
- * for time being set maxmem and memory to same
+ * for time being set max_balloon and cur_balloon to same
* Also since there is no direct way of checking
* the cputime required (one condition being the
* VM is remote), return zero for cputime. Get the
info->cpuTime = 0;
info->nrVirtCpu = CPUCount;
- info->memory = memorySize * 1024;
- info->maxMem = maxMemorySize * 1024;
+ info->mem.cur_balloon = memorySize * 1024;
+ info->mem.max_balloon = maxMemorySize * 1024;
switch(state) {
case MachineState_Running:
info->state = VIR_DOMAIN_RUNNING;
def->name = strdup(dom->name);
machine->vtbl->GetMemorySize(machine, &memorySize);
- def->memory = memorySize * 1024;
+ def->mem.cur_balloon = memorySize * 1024;
data->vboxObj->vtbl->GetSystemProperties(data->vboxObj, &systemProperties);
if (systemProperties) {
* the notation here seems to be inconsistent while
* reading and while dumping xml
*/
- /* def->maxmem = maxMemorySize * 1024; */
- def->maxmem = memorySize * 1024;
+ /* def->mem.max_balloon = maxMemorySize * 1024; */
+ def->mem.max_balloon = memorySize * 1024;
machine->vtbl->GetCPUCount(machine, &CPUCount);
def->vcpus = CPUCount;
goto cleanup;
}
- rc = machine->vtbl->SetMemorySize(machine, def->memory / 1024);
+ rc = machine->vtbl->SetMemorySize(machine, def->mem.cur_balloon / 1024);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not set the memory size of the domain to: %lu Kb, "
"rc=%08x"),
- def->memory, (unsigned)rc);
+ def->mem.cur_balloon, (unsigned)rc);
}
rc = machine->vtbl->SetCPUCount(machine, def->vcpus);
}
}
- def->maxmem = (unsigned long) (sexpr_u64(root, "domain/maxmem") << 10);
- def->memory = (unsigned long) (sexpr_u64(root, "domain/memory") << 10);
- if (def->memory > def->maxmem)
- def->maxmem = def->memory;
+ def->mem.max_balloon = (unsigned long)
+ (sexpr_u64(root, "domain/maxmem") << 10);
+ def->mem.cur_balloon = (unsigned long)
+ (sexpr_u64(root, "domain/memory") << 10);
+ if (def->mem.cur_balloon > def->mem.max_balloon)
+ def->mem.cur_balloon = def->mem.max_balloon;
if (cpus != NULL) {
def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
virBufferAddLit(&buf, "(vm ");
virBufferVSprintf(&buf, "(name '%s')", def->name);
virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)",
- def->memory/1024, def->maxmem/1024);
+ def->mem.cur_balloon/1024, def->mem.max_balloon/1024);
virBufferVSprintf(&buf, "(vcpus %lu)", def->vcpus);
if (def->cpumask) {
goto error;
memset(info, 0, sizeof(virDomainInfo));
- info->maxMem = entry->def->maxmem;
- info->memory = entry->def->memory;
+ info->maxMem = entry->def->mem.max_balloon;
+ info->memory = entry->def->mem.cur_balloon;
info->nrVirtCpu = entry->def->vcpus;
info->state = VIR_DOMAIN_SHUTOFF;
info->cpuTime = 0;
goto cleanup;
}
- if (xenXMConfigGetULong(conf, "memory", &def->memory, MIN_XEN_GUEST_SIZE * 2) < 0)
+ if (xenXMConfigGetULong(conf, "memory", &def->mem.cur_balloon,
+ MIN_XEN_GUEST_SIZE * 2) < 0)
goto cleanup;
- if (xenXMConfigGetULong(conf, "maxmem", &def->maxmem, def->memory) < 0)
+ if (xenXMConfigGetULong(conf, "maxmem", &def->mem.max_balloon,
+ def->mem.cur_balloon) < 0)
goto cleanup;
- def->memory *= 1024;
- def->maxmem *= 1024;
+ def->mem.cur_balloon *= 1024;
+ def->mem.max_balloon *= 1024;
if (xenXMConfigGetULong(conf, "vcpus", &def->vcpus, 1) < 0)
if (!(entry = virHashLookup(priv->configCache, filename)))
goto cleanup;
- entry->def->memory = memory;
- if (entry->def->memory > entry->def->maxmem)
- entry->def->memory = entry->def->maxmem;
+ entry->def->mem.cur_balloon = memory;
+ if (entry->def->mem.cur_balloon > entry->def->mem.max_balloon)
+ entry->def->mem.cur_balloon = entry->def->mem.max_balloon;
/* If this fails, should we try to undo our changes to the
* in-memory representation of the config file. I say not!
if (!(entry = virHashLookup(priv->configCache, filename)))
goto cleanup;
- entry->def->maxmem = memory;
- if (entry->def->memory > entry->def->maxmem)
- entry->def->memory = entry->def->maxmem;
+ entry->def->mem.max_balloon = memory;
+ if (entry->def->mem.cur_balloon > entry->def->mem.max_balloon)
+ entry->def->mem.cur_balloon = entry->def->mem.max_balloon;
/* If this fails, should we try to undo our changes to the
* in-memory representation of the config file. I say not!
if (!(entry = virHashLookup(priv->configCache, filename)))
goto cleanup;
- ret = entry->def->maxmem;
+ ret = entry->def->mem.max_balloon;
cleanup:
xenUnifiedUnlock(priv);
if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
goto no_memory;
- if (xenXMConfigSetInt(conf, "maxmem", def->maxmem / 1024) < 0)
+ if (xenXMConfigSetInt(conf, "maxmem", def->mem.max_balloon / 1024) < 0)
goto no_memory;
- if (xenXMConfigSetInt(conf, "memory", def->memory / 1024) < 0)
+ if (xenXMConfigSetInt(conf, "memory", def->mem.cur_balloon / 1024) < 0)
goto no_memory;
if (xenXMConfigSetInt(conf, "vcpus", def->vcpus) < 0)
}
unsigned long memory=0;
memory = xenapiDomainGetMaxMemory(dom);
- defPtr->maxmem = memory;
+ defPtr->mem.max_balloon = memory;
int64_t dynamic_mem=0;
if (xen_vm_get_memory_dynamic_max(session, &dynamic_mem, vm)) {
- defPtr->memory = (unsigned long) (dynamic_mem / 1024);
+ defPtr->mem.cur_balloon = (unsigned long) (dynamic_mem / 1024);
} else {
- defPtr->memory = memory;
+ defPtr->mem.cur_balloon = memory;
}
defPtr->vcpus = xenapiDomainGetMaxVcpus(dom);
enum xen_on_normal_exit action;
if (!((*record)->pv_bootloader_args = strdup(def->os.bootloaderArgs)))
goto error_cleanup;
- if (def->memory)
- (*record)->memory_static_max = (int64_t) (def->memory * 1024);
- if (def->maxmem)
- (*record)->memory_dynamic_max = (int64_t) (def->maxmem * 1024);
+ if (def->mem.cur_balloon)
+ (*record)->memory_static_max = (int64_t) (def->mem.cur_balloon * 1024);
+ if (def->mem.max_balloon)
+ (*record)->memory_dynamic_max = (int64_t) (def->mem.max_balloon * 1024);
else
(*record)->memory_dynamic_max = (*record)->memory_static_max;
--- /dev/null
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -name QEMUGuest1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <memtune>
+ <hard_limit>512000</hard_limit>
+ <soft_limit>128000</soft_limit>
+ <swap_hard_limit>1024000</swap_hard_limit>
+ </memtune>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
DO_TEST("hostdev-pci-address");
DO_TEST("encrypted-disk");
+ DO_TEST("memtune");
/* These tests generate different XML */
DO_TEST_DIFFERENT("balloon-device-auto");