Skip to contentSkip to conversation

Allow runtime adjustment to log level thresholds

PATCH In review Wei Liu 4 participants 13 messages Jul 4, 2016 – Jul 7, 2016

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

v2 cover Allow runtime adjustment to log level thresholds

Previously Jan posted [0]. The downside of that approach is that we need to rework log level number space to make it suitable for stable API (safe against addition and removal of numbers).

This version changes the interface to use buffers that contain string representation of log level. User space libraries won't care about what is inside. The parsing and interpretation is up to the hypervisor.

Wei.

[0] <[email protected]>

Wei Liu (5):
xen/console: consolidate log levels to an array xen/console: allow log level threshold adjustments
libxc: wrapper for log level sysctl
libxl: introduce APIs to get and set log level
xl: new loglvl command

 docs/man/xl.pod.1.in                |  22 +++
 tools/flask/policy/modules/dom0.te  |   2 +-
 tools/libxc/include/xenctrl.h       |   6 +
 tools/libxc/xc_misc.c               | 143 ++++++++++++++++
 tools/libxl/libxl.c                 |  40 +++++
 tools/libxl/libxl.h                 |  11 ++
 tools/libxl/xl.h                    |   1 +
 tools/libxl/xl_cmdimpl.c            |  49 ++++++
 tools/libxl/xl_cmdtable.c           |   6 +
 xen/common/sysctl.c                 |   5 +
 xen/drivers/char/console.c          | 314 +++++++++++++++++++++++++++++++++++-
 xen/include/public/sysctl.h         |  41 +++++
 xen/include/xen/console.h           |   2 +
 xen/xsm/flask/hooks.c               |   3 +
 xen/xsm/flask/policy/access_vectors |   2 +
 15 files changed, 639 insertions(+), 8 deletions(-)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#4 lore raw

PATCH v2 2/5 xen/console: allow log level threshold adjustments

... from serial console and via sysctl so that one doesn't always need to reboot to see more / less messages.

Note that upper thresholds driven from the serial console are sticky, i.e. while they get adjusted upwards when the lower threshold would otherwise end up above the upper one, they don't get adjusted when reducing the lower one. Full flexibility is available only via the sysctl interface.

Rework the sysctl interface to pass in / out strings directly. Provide some helper functions to transform from log level numbers to strings and vice verse. Lower and upper bounds are checked. Add XSM hook.

---
Cc: Jan Beulich <[email protected]>
Cc: Daniel De GRaaf <[email protected]>
Cc: Ian Jackson <[email protected]>

---
 tools/flask/policy/modules/dom0.te  |   2 +-
 xen/common/sysctl.c                 |   5 +
 xen/drivers/char/console.c          | 291 +++++++++++++++++++++++++++++++++++-
 xen/include/public/sysctl.h         |  41 +++++
 xen/include/xen/console.h           |   2 +
 xen/xsm/flask/hooks.c               |   3 +
 xen/xsm/flask/policy/access_vectors |   2 +
 7 files changed, 343 insertions(+), 3 deletions(-)
tools/flask/policy/modules/dom0.te +1 -1
index 2d982d9..4e45e10 100644
@@ -15,7 +15,7 @@ allow dom0_t xen_t:xen {
 };
 allow dom0_t xen_t:xen2 {
 	resource_op psr_cmt_op psr_cat_op pmu_ctrl get_symbol
-	get_cpu_levelling_caps get_cpu_featureset livepatch_op
+	get_cpu_levelling_caps get_cpu_featureset livepatch_op loglvl
 };
 
 # Allow dom0 to use all XENVER_ subops that have checks.
xen/common/sysctl.c +5 -0
index 55f2077..cf8fa68 100644
@@ -467,6 +467,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
             copyback = 1;
         break;
 
+    case XEN_SYSCTL_loglvl_op:
+        ret = console_loglvl_op(&op->u.loglvl);
+        copyback = 1;
+        break;
+
     default:
         ret = arch_do_sysctl(op, u_sysctl);
         copyback = 0;
xen/drivers/char/console.c +289 -2

321 lines not on this page · raw message

xen/include/public/sysctl.h +41 -0

59 lines not on this page · raw message

xen/include/xen/console.h +2 -0
index ea06fd8..ac57f78 100644
@@ -12,6 +12,8 @@
 
 struct xen_sysctl_readconsole;
 long read_console_ring(struct xen_sysctl_readconsole *op);
+struct xen_sysctl_loglvl_op;
+int console_loglvl_op(struct xen_sysctl_loglvl_op *);
 
 void console_init_preirq(void);
 void console_init_ring(void);
xen/xsm/flask/hooks.c +3 -0
index 2692a6f..de6aaa8 100644
@@ -823,6 +823,9 @@ static int flask_sysctl(int cmd)
         return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2,
                                     XEN2__LIVEPATCH_OP, NULL);
 
+    case XEN_SYSCTL_loglvl_op:
+        return domain_has_xen(current->domain, XEN2__LOGLVL);
+
     default:
         return avc_unknown_permission("sysctl", cmd);
     }
xen/xsm/flask/policy/access_vectors +2 -0
index 49c9a9e..f9d37a2 100644
@@ -99,6 +99,8 @@ class xen2
     get_cpu_featureset
 # XEN_SYSCTL_livepatch_op
     livepatch_op
+# XEN_SYSCTL_loglvl_op
+    loglvl
 }
 
 # Classes domain and domain2 consist of operations that a domain performs on
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#10 lore raw

PATCH v2 4/5 libxl: introduce APIs to get and set log level

In reply to Wei Liu

---
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>

---
 tools/libxl/libxl.c | 40 ++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl.h | 11 +++++++++++
 2 files changed, 51 insertions(+)
tools/libxl/libxl.c +40 -0
index 1c81239..ff70af7 100644
@@ -6599,6 +6599,46 @@ int libxl_send_debug_keys(libxl_ctx *ctx, char *keys)
     return 0;
 }
 
+int libxl_set_log_level(libxl_ctx *ctx, bool guest,
+                        char *lower_thresh, char *upper_thresh)
+{
+    int rc, ret;
+    GC_INIT(ctx);
+
+    ret = xc_set_log_level(ctx->xch, guest, lower_thresh, upper_thresh);
+    if (ret) {
+        LOGE(ERROR, "unable to set log level");
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = 0;
+out:
+    GC_FREE;
+    return rc;
+}
+
+int libxl_get_log_level(libxl_ctx *ctx, bool guest,
+                        char *lower_thresh, unsigned int *lower_thresh_bufsize,
+                        char *upper_thresh, unsigned int *upper_thresh_bufsize)
+{
+    int rc, ret;
+    GC_INIT(ctx);
+
+    ret = xc_get_log_level(ctx->xch, guest, lower_thresh, lower_thresh_bufsize,
+                           upper_thresh, upper_thresh_bufsize);
+    if (ret) {
+        LOGE(ERROR, "unable to get log level");
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = 0;
+out:
+    GC_FREE;
+    return rc;
+}
+
 libxl_xen_console_reader *
     libxl_xen_console_read_start(libxl_ctx *ctx, int clear)
 {
tools/libxl/libxl.h +11 -0
index 2c0f868..c460d11 100644
@@ -67,6 +67,12 @@
  * the same $(XEN_VERSION) (e.g. throughout a major release).
  */
 
+/* LIBXL_HAVE_GET_SET_LOG_LEVEL
+ *
+ * If this is defined libxl has a pair of APIs to get and set log levels
+ */
+#define LIBXL_HAVE_GET_SET_LOG_LEVEL 1
+
 /* LIBXL_HAVE_VNUMA
  *
  * If this is defined the type libxl_vnode_info exists, and a
@@ -1951,6 +1957,11 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
                        libxl_trigger trigger, uint32_t vcpuid);
 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_log_level(libxl_ctx *ctx, bool guest,
+                        char *lower_thresh, char *upper_thresh);
+int libxl_get_log_level(libxl_ctx *ctx, bool guest,
+                        char *lower_thresh, unsigned int *lower_thresh_bufsize,
+                        char *upper_thresh, unsigned int *upper_thresh_bufsize);
 
 typedef struct libxl__xen_console_reader libxl_xen_console_reader;
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#1 lore raw

PATCH v2 1/5 xen/console: consolidate log levels to an array

In reply to Wei Liu

It cleaner than open-coding strings and numbers. The array will also become handy later when we need to refactor things a bit.

No functional change.

---
Cc: Jan Beulich <[email protected]>

---
 xen/drivers/char/console.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
xen/drivers/char/console.c +19 -6
index 650035d..6620a1c 100644
@@ -139,6 +139,20 @@ custom_param("guest_loglvl", parse_guest_loglvl);
 
 static atomic_t print_everything = ATOMIC_INIT(0);
 
+struct log_level {
+    const char *str;
+    unsigned int num;
+};
+
+static struct log_level __initdata log_levels[] = {
+    { "none",    0 },
+    { "error",   1 },
+    { "warning", 2 },
+    { "info",    3 },
+    { "debug",   4 },
+    { "all",     4 },
+};
+
 #define ___parse_loglvl(s, ps, lvlstr, lvlnum)          \
     if ( !strncmp((s), (lvlstr), strlen(lvlstr)) ) {    \
         *(ps) = (s) + strlen(lvlstr);                   \
@@ -147,12 +161,11 @@ static atomic_t print_everything = ATOMIC_INIT(0);
 
 static int __init __parse_loglvl(char *s, char **ps)
 {
-    ___parse_loglvl(s, ps, "none",    0);
-    ___parse_loglvl(s, ps, "error",   1);
-    ___parse_loglvl(s, ps, "warning", 2);
-    ___parse_loglvl(s, ps, "info",    3);
-    ___parse_loglvl(s, ps, "debug",   4);
-    ___parse_loglvl(s, ps, "all",     4);
+    unsigned int i;
+
+    for ( i = 0; i < ARRAY_SIZE(log_levels); i++ )
+        ___parse_loglvl(s, ps, log_levels[i].str, log_levels[i].num);
+
     return 2; /* sane fallback */
 }
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#8 lore raw

PATCH v2 3/5 libxc: wrapper for log level sysctl

In reply to Wei Liu

---
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>

---
 tools/libxc/include/xenctrl.h |   6 ++
 tools/libxc/xc_misc.c         | 143 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 149 insertions(+)
tools/libxc/include/xenctrl.h +6 -0
index 4a85b4a..059c7b4 100644
@@ -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;
tools/libxc/xc_misc.c +143 -0

149 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#12 lore raw

PATCH v2 5/5 xl: new loglvl command

In reply to Wei Liu

Introduce a new command to dynamically change log level thresholds. Provide adequate documentation.

Based on a patch by Jan Beulich.

---
Cc: Jan Beulich <[email protected]>
Cc: Ian Jackson <[email protected]>

---
 docs/man/xl.pod.1.in      | 22 +++++++++++++++++++++
 tools/libxl/xl.h          |  1 +
 tools/libxl/xl_cmdimpl.c  | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c |  6 ++++++
 4 files changed, 78 insertions(+)
docs/man/xl.pod.1.in +22 -0
index c1e6b7f..9abd06a 100644
@@ -810,6 +810,28 @@ Pass VNC password to vncviewer via stdin.
 Send debug I<keys> to Xen. It is the same as pressing the Xen
 "conswitch" (Ctrl-A by default) three times and then pressing "keys".
 
+=item B<loglvl> [B<-g>] [B<-s [lower_threshold][/upper_threshold]>]
+
+Get and set the log level thresholds.
+
+B<OPTIONS>
+
+=over 4
+
+=item B<-g>, B<--guest>
+
+Select guest log levels instead of host wide log levels.
+
+=item B<-s [lower_threshold][/upper_threshold]> B<--set=[lower_threshold][/upper_threshold]>
+
+Set the lower threshold to B<lower_threshold> and optionally set upper
+threshold to B<upper_threshold>.
+
+If this option is not specified, the command prints the current lower
+threshold and upper threshold.
+
+=back
+
 =item B<dmesg> [B<-c>]
 
 Reads the Xen message buffer, similar to dmesg on a Linux system.  The
tools/libxl/xl.h +1 -0
index e601ca1..4bf16ee 100644
@@ -80,6 +80,7 @@ int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_sysrq(int argc, char **argv);
 int main_debug_keys(int argc, char **argv);
+int main_loglvl(int argc, char **argv);
 int main_dmesg(int argc, char **argv);
 int main_top(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
tools/libxl/xl_cmdimpl.c +49 -0

55 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +6 -0
index bf69ffb..3f3e996 100644
@@ -583,6 +583,12 @@ struct cmd_spec cmd_table[] = {
       "List information about all USB controllers and devices for a domain",
       "<Domain>",
     },
+    { "loglvl",
+      &main_loglvl, 0, 1,
+      "[-g] [-s=[LOWER]/[UPPER]]",
+      "-g,                 --guest                 act on guest log level\n"
+      "-s [LOWER][/UPPER], --set=[LOWER][/UPPER]   set new log level\n"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#2 lore raw

Re: [PATCH v2 1/5] xen/console: consolidate log levels to an array

In reply to Wei Liu
Quoted 17 lines · Wei Liu

It cleaner than open-coding strings and numbers. The array will also become handy later when we need to refactor things a bit.

No functional change.

---
Cc: Jan Beulich <[email protected]>

---
 xen/drivers/char/console.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
xen/drivers/char/console.c +0 -0
index 650035d..6620a1c 100644

xen/drivers/char/console.c custom_param("guest_loglvl", parse_guest_loglvl); · line 144

Quoted 6 lines
xen/drivers/char/console.c +3 -0
@@ -139,6 +139,20 @@ custom_param("guest_loglvl", parse_guest_loglvl);
 
 static atomic_t print_everything = ATOMIC_INIT(0);
 
+struct log_level {
+    const char *str;
+    unsigned int num;

This should be int instead of unsigned int.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 2/5
#5 lore raw

Re: [PATCH v2 2/5] xen/console: allow log level threshold adjustments

In reply to Wei Liu
Quoted 9 lines · Wei Liu

... from serial console and via sysctl so that one doesn't always need to reboot to see more / less messages.

Note that upper thresholds driven from the serial console are sticky, i.e. while they get adjusted upwards when the lower threshold would otherwise end up above the upper one, they don't get adjusted when reducing the lower one. Full flexibility is available only via the sysctl interface.

Quoted 7 lines

Rework the sysctl interface to pass in / out strings directly. Provide some helper functions to transform from log level numbers to strings and vice verse. Lower and upper bounds are checked. Add XSM hook.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw

Re: [PATCH v2 3/5] libxc: wrapper for log level sysctl

In reply to Wei Liu

Wei Liu writes ("[PATCH v2 3/5] libxc: wrapper for log level sysctl"):

Quoted 1 line

I have no objection to this new wrapper but the actual code is very tedious. Is this really the least repetitive way of writing this ?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH v2 2/5] xen/console: allow log level threshold adjustments

In reply to Wei Liu

Wei Liu writes ("[PATCH v2 2/5] xen/console: allow log level threshold adjustments"):

Quoted 9 lines

... from serial console and via sysctl so that one doesn't always need to reboot to see more / less messages.

Note that upper thresholds driven from the serial console are sticky, i.e. while they get adjusted upwards when the lower threshold would otherwise end up above the upper one, they don't get adjusted when reducing the lower one. Full flexibility is available only via the sysctl interface.

Quoted 5 lines

Rework the sysctl interface to pass in / out strings directly. Provide some helper functions to transform from log level numbers to strings and vice verse. Lower and upper bounds are checked. Add XSM hook.

Is this really the best way to do this ? This is an awful lot of hypervisor code. Perhaps instead there should be a way to request the table of level strings, and userspace could do the conversion ?

Or, given that this is a sysctl, so does not need a stable ABI, the table of loglevel strings could be provided in the .h file in the form of a suitable lifted list #define, and at runtime be implicit in the ABI version.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

Re: [PATCH v2 4/5] libxl: introduce APIs to get and set log level

In reply to Wei Liu

Wei Liu writes ("[PATCH v2 4/5] libxl: introduce APIs to get and set log level"):

Quoted 1 line

...

tools/libxl/libxl.c int libxl_send_debug_keys(libxl_ctx *ctx, char *keys) · line 6603

Quoted 2 lines
tools/libxl/libxl.c +2 -0
+int libxl_set_log_level(libxl_ctx *ctx, bool guest,
+                        char *lower_thresh, char *upper_thresh)

I think the log level names should be exposed as a list to the caller. It might be better to allow the caller to specify an integer.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH v2 1/5] xen/console: consolidate log levels to an array

In reply to Wei Liu

xen/drivers/char/console.c custom_param("guest_loglvl", parse_guest_loglvl); · line 147

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 04.07.16 at 17:13, <[email protected]> wrote:
xen/drivers/char/console.c +6 -0
@@ -139,6 +139,20 @@ custom_param("guest_loglvl", parse_guest_loglvl);
 
 static atomic_t print_everything = ATOMIC_INIT(0);
 
+struct log_level {
+    const char *str;
+    unsigned int num;
+};
+
+static struct log_level __initdata log_levels[] = {

const ... __initconstrel

But the question really is, as Ian had already indicated, whether this can't be solved with less hypervisor changes (in the second patch). And jftr - I did consider passing strings as part of the hypercall arguments, but I generally dislike non-human interfaces taking human readable strings.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH v2 2/5] xen/console: allow log level threshold adjustments

In reply to Wei Liu
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 04.07.16 at 17:13, <[email protected]> wrote:

In case this (or a variant thereof) is to be used despite the earlier voiced concerns, a couple of mechanical comments:

xen/drivers/char/console.c static void __init parse_guest_loglvl(char *s) · line 220

Quoted 10 lines
xen/drivers/char/console.c +10 -0
+static const char *loglvl_to_str(int lvl)
+{
+    unsigned int i;
+
+    if ( lvl < LOG_LEVEL_MIN || lvl > LOG_LEVEL_MAX )
+        return "???";
+
+    /* Multiple log levels can use the same number. Return the most
+     * comprehensive log level string.
+     */

Comment style.

Quoted 1 line

+ for ( i = ARRAY_SIZE(log_levels) - 1; i >= 0; i-- )

Possibly infinite loop - i is unsigned and hence always non-negative.

Quoted 4 lines
xen/drivers/char/console.c +4 -0
+int console_loglvl_op(struct xen_sysctl_loglvl_op *op)
+{
+    int ret;
+

xen/drivers/char/console.c static char * __init loglvl_str(int lvl) · line 338

Quoted 10 lines
xen/drivers/char/console.c +10 -0
+    switch ( op->cmd )
+    {
+    default:
+        ret = -EOPNOTSUPP;
+        break;
+
+    case XEN_SYSCTL_LOGLVL_set:
+    {
+        char *buf;
+        unsigned int buf_size = 0;

Pointless initializer.

Quoted 61 lines
xen/drivers/char/console.c +61 -0
+        int host_lower_thresh, host_upper_thresh;
+        int guest_lower_thresh, guest_upper_thresh;
+
+        buf_size = op->host.lower_thresh_len;
+        if ( buf_size < op->host.upper_thresh_len )
+            buf_size = op->host.upper_thresh_len;
+        if ( buf_size < op->guest.lower_thresh_len )
+            buf_size = op->guest.lower_thresh_len;
+        if ( buf_size < op->guest.upper_thresh_len )
+            buf_size = op->guest.upper_thresh_len;
+
+        buf = xmalloc_array(char, buf_size);
+        if ( !buf )
+        {
+            ret = -ENOMEM;
+            goto set_done;
+        }
+
+#define parse(hg, lu)                                                   \
+        hg##_##lu##_thresh = -1;                                        \
+        if ( op->hg.lu ##_thresh_len )                                  \
+        {                                                               \
+            if ( copy_from_guest(buf, op->hg.lu ##_thresh,              \
+                                 op->hg.lu ##_thresh_len) )             \
+            {                                                           \
+                ret = -EFAULT;                                          \
+                goto set_done;                                          \
+            }                                                           \
+                                                                        \
+            buf[buf_size-1] = 0;                                        \
+                                                                        \
+            ret = parse_log_level(buf);                                 \
+            if ( ret == -1 )                                            \
+            {                                                           \
+                ret = -EINVAL;                                          \
+                goto set_done;                                          \
+            }                                                           \
+                                                                        \
+            hg##_##lu##_thresh = ret;                                   \
+        }
+
+        parse(host,  lower);
+        parse(host,  upper);
+        parse(guest, lower);
+        parse(guest, upper);
+
+#undef parse
+
+        if ( (host_lower_thresh >= 0 && host_upper_thresh >= 0 &&
+              host_lower_thresh > host_upper_thresh) ||
+             (guest_lower_thresh >= 0 && guest_upper_thresh >= 0 &&
+              guest_lower_thresh > guest_upper_thresh) )
+        {
+            ret = -EINVAL;
+            goto set_done;
+        }
+
+        do_loglvl_op(host_lower_thresh, host_upper_thresh,
+                     &xenlog_lower_thresh, &xenlog_upper_thresh,
+                     "standard");
+

xen/drivers/char/console.c static char * __init loglvl_str(int lvl) · line 409

Quoted 10 lines
xen/drivers/char/console.c +10 -0
+        do_loglvl_op(guest_lower_thresh, guest_upper_thresh,
+                     &xenlog_guest_lower_thresh, &xenlog_guest_upper_thresh,
+                     "guest");
+
+        ret = 0;
+    set_done:
+        xfree(buf);
+        break;
+    }
+    case XEN_SYSCTL_LOGLVL_get:

Blank line ahead of the case label please.

Quoted 24 lines
xen/drivers/char/console.c +24 -0
+    {
+        unsigned int host_lower_thresh_len =
+            strlen(loglvl_to_str(xenlog_lower_thresh)) + 1;
+        unsigned int host_upper_thresh_len =
+            strlen(loglvl_to_str(xenlog_upper_thresh)) + 1;
+        unsigned int guest_lower_thresh_len =
+            strlen(loglvl_to_str(xenlog_guest_lower_thresh)) + 1;
+        unsigned int guest_upper_thresh_len =
+            strlen(loglvl_to_str(xenlog_guest_upper_thresh)) + 1;
+        char scratch[LOG_LEVEL_STRLEN_MAX+1];
+
+        if ( (op->host.lower_thresh_len &&
+              op->host.lower_thresh_len < host_lower_thresh_len) ||
+             (op->host.upper_thresh_len &&
+              op->host.upper_thresh_len < host_upper_thresh_len) ||
+             (op->guest.lower_thresh_len &&
+              op->guest.lower_thresh_len < guest_lower_thresh_len) ||
+             (op->guest.upper_thresh_len
+              && op->guest.upper_thresh_len < guest_upper_thresh_len)
+            )
+        {
+            ret = -ENOBUFS;
+            goto get_done;
+        }

xen/drivers/char/console.c static char * __init loglvl_str(int lvl) · line 443

Quoted 10 lines
xen/drivers/char/console.c +10 -0
+
+        ret = -EFAULT;
+
+        if ( op->host.lower_thresh_len )
+        {
+            snprintf(scratch, sizeof(scratch), "%s",
+                     loglvl_to_str(xenlog_lower_thresh));
+            if ( copy_to_guest(op->host.lower_thresh, scratch,
+                               strlen(scratch)+1) )
+                goto get_done;

Why the indirection through snprintf()?

xen/include/public/sysctl.h struct xen_sysctl_livepatch_op { · line 1039

Quoted 12 lines
xen/include/public/sysctl.h +6 -0
@@ -1031,6 +1031,45 @@ struct xen_sysctl_livepatch_op {
 typedef struct xen_sysctl_livepatch_op xen_sysctl_livepatch_op_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_livepatch_op_t);
 
+/* XEN_SYSCTL_loglvl_op */
+#define XEN_SYSCTL_LOGLVL_get 0
+#define XEN_SYSCTL_LOGLVL_set 1
+struct xen_sysctl_loglvl_op {
+    uint32_t cmd;        /* XEN_SYSCTL_LOGLVL_* */
+    struct xen_sysctl_loglvl_thresh {

Explicit padding please ahead of this struct.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel