conf: Rename max_balloon to total_memory

The name of the variable was misleading. Rename it and it's setting
accessor before other fixes.
This commit is contained in:
Peter Krempa 2015-09-16 14:25:42 +02:00
parent 849b5fc4f6
commit 8059a99025
20 changed files with 35 additions and 34 deletions

View File

@ -7706,27 +7706,27 @@ virDomainDefGetMemoryInitial(virDomainDefPtr def)
if ((ret = virDomainNumaGetMemorySize(def->numa)) > 0) {
return ret;
} else {
ret = def->mem.max_balloon;
ret = def->mem.total_memory;
for (i = 0; i < def->nmems; i++)
ret -= def->mems[i]->size;
}
return def->mem.max_balloon;
return def->mem.total_memory;
}
/**
* virDomainDefSetMemoryInitial:
* virDomainDefSetMemoryTotal:
* @def: domain definition
* @size: size to set
*
* Sets the initial memory size in @def.
* Sets the total memory size in @def.
*/
void
virDomainDefSetMemoryInitial(virDomainDefPtr def,
unsigned long long size)
virDomainDefSetMemoryTotal(virDomainDefPtr def,
unsigned long long size)
{
def->mem.max_balloon = size;
def->mem.total_memory = size;
}
@ -7748,7 +7748,7 @@ virDomainDefGetMemoryActual(virDomainDefPtr def)
for (i = 0; i < def->nmems; i++)
ret += def->mems[i]->size;
} else {
ret = def->mem.max_balloon;
ret = def->mem.total_memory;
}
return ret;
@ -14763,7 +14763,7 @@ virDomainDefParseXML(xmlDocPtr xml,
/* Extract domain memory */
if (virDomainParseMemory("./memory[1]", NULL, ctxt,
&def->mem.max_balloon, false, true) < 0)
&def->mem.total_memory, false, true) < 0)
goto error;
if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt,

View File

@ -2142,8 +2142,9 @@ typedef struct _virDomainMemtune virDomainMemtune;
typedef virDomainMemtune *virDomainMemtunePtr;
struct _virDomainMemtune {
unsigned long long max_balloon; /* in kibibytes, capped at ulong thanks
to virDomainGetMaxMemory */
/* total memory size including memory modules in kibibytes, this field
* should be accessed only via accessors */
unsigned long long total_memory;
unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
to virDomainGetInfo */
@ -2322,7 +2323,7 @@ struct _virDomainDef {
};
unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);

View File

@ -870,7 +870,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
if (VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes) < 0)
goto cleanup;
virDomainDefSetMemoryInitial(def, memorySettingData->data->Limit * 1024); /* megabyte to kilobyte */
virDomainDefSetMemoryTotal(def, memorySettingData->data->Limit * 1024); /* megabyte to kilobyte */
def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
def->vcpus = processorSettingData->data->VirtualQuantity;

View File

@ -227,7 +227,7 @@ virDomainDefParseFile;
virDomainDefParseNode;
virDomainDefParseString;
virDomainDefPostParse;
virDomainDefSetMemoryInitial;
virDomainDefSetMemoryTotal;
virDomainDeleteConfig;
virDomainDeviceAddressIsValid;
virDomainDeviceAddressTypeToString;

View File

@ -553,7 +553,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
vm->def->vcpus = d_info.vcpu_online;
vm->def->maxvcpus = d_info.vcpu_max_id + 1;
vm->def->mem.cur_balloon = d_info.current_memkb;
virDomainDefSetMemoryInitial(vm->def, d_info.max_memkb);
virDomainDefSetMemoryTotal(vm->def, d_info.max_memkb);
ret = 0;
@ -1498,7 +1498,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (flags & VIR_DOMAIN_MEM_CONFIG) {
/* Help clang 2.8 decipher the logic flow. */
sa_assert(persistentDef);
virDomainDefSetMemoryInitial(persistentDef, newmem);
virDomainDefSetMemoryTotal(persistentDef, newmem);
if (persistentDef->mem.cur_balloon > newmem)
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);

View File

@ -734,7 +734,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
virDomainDefSetMemoryInitial(persistentDef, newmem);
virDomainDefSetMemoryTotal(persistentDef, newmem);
if (persistentDef->mem.cur_balloon > newmem)
persistentDef->mem.cur_balloon = newmem;
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)

View File

@ -770,7 +770,7 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
if (lxcConvertSize(value->str, &size) < 0)
return -1;
size = size / 1024;
virDomainDefSetMemoryInitial(def, size);
virDomainDefSetMemoryTotal(def, size);
def->mem.hard_limit = virMemoryLimitTruncate(size);
}
@ -1010,7 +1010,7 @@ lxcParseConfigString(const char *config)
}
vmdef->id = -1;
virDomainDefSetMemoryInitial(vmdef, 64 * 1024);
virDomainDefSetMemoryTotal(vmdef, 64 * 1024);
vmdef->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
vmdef->onCrash = VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY;

View File

@ -3281,7 +3281,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
goto err;
}
virDomainDefSetMemoryInitial(&def, memory);
virDomainDefSetMemoryTotal(&def, memory);
if ((def.mem.cur_balloon =
phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0) {

View File

@ -13010,7 +13010,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
def->id = -1;
def->mem.cur_balloon = 64 * 1024;
virDomainDefSetMemoryInitial(def, def->mem.cur_balloon);
virDomainDefSetMemoryTotal(def, def->mem.cur_balloon);
def->maxvcpus = 1;
def->vcpus = 1;
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
@ -13216,7 +13216,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
_("cannot parse memory level '%s'"), val);
goto error;
}
virDomainDefSetMemoryInitial(def, mem * 1024);
virDomainDefSetMemoryTotal(def, mem * 1024);
def->mem.cur_balloon = mem * 1024;
} else if (STREQ(arg, "-smp")) {
WANT_VALUE();

View File

@ -3387,7 +3387,7 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
/* align initial memory size */
mem = virDomainDefGetMemoryInitial(def);
virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(mem, align));
virDomainDefSetMemoryTotal(def, VIR_ROUND_UP(mem, align));
def->mem.max_memory = VIR_ROUND_UP(def->mem.max_memory, align);

View File

@ -2357,7 +2357,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
goto endjob;
}
virDomainDefSetMemoryInitial(persistentDef, newmem);
virDomainDefSetMemoryTotal(persistentDef, newmem);
if (persistentDef->mem.cur_balloon > newmem)
persistentDef->mem.cur_balloon = newmem;

View File

@ -2256,7 +2256,7 @@ static int testDomainSetMaxMemory(virDomainPtr domain,
return -1;
/* XXX validate not over host memory wrt to other domains */
virDomainDefSetMemoryInitial(privdom->def, memory);
virDomainDefSetMemoryTotal(privdom->def, memory);
virDomainObjEndAPI(&privdom);
return 0;

View File

@ -1828,7 +1828,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
goto cleanup;
}
virDomainDefSetMemoryInitial(vm->def, newmax);
virDomainDefSetMemoryTotal(vm->def, newmax);
ret = 0;
cleanup:

View File

@ -3898,7 +3898,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
* reading and while dumping xml
*/
/* def->mem.max_balloon = maxMemorySize * 1024; */
virDomainDefSetMemoryInitial(def, memorySize * 1024);
virDomainDefSetMemoryTotal(def, memorySize * 1024);
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
def->maxvcpus = def->vcpus = CPUCount;
@ -6051,7 +6051,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
* the notation here seems to be inconsistent while
* reading and while dumping xml
*/
virDomainDefSetMemoryInitial(def->dom, memorySize * 1024);
virDomainDefSetMemoryTotal(def->dom, memorySize * 1024);
def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM;
def->dom->os.arch = virArchFromHost();
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);

View File

@ -1416,7 +1416,7 @@ virVMXParseConfig(virVMXContext *ctx,
goto cleanup;
}
virDomainDefSetMemoryInitial(def, memsize * 1024); /* Scale from megabytes to kilobytes */
virDomainDefSetMemoryTotal(def, memsize * 1024); /* Scale from megabytes to kilobytes */
/* vmx:sched.mem.max -> def:mem.cur_balloon */
if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,

View File

@ -1299,7 +1299,7 @@ prlsdkLoadDomain(vzConnPtr privconn,
/* get RAM parameters */
pret = PrlVmCfg_GetRamSize(sdkdom, &ram);
prlsdkCheckRetGoto(pret, error);
virDomainDefSetMemoryInitial(def, ram << 10); /* RAM size obtained in Mbytes,
virDomainDefSetMemoryTotal(def, ram << 10); /* RAM size obtained in Mbytes,
convert to Kbytes */
def->mem.cur_balloon = ram << 10;

View File

@ -605,7 +605,7 @@ xenXMDomainSetMaxMemory(virConnectPtr conn,
if (entry->def->mem.cur_balloon > memory)
entry->def->mem.cur_balloon = memory;
virDomainDefSetMemoryInitial(entry->def, memory);
virDomainDefSetMemoryTotal(entry->def, memory);
/* If this fails, should we try to undo our changes to the
* in-memory representation of the config file. I say not!
*/

View File

@ -1492,7 +1492,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
VIR_FREE(val);
}
memory = xenapiDomainGetMaxMemory(dom);
virDomainDefSetMemoryInitial(defPtr, memory);
virDomainDefSetMemoryTotal(defPtr, memory);
if (xen_vm_get_memory_dynamic_max(session, &dynamic_mem, vm)) {
defPtr->mem.cur_balloon = (unsigned long) (dynamic_mem / 1024);
} else {

View File

@ -316,7 +316,7 @@ xenParseMem(virConfPtr conf, virDomainDefPtr def)
return -1;
def->mem.cur_balloon *= 1024;
virDomainDefSetMemoryInitial(def, memory * 1024);
virDomainDefSetMemoryTotal(def, memory * 1024);
return 0;
}

View File

@ -1154,7 +1154,7 @@ xenParseSxpr(const struct sexpr *root,
}
}
virDomainDefSetMemoryInitial(def, (sexpr_u64(root, "domain/maxmem") << 10));
virDomainDefSetMemoryTotal(def, (sexpr_u64(root, "domain/maxmem") << 10));
def->mem.cur_balloon = (sexpr_u64(root, "domain/memory") << 10);
if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def))