diff mbox series

[v3,2/4] system/vl: extract overcommit option parsing into a helper

Message ID 20241211230433.1371327-3-d-tatianin@yandex-team.ru (mailing list archive)
State New
Headers show
Series overcommit: introduce mem-lock-onfault | expand

Commit Message

Daniil Tatianin Dec. 11, 2024, 11:04 p.m. UTC
This will be extended in the future commits, let's move it out of line
right away so that it's easier to read.

Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
 system/vl.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/system/vl.c b/system/vl.c
index 03819a80ef..f0b3ad0df7 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1855,6 +1855,19 @@  static void object_option_parse(const char *str)
     visit_free(v);
 }
 
+static void overcommit_parse(const char *str)
+{
+    QemuOpts *opts;
+
+    opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
+                                   str, false);
+    if (!opts) {
+        exit(1);
+    }
+    enable_mlock = qemu_opt_get_bool(opts, "mem-lock", enable_mlock);
+    enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", enable_cpu_pm);
+}
+
 /*
  * Very early object creation, before the sandbox options have been activated.
  */
@@ -3532,13 +3545,7 @@  void qemu_init(int argc, char **argv)
                 object_option_parse(optarg);
                 break;
             case QEMU_OPTION_overcommit:
-                opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
-                                               optarg, false);
-                if (!opts) {
-                    exit(1);
-                }
-                enable_mlock = qemu_opt_get_bool(opts, "mem-lock", enable_mlock);
-                enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", enable_cpu_pm);
+                overcommit_parse(optarg);
                 break;
             case QEMU_OPTION_compat:
                 {