[PATCH v3 1/2] qemu: parse: Use qemuParseCommandLineMem for -m memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move the parsing of -m memory to a new function, qemuParseCommandLineMem

Signed-off-by: Nishith Shah <nishithshah.2211@xxxxxxxxx>
---
 src/qemu/qemu_parse_command.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index e30586f..d0a9dc0 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1633,6 +1633,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
 qemuParseCommandLineSmp(virDomainDefPtr dom,
                         const char *val)
 {
@@ -1869,15 +1889,9 @@ qemuParseCommandLine(virCapsPtr caps,
         } else if (STREQ(arg, "-sdl")) {
             have_sdl = true;
         } else if (STREQ(arg, "-m")) {
-            int mem;
             WANT_VALUE();
-            if (virStrToLong_i(val, NULL, 10, &mem) < 0) {
-                virReportError(VIR_ERR_INTERNAL_ERROR, \
-                               _("cannot parse memory level '%s'"), val);
+            if (qemuParseCommandLineMem(def, val) < 0)
                 goto error;
-            }
-            virDomainDefSetMemoryTotal(def, mem * 1024);
-            def->mem.cur_balloon = mem * 1024;
         } else if (STREQ(arg, "-smp")) {
             WANT_VALUE();
             if (qemuParseCommandLineSmp(def, val) < 0)
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]