[libvirt] [PATCH] logging: remove concept of default log priority
by Daniel P. Berrange
The logging framework has categories which can be selectively
enabled/disabled by setting a suitable LIBVIRT_LOG_FILTERS
environment variable or config file setting.
Along side that we also have the LIBVIRT_DEBUG environment
variable which unconditionally enables every single category
at DEBUG level. With the amount of logging produced by libvirt
these days, the signal/noise ratio in the output from setting
LIBVIRT_DEBUG is to poor for it to be useful.
Originally the LIBVIRT_DEBUG env variable had a very specific
use case - it resulted in logging of anything in our public
API entrypoints. eg it turned on src/libvirt.c debugging and
nothing else. Additionally it would always result in log
messages being sent to stderr.
When applied to any of the daemons, the log output no longers
gets sent to stderr, but rather to whatever default log output
has been configured by the daemon. If no log_outputs setting
or LIBVIRT_LOG_OUTPUTS env is set, then messages will often
go to the systemd journal or a /var/log/libvirt/libvirtd.log
file rather than stderr.
These factors have conspired to make the LIBVIRT_DEBUG env
and/or default log priority to be pretty useless in the real
world.
This change attempts to take us back towards the original
semantics of the LIBVIRT_DEBUG env variable as follows.
If LIBVIRT_DEBUG is set to a plain integer, or log level
string, then it will turn on logging for the "libvirt" log
category at that level. Any other string will be parsed in
the same way as LIBVIRT_LOG_FILTERS would be. In all cases
use of LIBVIRT_DEBUG will result in an explicit output being
added for stderr. This ensures that messages always go to
stderr, even if other outputs are already configured.
IOW, LIBVIRT_DEBUG=1 virsh or LIBVIRT_DEBUG=1 libvirtd
will both result in printing logs of libvirt public API
calls to stderr. Meanwhile setting LIBVIRT_DEBUG="1:qemu"
is equivalent to setting LIBVIRT_LOG_FILTERS="1:qemu" and
LIBVIRT_LOG_OUTPUTS="1:stderr"
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
daemon/libvirtd.c | 27 ++++++------
src/libvirt_private.syms | 1 +
src/libxl/libxl_conf.c | 3 +-
src/locking/lock_daemon.c | 29 ++++++-------
src/logging/log_daemon.c | 29 ++++++-------
src/lxc/lxc_process.c | 7 ----
src/util/vircommand.c | 4 --
src/util/virlog.c | 104 +++++++++++++++++++---------------------------
src/util/virlog.h | 11 ++---
tests/eventtest.c | 6 +--
10 files changed, 97 insertions(+), 124 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index cc5190f..e88a982 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -668,6 +668,8 @@ daemonSetupLogging(struct daemonConfig *config,
bool verbose,
bool godaemon)
{
+ int level = VIR_LOG_WARN;
+
virLogReset();
/*
@@ -684,9 +686,6 @@ daemonSetupLogging(struct daemonConfig *config,
* level has been set, we must process variables in the opposite
* order, each one overriding the previous.
*/
- if (config->log_level != 0)
- virLogSetDefaultPriority(config->log_level);
-
virLogSetFromEnv();
if (virLogGetNbFilters() == 0)
@@ -695,11 +694,14 @@ daemonSetupLogging(struct daemonConfig *config,
if (virLogGetNbOutputs() == 0)
virLogParseOutputs(config->log_outputs);
- /*
- * Command line override for --verbose
- */
- if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO))
- virLogSetDefaultPriority(VIR_LOG_INFO);
+ if (config->log_level != 0 || verbose) {
+ level = config->log_level;
+ if (verbose && level > VIR_LOG_INFO)
+ level = VIR_LOG_INFO;
+ virLogDefineFilter("libvirt", level, 0);
+ if (virLogGetNbOutputs() == 0)
+ virLogParseOutputs("1:stderr");
+ }
/*
* If no defined outputs, and either running
@@ -711,7 +713,7 @@ daemonSetupLogging(struct daemonConfig *config,
(godaemon || !isatty(STDIN_FILENO))) {
char *tmp;
if (access("/run/systemd/journal/socket", W_OK) >= 0) {
- virLogPriority priority = virLogGetDefaultPriority();
+ virLogPriority priority = level;
/* By default we don't want to log too much stuff into journald as
* it may employ rate limiting and thus block libvirt execution. */
@@ -735,8 +737,7 @@ daemonSetupLogging(struct daemonConfig *config,
if (godaemon) {
if (privileged) {
if (virAsprintf(&tmp, "%d:file:%s/log/libvirt/libvirtd.log",
- virLogGetDefaultPriority(),
- LOCALSTATEDIR) == -1)
+ level, LOCALSTATEDIR) == -1)
goto error;
} else {
char *logdir = virGetUserCacheDirectory();
@@ -753,14 +754,14 @@ daemonSetupLogging(struct daemonConfig *config,
umask(old_umask);
if (virAsprintf(&tmp, "%d:file:%s/libvirtd.log",
- virLogGetDefaultPriority(), logdir) == -1) {
+ level, logdir) == -1) {
VIR_FREE(logdir);
goto error;
}
VIR_FREE(logdir);
}
} else {
- if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
+ if (virAsprintf(&tmp, "%d:stderr", level) < 0)
goto error;
}
virLogParseOutputs(tmp);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a980a32..5586d8b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1801,6 +1801,7 @@ virLogProbablyLogMessage;
virLogReset;
virLogSetDefaultPriority;
virLogSetFromEnv;
+virLogSourceGetPriority;
virLogUnlock;
virLogVMessage;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index d927b37..51d6037 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -52,6 +52,7 @@
#define VIR_FROM_THIS VIR_FROM_LIBXL
VIR_LOG_INIT("libxl.libxl_conf");
+VIR_LOG_INIT_FULL("libxl.libxl_context", virLogLibXL);
/* see xen-unstable.hg/xen/include/asm-x86/cpufeature.h */
#define LIBXL_X86_FEATURE_PAE_MASK 0x40
@@ -1724,7 +1725,7 @@ libxlDriverConfigNew(void)
}
VIR_FREE(log_file);
- switch (virLogGetDefaultPriority()) {
+ switch (virLogSourceGetPriority(&virLogLibXL)) {
case VIR_LOG_DEBUG:
log_level = XTL_DEBUG;
break;
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index f889a34..426fe6b 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -454,6 +454,8 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
bool verbose,
bool godaemon)
{
+ int level = VIR_LOG_WARN;
+
virLogReset();
/*
@@ -470,9 +472,6 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
* level has been set, we must process variables in the opposite
* order, each one overriding the previous.
*/
- if (config->log_level != 0)
- virLogSetDefaultPriority(config->log_level);
-
virLogSetFromEnv();
if (virLogGetNbFilters() == 0)
@@ -481,6 +480,15 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
if (virLogGetNbOutputs() == 0)
virLogParseOutputs(config->log_outputs);
+ if (config->log_level != 0 || verbose) {
+ level = config->log_level;
+ if (verbose && level > VIR_LOG_INFO)
+ level = VIR_LOG_INFO;
+ virLogDefineFilter("libvirt", level, 0);
+ if (virLogGetNbOutputs() == 0)
+ virLogParseOutputs("1:stderr");
+ }
+
/*
* If no defined outputs, and either running
* as daemon or not on a tty, then first try
@@ -491,7 +499,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
(godaemon || !isatty(STDIN_FILENO))) {
char *tmp;
if (access("/run/systemd/journal/socket", W_OK) >= 0) {
- if (virAsprintf(&tmp, "%d:journald", virLogGetDefaultPriority()) < 0)
+ if (virAsprintf(&tmp, "%d:journald", level) < 0)
goto error;
virLogParseOutputs(tmp);
VIR_FREE(tmp);
@@ -508,8 +516,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
if (godaemon) {
if (privileged) {
if (virAsprintf(&tmp, "%d:file:%s/log/libvirt/virtlockd.log",
- virLogGetDefaultPriority(),
- LOCALSTATEDIR) == -1)
+ level, LOCALSTATEDIR) == -1)
goto error;
} else {
char *logdir = virGetUserCacheDirectory();
@@ -527,26 +534,20 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
umask(old_umask);
if (virAsprintf(&tmp, "%d:file:%s/virtlockd.log",
- virLogGetDefaultPriority(), logdir) == -1) {
+ level, logdir) == -1) {
VIR_FREE(logdir);
goto error;
}
VIR_FREE(logdir);
}
} else {
- if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
+ if (virAsprintf(&tmp, "%d:stderr", level) < 0)
goto error;
}
virLogParseOutputs(tmp);
VIR_FREE(tmp);
}
- /*
- * Command line override for --verbose
- */
- if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO))
- virLogSetDefaultPriority(VIR_LOG_INFO);
-
return 0;
error:
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 90f8427..f344ba2 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -377,6 +377,8 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
bool verbose,
bool godaemon)
{
+ int level = VIR_LOG_WARN;
+
virLogReset();
/*
@@ -393,9 +395,6 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
* level has been set, we must process variables in the opposite
* order, each one overriding the previous.
*/
- if (config->log_level != 0)
- virLogSetDefaultPriority(config->log_level);
-
virLogSetFromEnv();
if (virLogGetNbFilters() == 0)
@@ -404,6 +403,15 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
if (virLogGetNbOutputs() == 0)
virLogParseOutputs(config->log_outputs);
+ if (config->log_level != 0 || verbose) {
+ level = config->log_level;
+ if (verbose && level > VIR_LOG_INFO)
+ level = VIR_LOG_INFO;
+ virLogDefineFilter("libvirt", level, 0);
+ if (virLogGetNbOutputs() == 0)
+ virLogParseOutputs("1:stderr");
+ }
+
/*
* If no defined outputs, and either running
* as daemon or not on a tty, then first try
@@ -414,7 +422,7 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
(godaemon || !isatty(STDIN_FILENO))) {
char *tmp;
if (access("/run/systemd/journal/socket", W_OK) >= 0) {
- if (virAsprintf(&tmp, "%d:journald", virLogGetDefaultPriority()) < 0)
+ if (virAsprintf(&tmp, "%d:journald", level) < 0)
goto error;
virLogParseOutputs(tmp);
VIR_FREE(tmp);
@@ -431,8 +439,7 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
if (godaemon) {
if (privileged) {
if (virAsprintf(&tmp, "%d:file:%s/log/libvirt/virtlogd.log",
- virLogGetDefaultPriority(),
- LOCALSTATEDIR) == -1)
+ level, LOCALSTATEDIR) == -1)
goto error;
} else {
char *logdir = virGetUserCacheDirectory();
@@ -450,26 +457,20 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
umask(old_umask);
if (virAsprintf(&tmp, "%d:file:%s/virtlogd.log",
- virLogGetDefaultPriority(), logdir) == -1) {
+ level, logdir) == -1) {
VIR_FREE(logdir);
goto error;
}
VIR_FREE(logdir);
}
} else {
- if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
+ if (virAsprintf(&tmp, "%d:stderr", level) < 0)
goto error;
}
virLogParseOutputs(tmp);
VIR_FREE(tmp);
}
- /*
- * Command line override for --verbose
- */
- if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO))
- virLogSetDefaultPriority(VIR_LOG_INFO);
-
return 0;
error:
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 8981d9a..9fca007 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -918,9 +918,6 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
/* The controller may call ip command, so we have to retain PATH. */
virCommandAddEnvPassBlockSUID(cmd, "PATH", "/bin:/usr/bin");
- virCommandAddEnvFormat(cmd, "LIBVIRT_DEBUG=%d",
- virLogGetDefaultPriority());
-
if (virLogGetNbFilters() > 0) {
filterstr = virLogGetFilters();
if (!filterstr) {
@@ -943,10 +940,6 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
virCommandAddEnvPair(cmd, "LIBVIRT_LOG_OUTPUTS", outputstr);
VIR_FREE(outputstr);
}
- } else {
- virCommandAddEnvFormat(cmd,
- "LIBVIRT_LOG_OUTPUTS=%d:stderr",
- virLogGetDefaultPriority());
}
virCommandAddArgList(cmd, "--name", vm->def->name, NULL);
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 027cb64..07cd005 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -342,8 +342,6 @@ virFork(void)
} else {
/* child process */
-
- int logprio;
size_t i;
/* Remove any error callback so errors in child now get sent
@@ -354,9 +352,7 @@ virFork(void)
/* Make sure any hook logging is sent to stderr, since child
* process may close the logfile FDs */
- logprio = virLogGetDefaultPriority();
virLogReset();
- virLogSetDefaultPriority(logprio);
/* Clear out all signal handlers from parent so nothing
* unexpected can happen in our child once we unblock
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 738eaac..82fb4dc 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -112,11 +112,6 @@ typedef virLogOutput *virLogOutputPtr;
static virLogOutputPtr virLogOutputs;
static int virLogNbOutputs;
-/*
- * Default priorities
- */
-static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
-
static int virLogResetFilters(void);
static int virLogResetOutputs(void);
static void virLogOutputToFd(virLogSourcePtr src,
@@ -175,7 +170,6 @@ virLogOnceInit(void)
return -1;
virLogLock();
- virLogDefaultPriority = VIR_LOG_DEFAULT;
if (VIR_ALLOC_QUIET(virLogRegex) >= 0) {
if (regcomp(virLogRegex, VIR_LOG_REGEX, REG_EXTENDED) != 0)
@@ -205,35 +199,10 @@ virLogReset(void)
virLogLock();
virLogResetFilters();
virLogResetOutputs();
- virLogDefaultPriority = VIR_LOG_DEFAULT;
virLogUnlock();
return 0;
}
-/**
- * virLogSetDefaultPriority:
- * @priority: the default priority level
- *
- * Set the default priority level, i.e. any logged data of a priority
- * equal or superior to this level will be logged, unless a specific rule
- * was defined for the log category of the message.
- *
- * Returns 0 if successful, -1 in case of error.
- */
-int
-virLogSetDefaultPriority(virLogPriority priority)
-{
- if ((priority < VIR_LOG_DEBUG) || (priority > VIR_LOG_ERROR)) {
- VIR_WARN("Ignoring invalid log level setting.");
- return -1;
- }
- if (virLogInitialize() < 0)
- return -1;
-
- virLogDefaultPriority = priority;
- return 0;
-}
-
/**
* virLogResetFilters:
@@ -472,7 +441,7 @@ virLogSourceUpdate(virLogSourcePtr source)
{
virLogLock();
if (source->serial < virLogFiltersSerial) {
- unsigned int priority = virLogDefaultPriority;
+ unsigned int priority = VIR_LOG_DEFAULT;
unsigned int flags = 0;
size_t i;
@@ -1310,18 +1279,6 @@ virLogParseFilters(const char *filters)
/**
- * virLogGetDefaultPriority:
- *
- * Returns the current logging priority level.
- */
-virLogPriority
-virLogGetDefaultPriority(void)
-{
- return virLogDefaultPriority;
-}
-
-
-/**
* virLogGetFilters:
*
* Returns a string listing the current filters, in the format originally
@@ -1423,35 +1380,53 @@ virLogGetNbOutputs(void)
/**
- * virLogParseDefaultPriority:
+ * virLogParseDebug:
* @priority: string defining the desired logging level
*
- * Parses and sets the default log priority level. It can take a string or
- * number corresponding to the following levels:
+ * This method is a shortcut for setting a filter
+ * along with output to stderr.
+ *
+ * It can take one of the following strings or numbers:
+ *
* 1: DEBUG
* 2: INFO
* 3: WARNING
* 4: ERROR
*
+ * in which case it will set the priority level on the
+ * "libvirt" log source filter. If it does not match any
+ * of these standard strings it will be treated as a full
+ * filter string.
+ *
+ * In all cases an output to stderr will be defined.
+ *
* Returns 0 if successful, -1 in case of error.
*/
int
-virLogParseDefaultPriority(const char *priority)
+virLogParseDebug(const char *debug)
{
- int ret = -1;
+ unsigned int priority = VIR_LOG_DEFAULT;
+ if (STREQ(debug, "1") || STREQ(debug, "debug"))
+ priority = VIR_LOG_DEBUG;
+ else if (STREQ(debug, "2") || STREQ(debug, "info"))
+ priority = VIR_LOG_INFO;
+ else if (STREQ(debug, "3") || STREQ(debug, "warning"))
+ priority = VIR_LOG_WARN;
+ else if (STREQ(debug, "4") || STREQ(debug, "error"))
+ priority = VIR_LOG_ERROR;
+
+ if (priority == VIR_LOG_DEFAULT) {
+ if (virLogParseFilters(debug) < 0)
+ return -1;
+ } else {
+ if (virLogDefineFilter("libvirt", priority, 0) < 0)
+ return -1;
+ }
- if (STREQ(priority, "1") || STREQ(priority, "debug"))
- ret = virLogSetDefaultPriority(VIR_LOG_DEBUG);
- else if (STREQ(priority, "2") || STREQ(priority, "info"))
- ret = virLogSetDefaultPriority(VIR_LOG_INFO);
- else if (STREQ(priority, "3") || STREQ(priority, "warning"))
- ret = virLogSetDefaultPriority(VIR_LOG_WARN);
- else if (STREQ(priority, "4") || STREQ(priority, "error"))
- ret = virLogSetDefaultPriority(VIR_LOG_ERROR);
- else
- VIR_WARN("Ignoring invalid log level setting");
+ if (virLogParseOutputs("1:stderr") < 0)
+ return -1;
- return ret;
+ return 0;
}
@@ -1471,7 +1446,7 @@ virLogSetFromEnv(void)
debugEnv = virGetEnvAllowSUID("LIBVIRT_DEBUG");
if (debugEnv && *debugEnv)
- virLogParseDefaultPriority(debugEnv);
+ virLogParseDebug(debugEnv);
debugEnv = virGetEnvAllowSUID("LIBVIRT_LOG_FILTERS");
if (debugEnv && *debugEnv)
virLogParseFilters(debugEnv);
@@ -1495,3 +1470,10 @@ bool virLogProbablyLogMessage(const char *str)
ret = true;
return ret;
}
+
+
+int virLogSourceGetPriority(virLogSourcePtr source)
+{
+ virLogSourceUpdate(source);
+ return source->priority;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 3ad00d4..aace409 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -73,13 +73,14 @@ struct _virLogSource {
* log statements in a file are conditionally disabled
* at compile time due to configure options.
*/
-# define VIR_LOG_INIT(n) \
- static ATTRIBUTE_UNUSED virLogSource virLogSelf = { \
+# define VIR_LOG_INIT_FULL(n, _var) \
+ static ATTRIBUTE_UNUSED virLogSource _var = { \
.name = "" n "", \
.priority = VIR_LOG_ERROR, \
.serial = 0, \
.flags = 0, \
};
+# define VIR_LOG_INIT(n) VIR_LOG_INIT_FULL(n, virLogSelf)
/*
* If configured with --enable-debug=yes then library calls
@@ -174,8 +175,6 @@ int virLogGetNbFilters(void);
int virLogGetNbOutputs(void);
char *virLogGetFilters(void);
char *virLogGetOutputs(void);
-virLogPriority virLogGetDefaultPriority(void);
-int virLogSetDefaultPriority(virLogPriority priority);
void virLogSetFromEnv(void);
int virLogDefineFilter(const char *match,
virLogPriority priority,
@@ -195,7 +194,7 @@ int virLogDefineOutput(virLogOutputFunc f,
void virLogLock(void);
void virLogUnlock(void);
int virLogReset(void);
-int virLogParseDefaultPriority(const char *priority);
+int virLogParseDebug(const char *debug);
int virLogParseFilters(const char *filters);
int virLogParseOutputs(const char *output);
int virLogPriorityFromSyslog(int priority);
@@ -217,4 +216,6 @@ void virLogVMessage(virLogSourcePtr source,
bool virLogProbablyLogMessage(const char *str);
+int virLogSourceGetPriority(virLogSourcePtr source);
+
#endif
diff --git a/tests/eventtest.c b/tests/eventtest.c
index c4be606..0a31672 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -310,11 +310,7 @@ mymain(void)
if (virThreadInitialize() < 0)
return EXIT_FAILURE;
- char *debugEnv = getenv("LIBVIRT_DEBUG");
- if (debugEnv && *debugEnv && (virLogParseDefaultPriority(debugEnv) == -1)) {
- fprintf(stderr, "Invalid log level setting.\n");
- return EXIT_FAILURE;
- }
+ virLogSetFromEnv();
virEventPollInit();
--
2.5.5
8 years, 5 months
[libvirt] [PATCH] A word error about net-dumpxml --inactive
by sannyshao
---
tools/virsh-network.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 5abcda3..fcf1f0b 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -282,7 +282,7 @@ static const vshCmdOptDef opts_network_dumpxml[] = {
VIRSH_COMMON_OPT_NETWORK,
{.name = "inactive",
.type = VSH_OT_BOOL,
- .help = N_("network information of an inactive domain")
+ .help = N_("network information of an inactive network")
},
{.name = NULL}
};
--
1.8.3.1
8 years, 5 months
[libvirt] [PATCH v2 0/6] Some patches for native TLS encrypted chardev TCP support
by John Ferlan
v1: http://www.redhat.com/archives/libvir-list/2016-June/msg00824.html
Based on Dan's review from patch 4, alter the methodology to use the
libvirt qemu config file to add support for a 'default' and (at first)
a 'chartcp' (I could use chardev, but I was concerned that would imply
more options - udp, unix, etc.).
I have started on the authentication portion of this (e.g. a passwordid=
parameter pointing at a secret object), but I'm a bit held up by the
need to have the secret key patches. I've separated those out and will
post a separate set shortly as well to hopefully get some traction.
For the chartcp, I went with the 'default' location for the /etc/pki
path - that will at least test patch 1. I also tested those locally by
removing the code in qemuxml2xmltest.c to specify the specific -vnc or
-spice paths as the test has.
John Ferlan (6):
conf: Add new default TLS X.509 certificate default directory
conf: Introduce chartcp_tls_x509_cert_dir
qemu: Make qemuBuildShmemBackendStr private
qemu: Add cfg pointer to various command line helpers
qemu: Add support for TLS X.509 path to TCP chardev backend
qemu: Add the ability to hotplug the TLS X.509 environment
src/conf/domain_conf.h | 1 +
src/qemu/libvirtd_qemu.aug | 9 +-
src/qemu/qemu.conf | 52 ++++---
src/qemu/qemu_command.c | 158 ++++++++++++++++++---
src/qemu/qemu_command.h | 12 +-
src/qemu/qemu_conf.c | 45 +++++-
src/qemu/qemu_conf.h | 5 +
src/qemu/qemu_hotplug.c | 29 +++-
src/qemu/qemu_monitor_json.c | 9 ++
src/qemu/test_libvirtd_qemu.aug.in | 3 +
.../qemuxml2argv-serial-tcp-tlsx509-chardev.args | 33 +++++
.../qemuxml2argv-serial-tcp-tlsx509-chardev.xml | 41 ++++++
tests/qemuxml2argvtest.c | 6 +
.../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml | 50 +++++++
tests/qemuxml2xmltest.c | 1 +
15 files changed, 399 insertions(+), 55 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
--
2.5.5
8 years, 5 months
[libvirt] [PATCH 0/2] Don't add a pci-bridge unless needed on Q35/aarch64
by Laine Stump
I had these in a branch waiting for further work to make them more
useful, and abologna asked about this topic, so I'm posting these two patches. Note that in most cases we'll still get a pci-bridge device added (since most devices are legacy PCI) but at least if the config doesn't have any unaddressed PCI devices, that won't happen.
As patch 1 states, the dmi-to-pci-bridge will still be there in all
cases for Q35/aarch64. That needs more work to eliminate.
Laine Stump (2):
qemu: don't be as insistent about adding dmi-to-pci-bridge or
pci-bridge
qemu: don't add pci-bridge to Q35/arm domains unless it's needed
src/qemu/qemu_domain.c | 14 +++++++-------
.../qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args | 1 -
.../qemuxml2argv-aarch64-virtio-pci-default.args | 1 -
tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args | 3 +--
.../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 5 -----
tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root.xml | 5 -----
6 files changed, 8 insertions(+), 21 deletions(-)
--
2.5.5
8 years, 5 months
[libvirt] [PATCH] util: Fix broken syntax-check
by John Ferlan
Commit id '743db933' broke at least one syntax check rule regard open/close
braces and perhaps more with spacing. Just remove the braces
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Pushed as build breaker
src/util/virauthconfig.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c
index b58937c..91c9c0c 100644
--- a/src/util/virauthconfig.c
+++ b/src/util/virauthconfig.c
@@ -123,9 +123,8 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
if (!virKeyFileHasGroup(auth->keyfile, authgroup)) {
VIR_FREE(authgroup);
- if (virAsprintf(&authgroup, "auth-%s-%s", service, "default") < 0){
+ if (virAsprintf(&authgroup, "auth-%s-%s", service, "default") < 0)
goto cleanup;
- }
}
if (!virKeyFileHasGroup(auth->keyfile, authgroup)) {
--
2.5.5
8 years, 5 months
[libvirt] RFC: New CPU hot(un)plug API and XML
by Peter Krempa
Hi list,
I'm planing on adding API that will be used instead of virDomainSetVcpus and
will allow a more granular control of which virtual CPUs are enabled for a
guest.
The new approach will allow to use cpu hotplug properly with NUMA guests as
the old APIs would not allow adding CPUs to very specific cgroups.
The old APIs should still work fine with the current approach although the
final implementation should also allow to unplug vcpus from the guest by using
new qemu features.
I'm still not sure though whether it will be possible to use this in a
backward compatible fashion though depending how this stuff will exactly need
to be set up in qemu.
# API #
As for the new API I'm thinking of the following design:
int
virDomainVcpu(virDomainPtr domain,
unsigned int id,
unsigned int flags);
The flags for this API would be following:
- usual domain modification impact:
* VIR_DOMAIN_SET_VCPU_CURRENT
* VIR_DOMAIN_SET_VCPU_LIVE
* VIR_DOMAIN_SET_VCPU_CONFIG
- for specifying the operation as the default operation would query the cpu
state:
* VIR_DOMAIN_SET_VCPU_ENABLE
* VIR_DOMAIN_SET_VCPU_DISABLE
- misc:
* VIR_DOMAIN_SET_VCPU_GUEST - use the guest agent instead of ACPI hotplug
* VIR_DOMAIN_SET_VCPU_NUMA_NODE - 'id' is the ID of a numa node where the
cpu should be enabled/disabled rather than CPU id. This is a convenience
flag that will allow to add cpu to a given numa node rather than having
to find the correct ID.
* VIR_DOMAIN_SET_VCPU_CORE - use thread level hotplug (see [1]). This
makes sure that the CPU will be plugged in
on platforms that require to plug in multiple
threads at once.
VIR_DOMAIN_SET_VCPU_NUMA_NODE and VIR_DOMAIN_SET_VCPU_GUEST are mutually
exclusive as the guest agent doesn't report the guest numa node the CPU is
belonging to .
If the idea of one API that will both query and set is too nonconformist to
our existing API design I have no problem adding Get/Set versions and/or
explode the ADD/REMOVE flags into a separate parameter.
# XML #
The new API will require us to add new XML that will allow to track the state
of VCPUs individually. Internally we now have a data structure allowing to
keep the relevant data in one place.
Currently we are setting data relevant to VCPUs in many places.
<domain>
[...]
<vcpu current='1'>3</vcpu>
[...]
<cputune>
<cpupin ... />
</cputune>
[...]
<cpu>
<numa>
<cell id='0' cpus='0' memory='102400' unit='KiB/>
<cell id='1' cpus='1-2' memory='102400' unit='KiB/>
</numa>
As we'll be required to keep the state for every single cpu I'm thinking of
adding a new subelement called '<vcpus>' to <domain>. This will have a
'<vcpu>' subelement for every configured cpu.
I'm specifically not going to add any of the cpupin or numa node ids to the
/domain/vcpus/vcpu as input parameters to avoid introducing very compicated
checking code that would be required to keep the data in sync.
I'm thinking of adding the numa node id as an output only attribute since it's
relevant to the hotplug case and it's misplaced otherwise. I certainly can add
the duplicated data as output-only attributes.
The XML with the new elements should look like:
<domain>
[...]
<vcpu current='1'>3</vcpu>
<vcpus>
<vcpu id='0' state='enabled'/> <-- option 1, no extra data
<vcpu id='1' state='disabled' cell='1'/> <--- option 2, just numa node,
since it's non-obvious
<vcpu id='2' state='disabled' cell='1' pin='1-2' scheduler='...'/>
<!-- option 3 all the data duplicated -->
</vcpus>
[...]
<cputune>
<cpupin ... />
</cputune>
[...]
<cpu>
<numa>
<cell id='0' cpus='0' memory='102400' unit='KiB/>
<cell id='1' cpus='1-2' memory='102400' unit='KiB/>
</numa>
# migration #
To ensure migration compatibility a new libvirt will set a new migration
feature flag in cases where a sparse topology was created by any means. Older
versions of libvirt will reject it.
As the new cpu data will be ignored by the parser of older libvirt we don't
need to stop formatting them on migration. (fortunately schemas are not
validated during migration)
# qemu/platform implementation caveats #
When starting the VM for the first time it might be necessary to start a
throw-away qemu process to query some details that we'll need to pass in on a
command line. I'm not sure if this is still necessary and I'll try to avoid it
at all cost.
[1] Some architectures (ppc64) don't directly support thread-level hotplug
and thus require us to plug in a core which translates into multiple threads
(8 in case of power 8).
Possibly other yet unknown problems.
Thanks for your feedback.
Peter
8 years, 5 months
[libvirt] [PATCH] syntax-check: drop prohibit_undesirable_word_seq
by Ján Tomko
This checks forbids using "can not" and checks the placement
of some texinfo tags.
Drop it since we do not use texinfo and the check takes almost
twice as much as the rest of the checks.
---
cfg.mk | 1 +
1 file changed, 1 insertion(+)
diff --git a/cfg.mk b/cfg.mk
index 297ca3a..d82070d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -64,6 +64,7 @@ local-checks-to-skip = \
sc_prohibit_quote_without_use \
sc_prohibit_quotearg_without_use \
sc_prohibit_stat_st_blocks \
+ sc_prohibit_undesirable_word_seq \
sc_root_tests \
sc_space_tab \
sc_sun_os_names \
--
2.7.3
8 years, 5 months
[libvirt] Patch review request for Red Hat Bugzilla Bug 1341866
by Ashish Mittal
Hi,
This is a patch review request in response to the following bugzilla:
Bug 1341866 RFE: Request to upstream libvirt dependencies for qemu based network block driver from Veritas
(1) This patch is required to enable Veritas OpenFlame functionality on RedHat OSP8 platform.
(2) Patch has been created on top of libvirt-1.2.17-13.el7.x86_64. Please let me know in case patch has to be rebased on top of the latest libvirt git master branch instead.
Regards,
Ashish
8 years, 5 months
[libvirt] [PATCH v3 0/7] Introducing storage pool lifecycle event APIs
by Jovanka Gulicoska
Changes since v2 listed in every commit separately
Introducing implementation of storage pool event APIs. Code changes
follow network event APIs.
Implemented functions: virStoragePoolEventRegisterAny(),
virStoragePoolEventDeregisterAny(), virStoragePoolLifeCycleEventNew(),
introduced STARTED, STOPPED, DEFINE, UNDEFINE and REFRESHED.
STARTED signal is emiited in storagePoolCreateXML() and storagePoolCreate()
DEFINED signal is emitted in storagePoolDefineXML()
UNDEFINED signal is emitted in storagePoolUndefine()
STOPPED signal is emitted in storagePoolDestroy() and storagePoolRefresh()
REFRESHED signal is emitted in storagePoolRefresh()
There are also test as well as unittests for the new functions and signals.
This is part of a GSOC project: Asynchronous lifecycle events for storage objects
As part of the project there should also be implementation for
storage volume events.
For now there's no signal when volumes are created or deleted,
they can also be implemented, but probably the easiest way is to have
apps watch for REFRESH signal, and later extend storage driver code to
refresh a pool after volume APIs are called.
Jovanka Gulicoska (7):
Introduce storage lifecycle event APIs
conf: add storage_event handling
test: implement storage lifecycle event APIs
remote: implement storage lifecycle event APIs
storage: implement storage lifecycle event APIs
event-test: support storage lifecycle event APIs
virsh: Introduce virsh-pool command
daemon/libvirtd.h | 2 +
daemon/remote.c | 207 ++++++++++++++++++++++++++++++-
examples/object-events/event-test.c | 73 +++++++++++
include/libvirt/libvirt-storage.h | 93 ++++++++++++++
src/Makefile.am | 5 +
src/conf/storage_conf.h | 4 +
src/conf/storage_event.c | 235 ++++++++++++++++++++++++++++++++++++
src/conf/storage_event.h | 58 +++++++++
src/datatypes.h | 13 ++
src/driver-storage.h | 13 ++
src/libvirt-storage.c | 125 +++++++++++++++++++
src/libvirt_private.syms | 5 +
src/libvirt_public.syms | 6 +
src/remote/remote_driver.c | 128 ++++++++++++++++++++
src/remote/remote_protocol.x | 43 ++++++-
src/remote_protocol-structs | 16 +++
src/storage/storage_driver.c | 110 +++++++++++++++++
src/test/test_driver.c | 71 +++++++++++
tests/objecteventtest.c | 177 +++++++++++++++++++++++++++
tools/virsh-pool.c | 184 ++++++++++++++++++++++++++++
20 files changed, 1564 insertions(+), 4 deletions(-)
create mode 100644 src/conf/storage_event.c
create mode 100644 src/conf/storage_event.h
--
2.5.5
8 years, 5 months