mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: parse: Use qemuParseCommandLineMem for -m memory
Move the parsing of -m memory to a new function, qemuParseCommandLineMem Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
This commit is contained in:
parent
2c8e75554b
commit
30677a78ab
@ -1632,6 +1632,26 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuParseCommandLineMem(virDomainDefPtr dom,
|
||||||
|
const char *val)
|
||||||
|
{
|
||||||
|
unsigned long long mem;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
if (virStrToLong_ull(val, &end, 10, &mem) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("cannot parse memory level '%s'"), val);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
virDomainDefSetMemoryTotal(dom, mem * 1024);
|
||||||
|
dom->mem.cur_balloon = mem * 1024;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuParseCommandLineSmp(virDomainDefPtr dom,
|
qemuParseCommandLineSmp(virDomainDefPtr dom,
|
||||||
const char *val)
|
const char *val)
|
||||||
@ -1869,15 +1889,9 @@ qemuParseCommandLine(virCapsPtr caps,
|
|||||||
} else if (STREQ(arg, "-sdl")) {
|
} else if (STREQ(arg, "-sdl")) {
|
||||||
have_sdl = true;
|
have_sdl = true;
|
||||||
} else if (STREQ(arg, "-m")) {
|
} else if (STREQ(arg, "-m")) {
|
||||||
int mem;
|
|
||||||
WANT_VALUE();
|
WANT_VALUE();
|
||||||
if (virStrToLong_i(val, NULL, 10, &mem) < 0) {
|
if (qemuParseCommandLineMem(def, val) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
||||||
_("cannot parse memory level '%s'"), val);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
virDomainDefSetMemoryTotal(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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user