From: Ben Pfaff Date: Thu, 28 Jul 2011 17:19:42 +0000 (-0700) Subject: vlog: Add a new log level "off". X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1a543a8d6d2847983b6b0defd1e19777da85715;p=openvswitch vlog: Add a new log level "off". Until now, "emer" has effectively been "off" because no messages were ever logged at "emer" level. Justin points out that it is useful to use "emer" for messages that indicate a fatal error. This commit makes that change and adds a new "off" level to really turn off all logging to a facility. --- diff --git a/ChangeLog b/ChangeLog index c38a50d4..3ae7c9b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ post v1.1.0 ------------------------ + + - A new log level "off" has been added. Configuring a log facility + "off" prevents any messages from being logged to it. Previously, + "emer" was effectively "off" because no messages were ever logged at + level "emer". Now, errors that cause a process to exit are logged + at "emer" level. - The new "-s" option for "ovs-dpctl show" prints packet and byte counters for each port. - ovs-ofctl: diff --git a/lib/daemon.c b/lib/daemon.c index f4151ab1..ef1a24ef 100644 --- a/lib/daemon.c +++ b/lib/daemon.c @@ -410,7 +410,7 @@ close_standard_fds(void) } /* Disable logging to stderr to avoid wasting CPU time. */ - vlog_set_levels(NULL, VLF_CONSOLE, VLL_EMER); + vlog_set_levels(NULL, VLF_CONSOLE, VLL_OFF); } /* If daemonization is configured, then starts daemonization, by forking and diff --git a/lib/vlog-unixctl.man b/lib/vlog-unixctl.man index 5c60a855..31de844c 100644 --- a/lib/vlog-unixctl.man +++ b/lib/vlog-unixctl.man @@ -19,7 +19,7 @@ facilities. If it is omitted, \fIfacility\fR defaults to \fBANY\fR. The log level for the \fBfile\fR facility has no effect unless \fB\*(PN\fR was invoked with the \fB\-\-log\-file\fR option. .IP \(bu -\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, +\fIlevel\fR must be one of \fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR, \fBinfo\fR, or \fBdbg\fR, designating the minimum severity of a message for it to be logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR. diff --git a/lib/vlog.c b/lib/vlog.c index 279c6e73..ef95b1b4 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -186,7 +186,7 @@ update_min_level(struct vlog_module *module) { enum vlog_facility facility; - module->min_level = VLL_EMER; + module->min_level = VLL_OFF; for (facility = 0; facility < VLF_N_FACILITIES; facility++) { if (log_file || facility != VLF_FILE) { enum vlog_level level = module->levels[facility]; @@ -692,27 +692,26 @@ vlog(const struct vlog_module *module, enum vlog_level level, } void -vlog_fatal_valist(const struct vlog_module *module_, enum vlog_level level, +vlog_fatal_valist(const struct vlog_module *module_, const char *message, va_list args) { struct vlog_module *module = (struct vlog_module *) module_; /* Don't log this message to the console to avoid redundancy with the * message written by the later ovs_fatal_valist(). */ - module->levels[VLF_CONSOLE] = VLL_EMER; + module->levels[VLF_CONSOLE] = VLL_OFF; - vlog_valist(module, level, message, args); + vlog_valist(module, VLL_EMER, message, args); ovs_fatal_valist(0, message, args); } void -vlog_fatal(const struct vlog_module *module, enum vlog_level level, - const char *message, ...) +vlog_fatal(const struct vlog_module *module, const char *message, ...) { va_list args; va_start(args, message); - vlog_fatal_valist(module, level, message, args); + vlog_fatal_valist(module, message, args); va_end(args); } diff --git a/lib/vlog.h b/lib/vlog.h index 7c439f22..aa98c06e 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -28,12 +28,13 @@ extern "C" { #endif -/* Logging importance levels. +/* Logging severity levels. * - * The following log levels, in descending order of importance, are enabled by + * A logging severity level of OFF suppresses logging. Messages at the + * following log levels, in descending order of importance, are enabled by * default: * - * - EMER: Not currently used. + * - EMER: The process is aborting due to unrecoverable failure. * * - ERR: A high-level operation or a subsystem failed. Attention is * warranted. @@ -50,6 +51,7 @@ extern "C" { * system, or that would commonly cause too-voluminous log output. */ #define VLOG_LEVELS \ + VLOG_LEVEL(OFF, LOG_ALERT) \ VLOG_LEVEL(EMER, LOG_ALERT) \ VLOG_LEVEL(ERR, LOG_ERR) \ VLOG_LEVEL(WARN, LOG_WARNING) \ @@ -163,12 +165,10 @@ void vlog_valist(const struct vlog_module *, enum vlog_level, const char *, va_list) PRINTF_FORMAT (3, 0); -void vlog_fatal(const struct vlog_module *, enum vlog_level, - const char *format, ...) - PRINTF_FORMAT (3, 4) NO_RETURN; -void vlog_fatal_valist(const struct vlog_module *, enum vlog_level, - const char *, va_list) - PRINTF_FORMAT (3, 0) NO_RETURN; +void vlog_fatal(const struct vlog_module *, const char *format, ...) + PRINTF_FORMAT (2, 3) NO_RETURN; +void vlog_fatal_valist(const struct vlog_module *, const char *format, va_list) + PRINTF_FORMAT (2, 0) NO_RETURN; void vlog_rate_limit(const struct vlog_module *, enum vlog_level, struct vlog_rate_limit *, const char *, ...) @@ -187,7 +187,7 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level, * * Guaranteed to preserve errno. */ -#define VLOG_FATAL(...) vlog_fatal(THIS_MODULE, VLL_ERR, __VA_ARGS__) +#define VLOG_FATAL(...) vlog_fatal(THIS_MODULE, __VA_ARGS__) #define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__) #define VLOG_ERR(...) VLOG(VLL_ERR, __VA_ARGS__) #define VLOG_WARN(...) VLOG(VLL_WARN, __VA_ARGS__) @@ -197,7 +197,6 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level, /* More convenience macros, for testing whether a given level is enabled in * THIS_MODULE. When constructing a log message is expensive, this enables it * to be skipped. */ -#define VLOG_IS_EMER_ENABLED() true #define VLOG_IS_ERR_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_ERR) #define VLOG_IS_WARN_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_WARN) #define VLOG_IS_INFO_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_INFO) diff --git a/lib/vlog.man b/lib/vlog.man index a645f3a4..63e712ea 100644 --- a/lib/vlog.man +++ b/lib/vlog.man @@ -21,7 +21,7 @@ will not take place unless \fB\-\-log\-file\fR is also specified (see below). . .IP \(bu -\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, +\fIlevel\fR must be one of \fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR, \fBinfo\fR, or \fBdbg\fR, designating the minimum severity of a message for it to be logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR. diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at index 90ca127c..f5add098 100644 --- a/tests/interface-reconfigure.at +++ b/tests/interface-reconfigure.at @@ -703,7 +703,7 @@ configure_datapath: bridge - xenbr2 configure_datapath: physical - [u'eth2'] configure_datapath: extra ports - [] configure_datapath: extra bonds - [] -/usr/bin/ovs-vsctl --timeout=5 -vANY:console:emer get-fail-mode xenbr2 +/usr/bin/ovs-vsctl --timeout=5 -vANY:console:off get-fail-mode xenbr2 Applying changes to /etc/sysconfig/network-scripts/route-xenbr2 configuration Applying changes to /etc/sysconfig/network configuration Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration @@ -718,7 +718,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration set Bridge xenbr2 fail_mode=secure remove Bridge xenbr2 other_config disable-in-band br-set-external-id xenbr2 xs-network-uuids d08c8749-0c8f-9e8d-ce25-fd364661ee99 -/usr/bin/ovs-vsctl --timeout=5 -vANY:console:emer get interface eth2 ofport +/usr/bin/ovs-vsctl --timeout=5 -vANY:console:off get interface eth2 ofport /usr/bin/ovs-ofctl add-flow xenbr2 idle_timeout=0,priority=0,in_port=5,arp,nw_proto=1,actions=local /usr/bin/ovs-ofctl add-flow xenbr2 idle_timeout=0,priority=0,in_port=local,arp,dl_src=00:15:17:a0:29:80,actions=5 /usr/bin/ovs-ofctl add-flow xenbr2 idle_timeout=0,priority=0,in_port=5,dl_dst=00:15:17:a0:29:80,actions=local diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c index fae0f178..494046cc 100644 --- a/tests/test-reconnect.c +++ b/tests/test-reconnect.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ main(void) int old_time; char line[128]; - vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_EMER); + vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_OFF); now = 1000; reconnect = reconnect_create(now); diff --git a/utilities/ovs-appctl.8.in b/utilities/ovs-appctl.8.in index 04a74dcc..a3688ac5 100644 --- a/utilities/ovs-appctl.8.in +++ b/utilities/ovs-appctl.8.in @@ -70,7 +70,8 @@ set the logging levels for all modules. The \fIfacility\fR may be system log or to the console, respectively, or \fBANY\fR to set the logging levels for both facilities. If it is omitted, \fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must be one of -\fBemer\fR, \fBerr\fR, \fBwarn\fR, \fBinfo\fR, or \fBdbg\fR, designating the +\fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR, \fBinfo\fR, or +\fBdbg\fR, designating the minimum severity of a message for it to be logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR. . diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c index 88ecfe32..cd059bf1 100644 --- a/utilities/ovs-appctl.c +++ b/utilities/ovs-appctl.c @@ -81,22 +81,23 @@ main(int argc, char *argv[]) static void usage(void) { - printf("%s, for querying and controlling Open vSwitch daemon\n" - "usage: %s [TARGET] COMMAND [ARG...]\n" - "Targets:\n" - " -t, --target=TARGET pidfile or socket to contact\n" - "Common commands:\n" - " help List commands supported by the target\n" - " vlog/list List current logging levels\n" - " vlog/set MODULE[:FACILITY[:LEVEL]]\n" - " Set MODULE and FACILITY log level to LEVEL\n" - " MODULE may be any valid module name or 'ANY'\n" - " FACILITY may be 'syslog', 'console', 'file', or 'ANY' (default)\n" - " LEVEL may be 'emer', 'err', 'warn', 'info', or 'dbg' (default)\n" - " vlog/reopen Make the program reopen its log file\n" - "Other options:\n" - " -h, --help Print this helpful information\n" - " -V, --version Display version information\n", + printf("\ +%s, for querying and controlling Open vSwitch daemon\n\ +usage: %s [TARGET] COMMAND [ARG...]\n\ +Targets:\n\ + -t, --target=TARGET pidfile or socket to contact\n\ +Common commands:\n\ + help List commands supported by the target\n\ + vlog/list List current logging levels\n\ + vlog/set MODULE[:FACILITY[:LEVEL]]\n\ + Set MODULE and FACILITY log level to LEVEL\n\ + MODULE may be any valid module name or 'ANY'\n\ + FACILITY may be 'syslog', 'console', 'file', or 'ANY' (default)\n\ + LEVEL may be 'off', 'emer', 'err', 'warn', 'info', or 'dbg' (default)\n\ + vlog/reopen Make the program reopen its log file\n\ +Other options:\n\ + -h, --help Print this helpful information\n\ + -V, --version Display version information\n", program_name, program_name); exit(EXIT_SUCCESS); } diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 01741e75..c1024190 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -61,7 +61,7 @@ ovs_vsctl () { } ovsdb_tool () { - ovsdb-tool -vANY:console:emer "$@" + ovsdb-tool -vANY:console:off "$@" } create_db () { diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 4f82d0c5..b59d8861 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -444,7 +444,7 @@ vsctl_fatal(const char *format, ...) message = xvasprintf(format, args); va_end(args); - vlog_set_levels(&VLM_vsctl, VLF_CONSOLE, VLL_EMER); + vlog_set_levels(&VLM_vsctl, VLF_CONSOLE, VLL_OFF); VLOG_ERR("%s", message); ovs_error(0, "%s", message); vsctl_exit(EXIT_FAILURE); diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update index bceccbf4..60cd7167 100755 --- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update +++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update @@ -215,7 +215,7 @@ def setControllerCfg(controller): "--", "set-manager", 'ssl:' + controller + ':6632']) def vswitchCfgQuery(action_args): - cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args + cmd = [vsctl, "--timeout=5", "-vANY:console:off"] + action_args output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() if len(output) == 0 or output[0] == None: output = "" @@ -224,7 +224,7 @@ def vswitchCfgQuery(action_args): return output def vswitchCfgMod(action_args): - cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args + cmd = [vsctl, "--timeout=5", "-vANY:console:off"] + action_args exitcode = subprocess.call(cmd) if exitcode != 0: raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE", diff --git a/xenserver/openvswitch-xen.spec b/xenserver/openvswitch-xen.spec index e4913514..4f1a0064 100644 --- a/xenserver/openvswitch-xen.spec +++ b/xenserver/openvswitch-xen.spec @@ -145,11 +145,11 @@ if test ! -e /etc/openvswitch/conf.db; then install -d -m 755 -o root -g root /etc/openvswitch # Create ovs-vswitchd config database - ovsdb-tool -vANY:console:emer create /etc/openvswitch/conf.db \ + ovsdb-tool -vANY:console:off create /etc/openvswitch/conf.db \ /usr/share/openvswitch/vswitch.ovsschema # Create initial table in config database - ovsdb-tool -vANY:console:emer transact /etc/openvswitch/conf.db \ + ovsdb-tool -vANY:console:off transact /etc/openvswitch/conf.db \ '[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \ > /dev/null fi diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py index c223e413..31e9b517 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py @@ -721,7 +721,7 @@ class DatapathVswitch(Datapath): def vswitchCfgQuery(action_args): cmd = ['%s/usr/bin/ovs-vsctl' % root_prefix(), - '--timeout=5', '-vANY:console:emer'] + action_args + '--timeout=5', '-vANY:console:off'] + action_args output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() if len(output) == 0 or output[0] == None: output = "" diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index dab9c773..93532c84 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2007-2010 Citrix Systems Inc. +# Copyright (c) 2007-2011 Citrix Systems Inc. # Copyright (c) 2009,2010,2011 Nicira Networks. # # This program is free software; you can redistribute it and/or modify @@ -86,7 +86,7 @@ class VSwitchConfig: @staticmethod def Get(action): try: - arg = [vsctl, "--timeout=30", "-vANY:console:emer"] + action.split() + arg = [vsctl, "--timeout=30", "-vANY:console:off"] + action.split() output = ShellPipe(arg).Stdout() except StandardError, e: XSLogError("config retrieval error: " + str(e)) diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index 02966217..02635568 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -118,7 +118,7 @@ def get_iface_id(if_name, xs_vif_uuid): return xs_vif_uuid def call_vsctl(args): - cmd = [vsctl, "--timeout=30", "-vANY:console:emer"] + args + cmd = [vsctl, "--timeout=30", "-vANY:console:off"] + args exitcode = subprocess.call(cmd) if exitcode != 0: s_log.warning("Couldn't call ovs-vsctl")