All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Paul Durrant <paul.durrant@citrix.com>, xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [RFC PATCH 2/6] libxl: stop using libxl__xs_mkdir() for ~/control/shutdown
Date: Mon, 16 Nov 2015 12:55:28 +0000	[thread overview]
Message-ID: <1447678528.27871.77.camel@citrix.com> (raw)
In-Reply-To: <1447258719-21891-3-git-send-email-paul.durrant@citrix.com>

On Wed, 2015-11-11 at 16:18 +0000, Paul Durrant wrote:
> As documented in docs/misc/xenstore, the XS_MKDIR operation merely makes
> sure a path exists whereas ~/control/shutdown needs to start empty. Also
> using XS_MKDIR for a node which is never supposed to have children is
> somewhat counterintuitive.
> 
> This patch introduces a new libxl__xs_printf_perms() function analogous
> to libxl__xs_printf() but taking explicit permissions arguments, and then
> uses this to create an empty ~/control/shutdown node.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxl/libxl_create.c   | 16 ++++++++++------
>  tools/libxl/libxl_internal.h | 10 ++++++++++
>  tools/libxl/libxl_xshelp.c   | 44
> ++++++++++++++++++++++++++++++++++++++------
>  3 files changed, 58 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index 921d155..279deda 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -484,7 +484,7 @@ int libxl__domain_make(libxl__gc *gc,
> libxl_domain_config *d_config,
>      libxl_ctx *ctx = libxl__gc_owner(gc);
>      int flags, ret, rc, nb_vm;
>      char *uuid_string;
> -    char *dom_path, *vm_path, *libxl_path;
> +    char *dom_path, *vm_path, *libxl_path, *control_path;
>      struct xs_permissions roperm[2];
>      struct xs_permissions rwperm[1];
>      struct xs_permissions noperm[1];
> @@ -605,17 +605,21 @@ retry_transaction:
>      libxl__xs_mkdir(gc, t,
>                      libxl__sprintf(gc, "%s/device", dom_path),
>                      roperm, ARRAY_SIZE(roperm));
> -    libxl__xs_mkdir(gc, t,
> -                    libxl__sprintf(gc, "%s/control", dom_path),
> +
> +    control_path = libxl__sprintf(gc, "%s/control", dom_path);
> +
> +    libxl__xs_mkdir(gc, t, control_path,
>                      roperm, ARRAY_SIZE(roperm));
>      if (info->type == LIBXL_DOMAIN_TYPE_HVM)
>          libxl__xs_mkdir(gc, t,
>                          libxl__sprintf(gc, "%s/hvmloader", dom_path),
>                          roperm, ARRAY_SIZE(roperm));
>  
> -    libxl__xs_mkdir(gc, t,
> -                    libxl__sprintf(gc, "%s/control/shutdown", dom_path),
> -                    rwperm, ARRAY_SIZE(rwperm));
> +    libxl__xs_printf_perms(gc, t,
> +                           libxl__sprintf(gc, "%s/shutdown",
> control_path),
> +                           rwperm, ARRAY_SIZE(rwperm),
> +                           "");
> +
>      libxl__xs_mkdir(gc, t,
>                      libxl__sprintf(gc, "%s/device/suspend/event-
> channel", dom_path),
>                      rwperm, ARRAY_SIZE(rwperm));
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 4710804..04d8a29 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -666,6 +666,16 @@ _hidden int libxl__xs_writev_perms(libxl__gc *gc,
> xs_transaction_t t,
>  _hidden int libxl__xs_writev_atonce(libxl__gc *gc,
>                               const char *dir, char **kvs);
>  
> +_hidden int libxl__xs_vprintf_perms(libxl__gc *gc, xs_transaction_t t,
> +                                    const char *path,
> +                                    struct xs_permissions *perms,
> +                                    unsigned int num_perms,
> +                                    const char *fmt, va_list ap);
> +_hidden int libxl__xs_printf_perms(libxl__gc *gc, xs_transaction_t t,
> +                                   const char *path,
> +                                   struct xs_permissions *perms,
> +                                   unsigned int num_perms,
> +                                   const char *fmt, ...)
> PRINTF_ATTRIBUTE(6, 7);
>  _hidden int libxl__xs_printf(libxl__gc *gc, xs_transaction_t t,
>                               const char *path, const char *fmt, ...)
> PRINTF_ATTRIBUTE(4, 5);
>     /* Each fn returns 0 on success.
> diff --git a/tools/libxl/libxl_xshelp.c b/tools/libxl/libxl_xshelp.c
> index 3cac4f2..0b56f8b 100644
> --- a/tools/libxl/libxl_xshelp.c
> +++ b/tools/libxl/libxl_xshelp.c
> @@ -96,25 +96,57 @@ out:
>  
>  }
>  
> -int libxl__xs_printf(libxl__gc *gc, xs_transaction_t t,
> -                     const char *path, const char *fmt, ...)
> +int libxl__xs_vprintf_perms(libxl__gc *gc, xs_transaction_t t,
> +                            const char *path,
> +                            struct xs_permissions *perms,
> +                            unsigned int num_perms,
> +                            const char *fmt,
> +                            va_list ap)
>  {
>      libxl_ctx *ctx = libxl__gc_owner(gc);
>      char *s;
> -    va_list ap;
>      int ret;
> -    va_start(ap, fmt);
> -    ret = vasprintf(&s, fmt, ap);
> -    va_end(ap);
>  
> +    ret = vasprintf(&s, fmt, ap);
>      if (ret == -1) {
>          return -1;
>      }
>      xs_write(ctx->xsh, t, path, s, ret);
> +    if (perms)
> +        xs_set_permissions(ctx->xsh, t, path, perms, num_perms);

This can fail, can't it? (OTOH so can xs_write, so maybe there is some
reason we apparently don't care for such things here?)

>      free(s);
>      return 0;
>  }
>  
> +int libxl__xs_printf_perms(libxl__gc *gc, xs_transaction_t t,
> +                           const char *path,
> +                           struct xs_permissions *perms,
> +                           unsigned int num_perms,
> +                           const char *fmt, ...)
> +{
> +    va_list ap;
> +    int ret;
> +
> +    va_start(ap, fmt);
> +    ret = libxl__xs_vprintf_perms(gc, t, path, perms, num_perms, fmt,
> ap);
> +    va_end(ap);
> +
> +    return ret;
> +}
> +
> +int libxl__xs_printf(libxl__gc *gc, xs_transaction_t t,
> +                     const char *path, const char *fmt, ...)
> +{
> +    va_list ap;
> +    int ret;
> +
> +    va_start(ap, fmt);
> +    ret = libxl__xs_vprintf_perms(gc, t, path, NULL, 0, fmt, ap);
> +    va_end(ap);
> +
> +    return ret;
> +}
> +
>  char * libxl__xs_read(libxl__gc *gc, xs_transaction_t t, const char
> *path)
>  {
>      libxl_ctx *ctx = libxl__gc_owner(gc);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2015-11-16 12:56 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 16:18 [RFC PATCH 0/6] libxl: xenstore related changes Paul Durrant
2015-11-11 16:18 ` [RFC PATCH 1/6] libxl: re-name libxl__xs_write() to libxl__xs_printf() Paul Durrant
2015-11-11 16:18 ` [RFC PATCH 2/6] libxl: stop using libxl__xs_mkdir() for ~/control/shutdown Paul Durrant
2015-11-16 12:55   ` Ian Campbell [this message]
2015-11-16 13:16     ` Paul Durrant
2015-11-16 13:42       ` Ian Campbell
2015-11-16 13:45         ` Paul Durrant
2015-11-16 17:20   ` Ian Jackson
2015-11-16 17:22     ` Paul Durrant
2015-11-16 17:30       ` Ian Jackson
2015-11-16 17:33         ` Paul Durrant
2015-11-24 16:34           ` Ian Jackson
2015-11-24 17:20             ` Paul Durrant
2015-11-24 17:24               ` Ian Jackson
2015-11-24 17:28                 ` Paul Durrant
2015-11-24 17:38                   ` Ian Jackson
2015-11-24 17:41                     ` Paul Durrant
2015-11-24 17:44                       ` Ian Jackson
2015-11-25 10:42               ` Ian Campbell
2015-11-25 10:46                 ` Paul Durrant
2015-11-25 11:02                   ` Ian Campbell
2015-11-25 11:07                     ` Paul Durrant
2015-11-25 11:13                       ` Ian Jackson
2015-11-25 11:14                         ` Paul Durrant
2015-11-25 11:11                 ` Ian Jackson
2015-11-11 16:18 ` [RFC PATCH 3/6] libxl: implement control feature checking Paul Durrant
2015-11-16 17:24   ` Ian Jackson
2015-11-11 16:18 ` [RFC PATCH 4/6] libxl: add guest writable xenstore area for driver versions Paul Durrant
2015-11-16 17:26   ` Ian Jackson
2015-11-16 17:26     ` Ian Jackson
2015-11-11 16:18 ` [RFC PATCH 5/6] libxl: add guest writable xenstore area for feature advertisement Paul Durrant
2015-11-16 17:27   ` Ian Jackson
2015-11-11 16:18 ` [RFC PATCH 6/6] libxl: create path for advertisement of network attributes Paul Durrant
2015-11-16 17:29   ` Ian Jackson
2015-11-16 17:31     ` Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447678528.27871.77.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=paul.durrant@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.