diff mbox series

[v4,06/16] libxl: write qemu arguments into separate xenstore keys

Message ID cd76e3559f841d3072558d9c603dc686f67d54c1.1579055705.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State New, archived
Headers show
Series Add support for qemu-xen runnning in a Linux-based stubdomain. | expand

Commit Message

Marek Marczykowski-Górecki Jan. 15, 2020, 2:39 a.m. UTC
This allows using arguments with spaces, like -append, without
nominating any special "separator" character.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
Changes in v3:
 - previous version of this patch "libxl: use \x1b to separate qemu
   arguments for linux stubdomain" used specific non-printable
   separator, but it was rejected as xenstore doesn't cope well with
   non-printable chars
---
 tools/libxl/libxl_dm.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

Comments

Jason Andryuk Jan. 20, 2020, 7:36 p.m. UTC | #1
On Tue, Jan 14, 2020 at 9:41 PM Marek Marczykowski-Górecki
<marmarek@invisiblethingslab.com> wrote:
>
> This allows using arguments with spaces, like -append, without
> nominating any special "separator" character.
>
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> ---
> Changes in v3:
>  - previous version of this patch "libxl: use \x1b to separate qemu
>    arguments for linux stubdomain" used specific non-printable
>    separator, but it was rejected as xenstore doesn't cope well with
>    non-printable chars
> ---

The code looks good.

Reviewed-by: Jason Andryuk <jandryuk@gmail.com>

One thought I have is dmargs is a string for mini-os and a directory
for linux stubdom.  It's toolstack managed, so it's not a problem.
But would a different xenstore node be less surprising to humans?

Regards,
Jason
Marek Marczykowski-Górecki Jan. 21, 2020, 9:19 p.m. UTC | #2
On Mon, Jan 20, 2020 at 02:36:08PM -0500, Jason Andryuk wrote:
> On Tue, Jan 14, 2020 at 9:41 PM Marek Marczykowski-Górecki
> <marmarek@invisiblethingslab.com> wrote:
> >
> > This allows using arguments with spaces, like -append, without
> > nominating any special "separator" character.
> >
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > ---
> > Changes in v3:
> >  - previous version of this patch "libxl: use \x1b to separate qemu
> >    arguments for linux stubdomain" used specific non-printable
> >    separator, but it was rejected as xenstore doesn't cope well with
> >    non-printable chars
> > ---
> 
> The code looks good.
> 
> Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
> 
> One thought I have is dmargs is a string for mini-os and a directory
> for linux stubdom.  It's toolstack managed, so it's not a problem.
> But would a different xenstore node be less surprising to humans?

dmargs_list?
Jason Andryuk Jan. 22, 2020, 2:39 p.m. UTC | #3
On Tue, Jan 21, 2020 at 4:19 PM Marek Marczykowski-Górecki
<marmarek@invisiblethingslab.com> wrote:
>
> On Mon, Jan 20, 2020 at 02:36:08PM -0500, Jason Andryuk wrote:
> > On Tue, Jan 14, 2020 at 9:41 PM Marek Marczykowski-Górecki
> > <marmarek@invisiblethingslab.com> wrote:
> > >
> > > This allows using arguments with spaces, like -append, without
> > > nominating any special "separator" character.
> > >
> > > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > > ---
> > > Changes in v3:
> > >  - previous version of this patch "libxl: use \x1b to separate qemu
> > >    arguments for linux stubdomain" used specific non-printable
> > >    separator, but it was rejected as xenstore doesn't cope well with
> > >    non-printable chars
> > > ---
> >
> > The code looks good.
> >
> > Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
> >
> > One thought I have is dmargs is a string for mini-os and a directory
> > for linux stubdom.  It's toolstack managed, so it's not a problem.
> > But would a different xenstore node be less surprising to humans?
>
> dmargs_list?

dmargs_list works.  dmargv to mimic argv?  That might be too subtle.

I'm not asking for the change.  I just wanted to bring it up for discussion.

Regards,
Jason
diff mbox series

Patch

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 926d963..bf49262 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -2049,6 +2049,40 @@  static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
     return 0;
 }
 
+static int libxl__write_stub_linux_dmargs(libxl__gc *gc,
+                                    int dm_domid, int guest_domid,
+                                    char **args)
+{
+    libxl_ctx *ctx = libxl__gc_owner(gc);
+    int i;
+    char *vm_path;
+    char *path;
+    struct xs_permissions roperm[2];
+    xs_transaction_t t;
+
+    roperm[0].id = 0;
+    roperm[0].perms = XS_PERM_NONE;
+    roperm[1].id = dm_domid;
+    roperm[1].perms = XS_PERM_READ;
+
+    vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("/local/domain/%d/vm", guest_domid));
+    path = GCSPRINTF("%s/image/dmargs", vm_path);
+
+retry_transaction:
+    t = xs_transaction_start(ctx->xsh);
+    xs_write(ctx->xsh, t, path, "", 0);
+    xs_set_permissions(ctx->xsh, t, path, roperm, ARRAY_SIZE(roperm));
+    i = 1;
+    for (i=1; args[i] != NULL; i++)
+        xs_write(ctx->xsh, t, GCSPRINTF("%s/%03d", path, i), args[i], strlen(args[i]));
+
+    xs_set_permissions(ctx->xsh, t, GCSPRINTF("%s/rtc/timeoffset", vm_path), roperm, ARRAY_SIZE(roperm));
+    if (!xs_transaction_end(ctx->xsh, t, 0))
+        if (errno == EAGAIN)
+            goto retry_transaction;
+    return 0;
+}
+
 static int libxl__write_stub_dmargs(libxl__gc *gc,
                                     int dm_domid, int guest_domid,
                                     char **args)
@@ -2258,7 +2292,10 @@  void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
 
     libxl__store_libxl_entry(gc, guest_domid, "dm-version",
         libxl_device_model_version_to_string(dm_config->b_info.device_model_version));
-    libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args);
+    if (libxl__stubdomain_is_linux(&guest_config->b_info))
+        libxl__write_stub_linux_dmargs(gc, dm_domid, guest_domid, args);
+    else
+        libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args);
     libxl__xs_printf(gc, XBT_NULL,
                      GCSPRINTF("%s/image/device-model-domid",
                                libxl__xs_get_dompath(gc, guest_domid)),