]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
libxl: Probe QEMU for -run-with user=user and use it
authorAnthony PERARD <anthony.perard@vates.tech>
Fri, 30 Aug 2024 09:49:40 +0000 (09:49 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Aug 2024 17:14:11 +0000 (18:14 +0100)
"-runas" is deprecated since QEMU 9.1 and will be remove in a future
release.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
tools/libs/light/libxl_dm.c
tools/libs/light/libxl_internal.h

index 15b157060f067f142de08176cb41c25f50588dff..1f2f5bd97a653fbda6442e19a4f52b2b97880b3e 100644 (file)
@@ -2052,8 +2052,13 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
         }
 
         if (state->dm_runas) {
-            flexarray_append(dm_args, "-runas");
-            flexarray_append(dm_args, state->dm_runas);
+            if (qemu_opts->have_runwith_user) {
+                flexarray_append_pair(dm_args, "-run-with",
+                                      GCSPRINTF("user=%s", state->dm_runas));
+            } else {
+                flexarray_append(dm_args, "-runas");
+                flexarray_append(dm_args, state->dm_runas);
+            }
         }
     }
     flexarray_append(dm_args, NULL);
@@ -3073,6 +3078,9 @@ static void device_model_probe_cmdline(libxl__egc *egc,
                 if (!strcmp("chroot", libxl__json_object_get_string(o))) {
                     dmss->qemu_opts.have_runwith_chroot = true;
                 }
+                else if (!strcmp("user", libxl__json_object_get_string(o))) {
+                    dmss->qemu_opts.have_runwith_user = true;
+                }
             }
 
             /*
index 0133c57e01133a1f58ed301e3814ea0ed9ffc5e4..089a2f949c53b7adca24cf3605e7120ef4e2acf6 100644 (file)
@@ -4145,6 +4145,7 @@ typedef struct libxl__dm_spawn_state libxl__dm_spawn_state;
 typedef struct libxl__qemu_available_opts libxl__qemu_available_opts;
 struct libxl__qemu_available_opts {
     bool have_runwith_chroot;
+    bool have_runwith_user;
 };
 
 typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*,