diff mbox

[v2,2/3] libxc: wrapper for log level sysctl

Message ID 56D9CA3402000078000D9931@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich March 4, 2016, 4:47 p.m. UTC
Signed-off-by: Jan Beulich <jbeulich@suse.com>
libxc: wrapper for log level sysctl

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1120,6 +1120,11 @@ int xc_readconsolering(xc_interface *xch
 
 int xc_send_debug_keys(xc_interface *xch, char *keys);
 
+int xc_get_log_level(xc_interface *xch, bool guest,
+                     int *lower_thresh, int *upper_thresh);
+int xc_set_log_level(xc_interface *xch, bool guest,
+                     int lower_thresh, int upper_thresh);
+
 typedef xen_sysctl_physinfo_t xc_physinfo_t;
 typedef xen_sysctl_cputopo_t xc_cputopo_t;
 typedef xen_sysctl_numainfo_t xc_numainfo_t;
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -184,6 +184,55 @@ int xc_send_debug_keys(xc_interface *xch
     return ret;
 }
 
+int xc_get_log_level(xc_interface *xch, bool guest,
+                     int *lower_thresh, int *upper_thresh)
+{
+    int ret;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_loglvl_op;
+    sysctl.u.loglvl.cmd = XEN_SYSCTL_LOGLVL_get;
+    ret = do_sysctl(xch, &sysctl);
+
+    if ( guest )
+    {
+        *lower_thresh = sysctl.u.loglvl.guest.lower_thresh;
+        *upper_thresh = sysctl.u.loglvl.guest.upper_thresh;
+    }
+    else
+    {
+        *lower_thresh = sysctl.u.loglvl.host.lower_thresh;
+        *upper_thresh = sysctl.u.loglvl.host.upper_thresh;
+    }
+
+    return ret;
+}
+
+int xc_set_log_level(xc_interface *xch, bool guest,
+                     int lower_thresh, int upper_thresh)
+{
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_loglvl_op;
+    sysctl.u.loglvl.cmd = XEN_SYSCTL_LOGLVL_set;
+    if ( guest )
+    {
+        sysctl.u.loglvl.host.lower_thresh = -1;
+        sysctl.u.loglvl.host.upper_thresh = -1;
+        sysctl.u.loglvl.guest.lower_thresh = lower_thresh;
+        sysctl.u.loglvl.guest.upper_thresh = upper_thresh;
+    }
+    else
+    {
+        sysctl.u.loglvl.host.lower_thresh = lower_thresh;
+        sysctl.u.loglvl.host.upper_thresh = upper_thresh;
+        sysctl.u.loglvl.guest.lower_thresh = -1;
+        sysctl.u.loglvl.guest.upper_thresh = -1;
+    }
+
+    return do_sysctl(xch, &sysctl);
+}
+
 int xc_physinfo(xc_interface *xch,
                 xc_physinfo_t *put_info)
 {

Comments

Dario Faggioli March 5, 2016, 4 p.m. UTC | #1
On Fri, 2016-03-04 at 09:47 -0700, Jan Beulich wrote:
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>

Regards,
Dario
Wei Liu March 8, 2016, 4:20 p.m. UTC | #2
On Fri, Mar 04, 2016 at 09:47:32AM -0700, Jan Beulich wrote:
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 

Acked-by: Wei Liu <wei.liu2@citrix.com>
diff mbox

Patch

--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1120,6 +1120,11 @@  int xc_readconsolering(xc_interface *xch
 
 int xc_send_debug_keys(xc_interface *xch, char *keys);
 
+int xc_get_log_level(xc_interface *xch, bool guest,
+                     int *lower_thresh, int *upper_thresh);
+int xc_set_log_level(xc_interface *xch, bool guest,
+                     int lower_thresh, int upper_thresh);
+
 typedef xen_sysctl_physinfo_t xc_physinfo_t;
 typedef xen_sysctl_cputopo_t xc_cputopo_t;
 typedef xen_sysctl_numainfo_t xc_numainfo_t;
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -184,6 +184,55 @@  int xc_send_debug_keys(xc_interface *xch
     return ret;
 }
 
+int xc_get_log_level(xc_interface *xch, bool guest,
+                     int *lower_thresh, int *upper_thresh)
+{
+    int ret;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_loglvl_op;
+    sysctl.u.loglvl.cmd = XEN_SYSCTL_LOGLVL_get;
+    ret = do_sysctl(xch, &sysctl);
+
+    if ( guest )
+    {
+        *lower_thresh = sysctl.u.loglvl.guest.lower_thresh;
+        *upper_thresh = sysctl.u.loglvl.guest.upper_thresh;
+    }
+    else
+    {
+        *lower_thresh = sysctl.u.loglvl.host.lower_thresh;
+        *upper_thresh = sysctl.u.loglvl.host.upper_thresh;
+    }
+
+    return ret;
+}
+
+int xc_set_log_level(xc_interface *xch, bool guest,
+                     int lower_thresh, int upper_thresh)
+{
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_loglvl_op;
+    sysctl.u.loglvl.cmd = XEN_SYSCTL_LOGLVL_set;
+    if ( guest )
+    {
+        sysctl.u.loglvl.host.lower_thresh = -1;
+        sysctl.u.loglvl.host.upper_thresh = -1;
+        sysctl.u.loglvl.guest.lower_thresh = lower_thresh;
+        sysctl.u.loglvl.guest.upper_thresh = upper_thresh;
+    }
+    else
+    {
+        sysctl.u.loglvl.host.lower_thresh = lower_thresh;
+        sysctl.u.loglvl.host.upper_thresh = upper_thresh;
+        sysctl.u.loglvl.guest.lower_thresh = -1;
+        sysctl.u.loglvl.guest.upper_thresh = -1;
+    }
+
+    return do_sysctl(xch, &sysctl);
+}
+
 int xc_physinfo(xc_interface *xch,
                 xc_physinfo_t *put_info)
 {