diff mbox series

[v3,2/4] libxc: add function to get hypervisor parameters

Message ID 20190509154128.9196-3-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 libxc function to get hypervisor parameters.

Signed-off-by: Vasilis Liaskovitis <vliaskovitis@suse.com>
---
 tools/libxc/include/xenctrl.h |  1 +
 tools/libxc/xc_misc.c         | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index a3628e56bb..3482ca1a91 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1228,6 +1228,7 @@  int xc_readconsolering(xc_interface *xch,
 
 int xc_send_debug_keys(xc_interface *xch, char *keys);
 int xc_set_parameters(xc_interface *xch, char *params);
+int xc_get_parameters(xc_interface *xch, char *params, char *values);
 
 typedef struct xen_sysctl_physinfo xc_physinfo_t;
 typedef struct xen_sysctl_cputopo xc_cputopo_t;
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 5e6714ae2b..439ad91194 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -208,6 +208,32 @@  int xc_set_parameters(xc_interface *xch, char *params)
     return ret;
 }
 
+int xc_get_parameters(xc_interface *xch, char *params, char *values)
+{
+    int ret, len = strlen(params);
+    DECLARE_SYSCTL;
+    DECLARE_HYPERCALL_BOUNCE(params, len, XC_HYPERCALL_BUFFER_BOUNCE_IN);
+    DECLARE_HYPERCALL_BOUNCE(values, 1023, XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+    if ( xc_hypercall_bounce_pre(xch, params) )
+        return -1;
+    if ( xc_hypercall_bounce_pre(xch, values) )
+        return -1;
+
+    sysctl.cmd = XEN_SYSCTL_get_parameter;
+    set_xen_guest_handle(sysctl.u.get_parameter.params, params);
+    set_xen_guest_handle(sysctl.u.get_parameter.values, values);
+    sysctl.u.get_parameter.size = len;
+    memset(sysctl.u.get_parameter.pad, 0, sizeof(sysctl.u.get_parameter.pad));
+
+    ret = do_sysctl(xch, &sysctl);
+
+    xc_hypercall_bounce_post(xch, params);
+    xc_hypercall_bounce_post(xch, values);
+
+    return ret;
+}
+
 int xc_physinfo(xc_interface *xch,
                 xc_physinfo_t *put_info)
 {