[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 1/5] libxl: introduce libxl__device_model_xs_path



On Thu, 2015-03-19 at 13:18 +0000, Wei Liu wrote:
> Introduce this helper to return xenstore path for device model to avoid
> handcoded paths.
> 
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/libxl/libxl_internal.c | 22 ++++++++++++++++++++++
>  tools/libxl/libxl_internal.h |  3 +++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> index ddc68ab..8877288 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -555,6 +555,28 @@ void libxl__update_domain_configuration(libxl__gc *gc,
>      dst->b_info.video_memkb = src->b_info.video_memkb;
>  }
>  
> +char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid,
> +                                  uint32_t domid, const char *format,  ...)
> +{
> +    char *s, *fmt;
> +    va_list ap;
> +    int ret;
> +
> +    fmt = GCSPRINTF("/local/domain/%u/device-model/%u%s", dm_domid,
> +                    domid, format);
> +
> +    va_start(ap, format);
> +    ret = vsnprintf(NULL, 0, fmt, ap);
> +    va_end(ap);
> +
> +    s = libxl__zalloc(gc, ret + 1);
> +    va_start(ap, format);
> +    ret = vsnprintf(s, ret + 1, fmt, ap);
> +    va_end(ap);

Please could you refactor the existing libxl__sprintf into a
libxl__vsprintf (i.e. which takes a va_list, and uses va_copy for the
two calls to vsnprintf). Then implement your new helper in terms of the
libxl__vsprintf.

> +
> +    return s;
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 934465a..9ef2ec6 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -1794,6 +1794,9 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc 
> *gc_opt, const char *s);
>  _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t 
> domid);
>    /* Return the system-wide default device model */
>  _hidden libxl_device_model_version libxl__default_device_model(libxl__gc 
> *gc);
> +_hidden char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid,
> +                                          uint32_t domid,
> +                                          const char *format,  ...);
>  
>  /* Check how executes hotplug script currently */
>  int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t);



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.