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

Re: [Xen-devel] [PATCH v4 05/34] libxc/libxl/python/xenstat: Use new XEN_VERSION_OP hypercall



On Tue, Mar 15, 2016 at 01:56:27PM -0400, Konrad Rzeszutek Wilk wrote:
[...]
> diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h
> index 303081d..2663969 100644
> --- a/tools/libxc/xg_save_restore.h
> +++ b/tools/libxc/xg_save_restore.h
> @@ -57,10 +57,12 @@ static inline int get_platform_info(xc_interface *xch, 
> uint32_t dom,
>      xen_capabilities_info_t xen_caps = "";
>      xen_platform_parameters_t xen_params;
>  
> -    if (xc_version(xch, XENVER_platform_parameters, &xen_params) != 0)
> +    if (xc_version(xch, XEN_VERSION_OP_platform_parameters, &xen_params,
> +                   sizeof(xen_params)) < 0)
>          return 0;
>  
> -    if (xc_version(xch, XENVER_capabilities, &xen_caps) != 0)
> +    if (xc_version(xch, XEN_VERSION_OP_capabilities, xen_caps,
> +                   sizeof(xen_caps)) < 0)
>          return 0;
>  
>      if (xc_maximum_ram_page(xch, max_mfn))
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 93e228d..dc660b7 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -5191,50 +5191,73 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, 
> int *nr)
>      return ret;
>  }
>  
> +
> +static int xc_version_wrapper(libxl_ctx *ctx, unsigned int cmd, char *buf, 
> ssize_t len, char **dst)
> +{

This function should accept libxl__gc *gc instead of libxl_ctx.

Preferably is should be renamed to

libxl__xc_version_wrapper

> +    GC_INIT(ctx);
> +    int r;
> +
> +    r = xc_version(ctx->xch, cmd, buf, len);

Then here CTX->xch

> +    if ( r == -EPERM )
> +        buf[0] = '\0';
> +    else if ( r < 0 )
> +    {
> +        GC_FREE;
> +        return r;
> +    }
> +    *dst = libxl__strdup(NOGC, buf);
> +    GC_FREE;

Then get rid of all GC_* macros.

> +    return 0;
> +}
> +
>  const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
[...]
> diff --git a/tools/python/xen/lowlevel/xc/xc.c 
> b/tools/python/xen/lowlevel/xc/xc.c
> index c40a4e9..23876f0 100644
> --- a/tools/python/xen/lowlevel/xc/xc.c
> +++ b/tools/python/xen/lowlevel/xc/xc.c
> @@ -1204,34 +1204,40 @@ static PyObject *pyxc_xeninfo(XcObject *self)
>      xen_capabilities_info_t xen_caps;
>      xen_platform_parameters_t p_parms;
>      xen_commandline_t xen_commandline;
> -    long xen_version;
> -    long xen_pagesize;
> +    xen_version_op_val_t xen_version;
> +    xen_version_op_val_t xen_pagesize;
>      char str[128];
>  
> -    xen_version = xc_version(self->xc_handle, XENVER_version, NULL);
> -
> -    if ( xc_version(self->xc_handle, XENVER_extraversion, &xen_extra) != 0 )
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_version, &xen_version,
> +                    sizeof(xen_version)) < 0)
>          return pyxc_error_to_exception(self->xc_handle);
>  
> -    if ( xc_version(self->xc_handle, XENVER_compile_info, &xen_cc) != 0 )
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_extraversion, &xen_extra,
> +                    sizeof(xen_extra)) < 0 )
>          return pyxc_error_to_exception(self->xc_handle);
>  
> -    if ( xc_version(self->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
> +    memset(&xen_cc, 0, sizeof(xen_cc));
> +
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_changeset, &xen_chgset,
> +                    sizeof(xen_chgset)) < 0 )
>          return pyxc_error_to_exception(self->xc_handle);
>  
> -    if ( xc_version(self->xc_handle, XENVER_capabilities, &xen_caps) != 0 )
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_capabilities, &xen_caps,
> +                   sizeof(xen_caps)) < 0 )

Indentation.

>          return pyxc_error_to_exception(self->xc_handle);
>  
> -    if ( xc_version(self->xc_handle, XENVER_platform_parameters, &p_parms) 
> != 0 )
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_platform_parameters,
> +                    &p_parms, sizeof(p_parms)) < 0 )
>          return pyxc_error_to_exception(self->xc_handle);
>  
> -    if ( xc_version(self->xc_handle, XENVER_commandline, &xen_commandline) 
> != 0 )
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_commandline,
> +                    &xen_commandline, sizeof(xen_commandline)) < 0 )
>          return pyxc_error_to_exception(self->xc_handle);
>  
>      snprintf(str, sizeof(str), "virt_start=0x%"PRI_xen_ulong, 
> p_parms.virt_start);
>  
> -    xen_pagesize = xc_version(self->xc_handle, XENVER_pagesize, NULL);
> -    if (xen_pagesize < 0 )
> +    if ( xc_version(self->xc_handle, XEN_VERSION_OP_pagesize, &xen_pagesize,
> +                    sizeof(xen_pagesize)) < 0)
>          return pyxc_error_to_exception(self->xc_handle);
>  
>      return Py_BuildValue("{s:i,s:i,s:s,s:s,s:i,s:s,s:s,s:s,s:s,s:s,s:s,s:s}",
> diff --git a/tools/xenstat/libxenstat/src/xenstat.c 
> b/tools/xenstat/libxenstat/src/xenstat.c
> index 3495f3f..723e46a 100644
> --- a/tools/xenstat/libxenstat/src/xenstat.c
> +++ b/tools/xenstat/libxenstat/src/xenstat.c
> @@ -621,20 +621,18 @@ unsigned long long 
> xenstat_network_tdrop(xenstat_network * network)
>  /* Collect Xen version information */
>  static int xenstat_collect_xen_version(xenstat_node * node)
>  {
> -     long vnum = 0;
> +     xen_version_op_val_t vnum = 0;
>       xen_extraversion_t version;
>  
>       /* Collect Xen version information if not already collected */
>       if (node->handle->xen_version[0] == '\0') {
>               /* Get the Xen version number and extraversion string */
> -             vnum = xc_version(node->handle->xc_handle,
> -                     XENVER_version, NULL);
> -
> -             if (vnum < 0)
> +             if (xc_version(node->handle->xc_handle,
> +                                XEN_VERSION_OP_version, &vnum, sizeof(vnum)) 
> < 0 )

Indentation.

>                       return 0;
>  
> -             if (xc_version(node->handle->xc_handle, XENVER_extraversion,
> -                     &version) < 0)
> +             if (xc_version(node->handle->xc_handle, 
> XEN_VERSION_OP_extraversion,
> +                                &version, sizeof(version)) < 0)

Indentation.


Wei.

>                       return 0;
>               /* Format the version information as a string and store it */
>               snprintf(node->handle->xen_version, VERSION_SIZE, "%ld.%ld%s",
> diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
> index e647179..14d2f8b 100644
> --- a/tools/xentrace/xenctx.c
> +++ b/tools/xentrace/xenctx.c
> @@ -1000,7 +1000,8 @@ static void dump_ctx(int vcpu)
>              guest_word_size = (cpuctx.msr_efer & 0x400) ? 8 :
>                  guest_protected_mode ? 4 : 2;
>              /* HVM guest context records are always host-sized */
> -            if (xc_version(xenctx.xc_handle, XENVER_capabilities, &xen_caps) 
> != 0) {
> +            if (xc_version(xenctx.xc_handle, XEN_VERSION_OP_capabilities,
> +                           &xen_caps, sizeof(xen_caps)) < 0) {
>                  perror("xc_version");
>                  return;
>              }
> -- 
> 2.5.0
> 

_______________________________________________
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®.