diff mbox series

[v3,3/4] libxl: add libxl_get_parameters() function

Message ID 20190509154128.9196-4-vliaskovitis@suse.com (mailing list archive)
State Superseded
Headers show
Series Support for reading runtime hypervisor parameters | expand

Commit Message

Vasilis LIaskovitis May 9, 2019, 3:41 p.m. UTC
Add a new libxl function to get hypervisor parameters.

Signed-off-by: Vasilis Liaskovitis <vliaskovitis@suse.com>
---
 tools/libxl/libxl.c | 15 +++++++++++++++
 tools/libxl/libxl.h |  1 +
 2 files changed, 16 insertions(+)

Comments

Anthony PERARD May 13, 2019, 9:51 a.m. UTC | #1
On Thu, May 09, 2019 at 05:41:27PM +0200, Vasilis Liaskovitis wrote:
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index ec71574e99..124033e5a3 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -669,6 +669,21 @@ int libxl_set_parameters(libxl_ctx *ctx, char *params)
>      return 0;
>  }
>  
> +int libxl_get_parameters(libxl_ctx *ctx, char *params, char *values)
> +{
> +    int ret;
> +    GC_INIT(ctx);
> +
> +    ret = xc_get_parameters(ctx->xch, params, values);

Please name the variable `r' instead of 'ret'. See CODING_STYLE as for
why.

> +    if (ret < 0) {
> +        LOGEV(ERROR, ret, "getting parameters");

LOGEV takes `errno' as second parameter, the value of `ret' seems to be
-1 or 0, and xc_get_parameters should set `errno'.  So, using the macro
LOGE() should be enough.

> +        GC_FREE;
> +        return ret;//ERROR_FAIL;

Almost! I think ERROR_FAIL should be returned here, not a return value
from a libxc call.

> +    }
> +    GC_FREE;
> +    return 0;

Instead of having to write GC_FREE twice, you could:

    if (r < 0) {
       LOG...
       rc = ERROR_FAIL;
       goto out;
    }
    rc=0;
  out:
    GC_FREE;
    return rc;

> +}
> +

Thanks,
diff mbox series

Patch

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index ec71574e99..124033e5a3 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -669,6 +669,21 @@  int libxl_set_parameters(libxl_ctx *ctx, char *params)
     return 0;
 }
 
+int libxl_get_parameters(libxl_ctx *ctx, char *params, char *values)
+{
+    int ret;
+    GC_INIT(ctx);
+
+    ret = xc_get_parameters(ctx->xch, params, values);
+    if (ret < 0) {
+        LOGEV(ERROR, ret, "getting parameters");
+        GC_FREE;
+        return ret;//ERROR_FAIL;
+    }
+    GC_FREE;
+    return 0;
+}
+
 static int fd_set_flags(libxl_ctx *ctx, int fd,
                         int fcntlgetop, int fcntlsetop, const char *fl,
                         int flagmask, int set_p)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index a38e5cdba2..360a757a06 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2307,6 +2307,7 @@  int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
 int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
 int libxl_send_debug_keys(libxl_ctx *ctx, char *keys);
 int libxl_set_parameters(libxl_ctx *ctx, char *params);
+int libxl_get_parameters(libxl_ctx *ctx, char *params, char *values);
 
 typedef struct libxl__xen_console_reader libxl_xen_console_reader;