qemu: Introduce qemuBuildMemCommandLine
Add new function to manage adding the '-m' memory options to the command line removing that task from the mainline qemuBuildCommandLine Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
d238b51f00
commit
aa076fe8e4
@ -5225,7 +5225,7 @@ qemuBuildSmpArgStr(const virDomainDef *def,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
|
qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
|
||||||
virDomainDefPtr def,
|
const virDomainDef *def,
|
||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
virCommandPtr cmd)
|
virCommandPtr cmd)
|
||||||
{
|
{
|
||||||
@ -5288,6 +5288,53 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuBuildMemCommandLine(virCommandPtr cmd,
|
||||||
|
virQEMUDriverConfigPtr cfg,
|
||||||
|
const virDomainDef *def,
|
||||||
|
virQEMUCapsPtr qemuCaps)
|
||||||
|
{
|
||||||
|
if (qemuDomainDefValidateMemoryHotplug(def, qemuCaps, NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
virCommandAddArg(cmd, "-m");
|
||||||
|
|
||||||
|
if (virDomainDefHasMemoryHotplug(def)) {
|
||||||
|
/* Use the 'k' suffix to let qemu handle the units */
|
||||||
|
virCommandAddArgFormat(cmd, "size=%lluk,slots=%u,maxmem=%lluk",
|
||||||
|
virDomainDefGetMemoryInitial(def),
|
||||||
|
def->mem.memory_slots,
|
||||||
|
def->mem.max_memory);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
virCommandAddArgFormat(cmd, "%llu",
|
||||||
|
virDomainDefGetMemoryInitial(def) / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add '-mem-path' (and '-mem-prealloc') parameter here only if
|
||||||
|
* there is no numa node specified.
|
||||||
|
*/
|
||||||
|
if (!virDomainNumaGetNodeCount(def->numa) &&
|
||||||
|
qemuBuildMemPathStr(cfg, def, qemuCaps, cmd) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (def->mem.locked && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_MLOCK)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("memory locking not supported by QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MLOCK)) {
|
||||||
|
virCommandAddArg(cmd, "-realtime");
|
||||||
|
virCommandAddArgFormat(cmd, "mlock=%s",
|
||||||
|
def->mem.locked ? "on" : "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
@ -6827,45 +6874,12 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0)
|
if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!migrateURI && !snapshot &&
|
if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0)
|
||||||
qemuDomainAlignMemorySizes(def) < 0)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (qemuDomainDefValidateMemoryHotplug(def, qemuCaps, NULL) < 0)
|
if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-m");
|
|
||||||
|
|
||||||
if (virDomainDefHasMemoryHotplug(def)) {
|
|
||||||
/* Use the 'k' suffix to let qemu handle the units */
|
|
||||||
virCommandAddArgFormat(cmd, "size=%lluk,slots=%u,maxmem=%lluk",
|
|
||||||
virDomainDefGetMemoryInitial(def),
|
|
||||||
def->mem.memory_slots,
|
|
||||||
def->mem.max_memory);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
virCommandAddArgFormat(cmd, "%llu", virDomainDefGetMemoryInitial(def) / 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add '-mem-path' (and '-mem-prealloc') parameter here only if
|
|
||||||
* there is no numa node specified.
|
|
||||||
*/
|
|
||||||
if (!virDomainNumaGetNodeCount(def->numa) &&
|
|
||||||
qemuBuildMemPathStr(cfg, def, qemuCaps, cmd) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (def->mem.locked && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_MLOCK)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("memory locking not supported by QEMU binary"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MLOCK)) {
|
|
||||||
virCommandAddArg(cmd, "-realtime");
|
|
||||||
virCommandAddArgFormat(cmd, "mlock=%s",
|
|
||||||
def->mem.locked ? "on" : "off");
|
|
||||||
}
|
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-smp");
|
virCommandAddArg(cmd, "-smp");
|
||||||
if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
|
if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user