diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index d0a9dc0dccf9fde2c28f77c3968cec147d96e1e2..fb8d3d8045b89515f7eb8bb24e0749791da9bebd 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1645,8 +1645,15 @@ qemuParseCommandLineMem(virDomainDefPtr dom, return -1; } - virDomainDefSetMemoryTotal(dom, mem * 1024); - dom->mem.cur_balloon = mem * 1024; + if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot scale memory: %s"), + virGetLastErrorMessage()); + return -1; + } + + virDomainDefSetMemoryTotal(dom, mem / 1024); + dom->mem.cur_balloon = mem / 1024; return 0; } diff --git a/tests/qemuargv2xmldata/qemuargv2xml-mem-scale.args b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale.args new file mode 100644 index 0000000000000000000000000000000000000000..90da94d46e8ce54d05e5753aa51d94af4fa6af1a --- /dev/null +++ b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 2G \ +-smp 1,maxcpus=2,sockets=2,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-monitor unix:/tmp/test-monitor,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=ide,bus=0,unit=0 \ +-net none \ +-serial none \ +-parallel none diff --git a/tests/qemuargv2xmldata/qemuargv2xml-mem-scale.xml b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale.xml new file mode 100644 index 0000000000000000000000000000000000000000..d4091f7708c78cf8fbfbcc773b42e5edf3614bb2 --- /dev/null +++ b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale.xml @@ -0,0 +1,37 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 2097152 + 2097152 + 2 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + +
+ + +
+ + + +
+ + + + + + diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 73d3f5c221dfe00acd8dde88365d3e66c59d88de..0fe6b9b016365b711061873f2a2196a31e42137b 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -263,6 +263,7 @@ mymain(void) DO_TEST("hostdev-pci-address"); + DO_TEST("mem-scale"); DO_TEST("smp"); DO_TEST("hyperv");