xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH v2 3/5] libxc: wrapper for log level sysctl
Date: Mon, 4 Jul 2016 16:13:24 +0100	[thread overview]
Message-ID: <1467645206-28142-4-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1467645206-28142-1-git-send-email-wei.liu2@citrix.com>

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>
---
 tools/libxc/include/xenctrl.h |   6 ++
 tools/libxc/xc_misc.c         | 143 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 149 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 4a85b4a..059c7b4 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1179,6 +1179,12 @@ 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,
+                     char *lower_thresh, unsigned int *lower_thresh_len,
+                     char *upper_thresh, unsigned int *upper_thresh_len);
+int xc_set_log_level(xc_interface *xch, bool guest,
+                     char *lower_thresh, char *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;
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 06e90de..1dbbe9c 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -187,6 +187,149 @@ int xc_send_debug_keys(xc_interface *xch, char *keys)
     return ret;
 }
 
+int xc_get_log_level(xc_interface *xch, bool guest,
+                     char *lower_thresh, unsigned int *lower_thresh_len,
+                     char *upper_thresh, unsigned int *upper_thresh_len)
+{
+    int ret;
+    DECLARE_SYSCTL;
+    DECLARE_HYPERCALL_BOUNCE(lower_thresh, *lower_thresh_len,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(upper_thresh, *upper_thresh_len,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+
+    if ( (ret = xc_hypercall_bounce_pre(xch, lower_thresh)) )
+        goto out;
+    if ( (ret = xc_hypercall_bounce_pre(xch, upper_thresh)) )
+        goto out;
+
+    sysctl.cmd = XEN_SYSCTL_loglvl_op;
+    sysctl.u.loglvl.cmd = XEN_SYSCTL_LOGLVL_get;
+
+    if ( guest )
+    {
+        set_xen_guest_handle(sysctl.u.loglvl.host.lower_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.host.lower_thresh_len = 0;
+        set_xen_guest_handle(sysctl.u.loglvl.host.upper_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.host.upper_thresh_len = 0;
+
+        set_xen_guest_handle(sysctl.u.loglvl.guest.lower_thresh,
+                             lower_thresh);
+        sysctl.u.loglvl.guest.lower_thresh_len = *lower_thresh_len;
+        set_xen_guest_handle(sysctl.u.loglvl.guest.upper_thresh,
+                             upper_thresh);
+        sysctl.u.loglvl.guest.upper_thresh_len = *upper_thresh_len;
+    }
+    else
+    {
+        set_xen_guest_handle(sysctl.u.loglvl.host.lower_thresh,
+                             lower_thresh);
+        sysctl.u.loglvl.host.lower_thresh_len = *lower_thresh_len;
+        set_xen_guest_handle(sysctl.u.loglvl.host.upper_thresh,
+                             upper_thresh);
+        sysctl.u.loglvl.host.upper_thresh_len = *upper_thresh_len;
+
+        set_xen_guest_handle(sysctl.u.loglvl.guest.lower_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.guest.lower_thresh_len = 0;
+        set_xen_guest_handle(sysctl.u.loglvl.guest.upper_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.guest.upper_thresh_len = 0;
+    }
+
+    ret = do_sysctl(xch, &sysctl);
+
+    if ( guest )
+    {
+        *lower_thresh_len = sysctl.u.loglvl.guest.lower_thresh_len;
+        *upper_thresh_len = sysctl.u.loglvl.guest.upper_thresh_len;
+    }
+    else
+    {
+        *lower_thresh_len = sysctl.u.loglvl.host.lower_thresh_len;
+        *upper_thresh_len = sysctl.u.loglvl.host.upper_thresh_len;
+    }
+
+out:
+    xc_hypercall_bounce_post(xch, lower_thresh);
+    xc_hypercall_bounce_post(xch, upper_thresh);
+    return ret;
+}
+
+int xc_set_log_level(xc_interface *xch, bool guest,
+                     char *lower_thresh, char *upper_thresh)
+{
+    int ret;
+    unsigned int lower_thresh_len = 0, upper_thresh_len = 0;
+    DECLARE_SYSCTL;
+    DECLARE_HYPERCALL_BOUNCE(lower_thresh, 0 /* later */,
+                             XC_HYPERCALL_BUFFER_BOUNCE_IN);
+    DECLARE_HYPERCALL_BOUNCE(upper_thresh, 0 /* later */,
+                             XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if (!lower_thresh && !upper_thresh)
+        return 0;
+
+    sysctl.cmd = XEN_SYSCTL_loglvl_op;
+    sysctl.u.loglvl.cmd = XEN_SYSCTL_LOGLVL_set;
+
+    if (lower_thresh) {
+        lower_thresh_len = strlen(lower_thresh) + 1;
+        HYPERCALL_BOUNCE_SET_SIZE(lower_thresh, lower_thresh_len);
+    }
+
+    if (upper_thresh) {
+        upper_thresh_len = strlen(upper_thresh) + 1;
+        HYPERCALL_BOUNCE_SET_SIZE(upper_thresh, upper_thresh_len);
+    }
+
+    if ( (ret = xc_hypercall_bounce_pre(xch, lower_thresh)) )
+        goto out;
+    if ( (ret = xc_hypercall_bounce_pre(xch, upper_thresh)) )
+        goto out;
+
+    if ( guest )
+    {
+        set_xen_guest_handle(sysctl.u.loglvl.host.lower_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.host.lower_thresh_len = 0;
+        set_xen_guest_handle(sysctl.u.loglvl.host.upper_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.host.upper_thresh_len = 0;
+        set_xen_guest_handle(sysctl.u.loglvl.guest.lower_thresh,
+                             lower_thresh);
+        sysctl.u.loglvl.guest.lower_thresh_len = lower_thresh_len;
+        set_xen_guest_handle(sysctl.u.loglvl.guest.upper_thresh,
+                             upper_thresh);
+        sysctl.u.loglvl.guest.upper_thresh_len = upper_thresh_len;
+    }
+    else
+    {
+        set_xen_guest_handle(sysctl.u.loglvl.host.lower_thresh,
+                             lower_thresh);
+        sysctl.u.loglvl.host.lower_thresh_len = lower_thresh_len;
+        set_xen_guest_handle(sysctl.u.loglvl.host.upper_thresh,
+                             upper_thresh);
+        sysctl.u.loglvl.host.upper_thresh_len = upper_thresh_len;
+
+        set_xen_guest_handle(sysctl.u.loglvl.guest.lower_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.guest.lower_thresh_len = 0;
+        set_xen_guest_handle(sysctl.u.loglvl.guest.upper_thresh,
+                             HYPERCALL_BUFFER_NULL);
+        sysctl.u.loglvl.guest.upper_thresh_len = 0;
+    }
+
+    ret = do_sysctl(xch, &sysctl);
+
+out:
+    xc_hypercall_bounce_post(xch, lower_thresh);
+    xc_hypercall_bounce_post(xch, upper_thresh);
+    return ret;
+}
+
 int xc_physinfo(xc_interface *xch,
                 xc_physinfo_t *put_info)
 {
-- 
2.1.4


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

  parent reply	other threads:[~2016-07-04 15:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 15:13 [PATCH v2 0/5] Allow runtime adjustment to log level thresholds Wei Liu
2016-07-04 15:13 ` [PATCH v2 1/5] xen/console: consolidate log levels to an array Wei Liu
2016-07-04 15:28   ` Wei Liu
2016-07-07 10:39   ` Jan Beulich
2016-07-04 15:13 ` [PATCH v2 2/5] xen/console: allow log level threshold adjustments Wei Liu
2016-07-05 17:52   ` Daniel De Graaf
2016-07-06 11:14   ` Ian Jackson
2016-07-07 11:51   ` Jan Beulich
2016-07-04 15:13 ` Wei Liu [this message]
2016-07-06 11:11   ` [PATCH v2 3/5] libxc: wrapper for log level sysctl Ian Jackson
2016-07-04 15:13 ` [PATCH v2 4/5] libxl: introduce APIs to get and set log level Wei Liu
2016-07-06 11:15   ` Ian Jackson
2016-07-04 15:13 ` [PATCH v2 5/5] xl: new loglvl command Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467645206-28142-4-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).