summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDaniil Tatianin <d-tatianin@yandex-team.ru>2025-02-12 17:39:18 +0300
committerPeter Xu <peterx@redhat.com>2025-02-12 11:36:13 -0500
commitcb74f2b8a65cde2eadbcb5574327ac3f49983d8a (patch)
tree6cb28273e17b1fbc7ac0aabdf8d82980645a40f0
parente76fadf93e4d64492206b34fd3d434b515450d2c (diff)
downloadfocaccia-qemu-cb74f2b8a65cde2eadbcb5574327ac3f49983d8a.tar.gz
focaccia-qemu-cb74f2b8a65cde2eadbcb5574327ac3f49983d8a.zip
system/vl: extract overcommit option parsing into a helper
This will be extended in the future commits, let's move it out of line
right away so that it's easier to read.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Link: https://lore.kernel.org/r/20250212143920.1269754-3-d-tatianin@yandex-team.ru
Signed-off-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to '')
-rw-r--r--system/vl.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/system/vl.c b/system/vl.c
index e94fc7ea35..72a40985f5 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1875,6 +1875,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.
  */
@@ -3575,13 +3588,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:
                 {