[XEN PATCH 3/3] libxl: Probe QEMU for -run-with user=user and use it

Anthony PERARD posted 3 patches 2 months, 4 weeks ago
There is a newer version of this series
[XEN PATCH 3/3] libxl: Probe QEMU for -run-with user=user and use it
Posted by Anthony PERARD 2 months, 4 weeks ago
"-runas" is deprecated since QEMU 9.1 and will be remove in a future
release.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
---
 tools/libs/light/libxl_dm.c       | 12 ++++++++++--
 tools/libs/light/libxl_internal.h |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 298fbb84fe..49995b14b8 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -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_cmdline->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_cmdline.have_runwith_chroot = true;
                 }
+                else if (!strcmp("user", libxl__json_object_get_string(o))) {
+                    dmss->qemu_cmdline.have_runwith_user = true;
+                }
             }
 
             /*
diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_internal.h
index df93d904c2..5c61050f79 100644
--- a/tools/libs/light/libxl_internal.h
+++ b/tools/libs/light/libxl_internal.h
@@ -4145,6 +4145,7 @@ typedef struct libxl__dm_spawn_state libxl__dm_spawn_state;
 typedef struct libxl__qemu_available_cmd_line libxl__qemu_available_cmd_line;
 struct libxl__qemu_available_cmd_line {
     bool have_runwith_chroot;
+    bool have_runwith_user;
 };
 
 typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*,
-- 


Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [XEN PATCH 3/3] libxl: Probe QEMU for -run-with user=user and use it
Posted by Jason Andryuk 2 months, 3 weeks ago
On 2024-08-27 06:03, Anthony PERARD wrote:
> "-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>