Discussion:
[libvirt] [PATCH 0/7] Remove overhead of disabled logging calls
(too old to reply)
Daniel P. Berrange
2014-03-03 19:18:05 UTC
Permalink
Looking at the performance of the libvirtd event loop when used
with libvirt sandbox and apps which do lots of I/O I discovered
that a huge amount of time was being spent in our logging APIs
making the event loop quite poor at dealing with frequently
firing poll events for small data sizes.

To track this down I created the following short demo program
which simulates a libvirtd event loop thread, watching 500
FDs (eg 500 QEMU or LXC console or monitor FDs). In the test no
logging outputs are enabled, so ideally the log overhead would
be near zero. Running the demo for 51200 iterations initially
took 1 minute 40 seconds. oprofile traces show that in this test
run the logging APIs were totally dominant in CPU time, over the
work done in the event loop. Note the demo program's FD handler
doesn't actually do any work, so this is showing the worst case
behaviour, but it is none-the-less a good illustration of the
loggin overhead.

After refactoring the logging code, the overhead of logging calls
when no outputs are enabled is reduced to a single function call
which does 2 integer comparisons without any mutex locks. The
demo program now completes in 3.3 seconds. IOW, 97% of the original
CPU time for the demo was consumed by the logging APIs !

The main feature we loose in this series is the global logging
buffer. This ring buffer currently collects all log mesages
regardless of log filter settings, and dumps them to stderr upon
crash of libvirtd. As the amount of logging code in libvirt has
grown, the signal/noise ratio of data in the global log buffer
has gone down significantly. Whenever libvirtd crashes, my first
reaction to ask the reporter to reproduce with a specifically
tailored set of log filters set. Thus, IMHO, the global log buffer
is no longer a compelling enough feature to justify its significant
performance overhead.

Rather than remove it entirely though, I've changed it in two
parts. The first patch removes the overhead of it, but leaves a
more tailored verson of it still present. This removes the
contribution it makes to performance overheads. The last patch,
which is not performance relevant, simply deletes the rest of
the global log buffer entirely.

I'm mostly ambivalent on whether to apply patch 7 or not. IMHO the
global log buffer is mostly useless once patch 1 is applied, but if
people think it is worth keeping it, patch 7 can be dropped and I
won't mind.

The demo program used is

$ cat demo.c
#include <libvirt/libvirt.h>
#include <unistd.h>
#include <stdio.h>

static void ignore(int handle, int fd, int events, void *opaque)
{
// nada
}

#define STEPS (1024 * 5)
#define ITERATIONS (STEPS * 10)
#define NFILES 500
int main(int argc, char **argv)
{
int fds[NFILES][2];
int i;

virEventRegisterDefaultImpl();

for (i = 0 ; i < NFILES ; i++) {
char c = '0';
if (pipe(fds[i]) < 0) {
perror("pipe");
return -1;
}
if (write(fds[i][1], &c, 1) < 0)
return -1;
virEventAddHandle(fds[i][0], VIR_EVENT_HANDLE_READABLE,
ignore, NULL, NULL);
}

for (i = 0 ; i < ITERATIONS ; i++) {
if (!(i % STEPS))
fprintf(stderr, ".");
virEventRunDefaultImpl();
}

return 0;
}


Simply compile & run it with no args

$ gcc -Wall `pkg-config --cflags --libs libvirt` -o demo demo.c
$ time ./demo
..........
real 1m39.981s
user 1m34.894s
sys 0m4.851s

Now make it use the newly compiled libvirt version

$ export LD_LIBRARY_PATH=`pwd`/src/.libs
$ time ./demo
..........
real 0m3.316s
user 0m2.896s
sys 0m0.412s

97% execution time removed !

Daniel P. Berrange (7):
Reduce performance overhead of the global log buffer
Refactor code that skips logging of error messages
Move dtrace probe macros into separate header file
Turn virLogSource into a struct instead of an enum
Add virLogSource variables to all source files
Switch to filtering based on log source name instead of filename
Remove global log buffer feature entirely

daemon/libvirtd-config.c | 5 +-
daemon/libvirtd-config.h | 1 -
daemon/libvirtd.aug | 1 -
daemon/libvirtd.c | 5 +-
daemon/libvirtd.conf | 7 -
daemon/libvirtd.h | 1 -
daemon/remote.c | 3 +
daemon/stream.c | 2 +
daemon/test_libvirtd.aug.in | 1 -
docs/apibuild.py | 30 +++
docs/logging.html.in | 10 -
src/access/viraccessdriverpolkit.c | 3 +
src/access/viraccessmanager.c | 3 +
src/bhyve/bhyve_command.c | 2 +
src/bhyve/bhyve_driver.c | 2 +
src/bhyve/bhyve_process.c | 2 +
src/conf/domain_audit.c | 2 +
src/conf/domain_conf.c | 2 +
src/conf/domain_event.c | 1 +
src/conf/network_event.c | 2 +
src/conf/nwfilter_params.c | 2 +
src/conf/object_event.c | 2 +
src/conf/secret_conf.c | 2 +
src/conf/snapshot_conf.c | 2 +
src/conf/storage_conf.c | 1 -
src/conf/virchrdev.c | 2 +
src/cpu/cpu.c | 2 +
src/cpu/cpu_powerpc.c | 2 +
src/cpu/cpu_x86.c | 2 +
src/datatypes.c | 2 +
src/driver.c | 2 +
src/esx/esx_device_monitor.c | 1 -
src/esx/esx_driver.c | 2 +
src/esx/esx_interface_driver.c | 2 -
src/esx/esx_network_driver.c | 2 -
src/esx/esx_nwfilter_driver.c | 2 -
src/esx/esx_secret_driver.c | 2 -
src/esx/esx_storage_backend_iscsi.c | 2 -
src/esx/esx_storage_backend_vmfs.c | 2 +
src/esx/esx_util.c | 2 +-
src/esx/esx_vi.c | 2 +-
src/esx/esx_vi_methods.c | 1 -
src/esx/esx_vi_types.c | 2 +-
src/fdstream.c | 2 +
src/hyperv/hyperv_device_monitor.c | 2 -
src/hyperv/hyperv_driver.c | 3 +-
src/hyperv/hyperv_interface_driver.c | 2 -
src/hyperv/hyperv_network_driver.c | 2 -
src/hyperv/hyperv_nwfilter_driver.c | 2 -
src/hyperv/hyperv_secret_driver.c | 2 -
src/hyperv/hyperv_storage_driver.c | 2 -
src/hyperv/hyperv_util.c | 2 +-
src/hyperv/hyperv_wmi.c | 2 -
src/interface/interface_backend_netcf.c | 2 +
src/internal.h | 74 ------
src/libvirt-lxc.c | 2 +
src/libvirt-qemu.c | 2 +
src/libvirt.c | 2 +
src/libxl/libxl_conf.c | 2 +
src/libxl/libxl_domain.c | 1 +
src/libxl/libxl_driver.c | 2 +
src/locking/domain_lock.c | 2 +
src/locking/lock_daemon.c | 4 +-
src/locking/lock_daemon_config.c | 4 +-
src/locking/lock_daemon_config.h | 1 -
src/locking/lock_daemon_dispatch.c | 5 +-
src/locking/lock_driver_lockd.c | 2 +
src/locking/lock_driver_nop.c | 2 +
src/locking/lock_driver_sanlock.c | 2 +
src/locking/lock_manager.c | 2 +
src/locking/test_virtlockd.aug.in | 2 -
src/locking/virtlockd.aug | 1 -
src/locking/virtlockd.conf | 7 -
src/lxc/lxc_cgroup.c | 2 +
src/lxc/lxc_conf.c | 2 +
src/lxc/lxc_container.c | 2 +
src/lxc/lxc_controller.c | 2 +
src/lxc/lxc_domain.c | 2 +
src/lxc/lxc_driver.c | 1 +
src/lxc/lxc_fuse.c | 1 -
src/lxc/lxc_hostdev.c | 2 +
src/lxc/lxc_monitor.c | 2 +
src/lxc/lxc_native.c | 1 +
src/lxc/lxc_process.c | 2 +
src/network/bridge_driver.c | 2 +
src/network/bridge_driver_linux.c | 3 +
src/network/bridge_driver_platform.h | 1 -
src/node_device/node_device_driver.c | 2 -
src/node_device/node_device_hal.c | 2 +
src/node_device/node_device_linux_sysfs.c | 2 +
src/node_device/node_device_udev.c | 4 +-
src/nodeinfo.c | 1 -
src/nwfilter/nwfilter_dhcpsnoop.c | 2 +
src/nwfilter/nwfilter_driver.c | 2 +
src/nwfilter/nwfilter_ebiptables_driver.c | 2 +
src/nwfilter/nwfilter_gentech_driver.c | 1 +
src/nwfilter/nwfilter_learnipaddr.c | 2 +
src/openvz/openvz_driver.c | 2 +
src/parallels/parallels_driver.c | 2 +
src/phyp/phyp_driver.c | 3 +
src/qemu/qemu_agent.c | 2 +
src/qemu/qemu_bridge_filter.c | 1 -
src/qemu/qemu_capabilities.c | 4 +-
src/qemu/qemu_cgroup.c | 2 +
src/qemu/qemu_command.c | 2 +
src/qemu/qemu_conf.c | 2 +
src/qemu/qemu_domain.c | 2 +
src/qemu/qemu_driver.c | 2 +
src/qemu/qemu_hostdev.c | 2 +
src/qemu/qemu_hotplug.c | 3 +
src/qemu/qemu_migration.c | 2 +
src/qemu/qemu_monitor.c | 3 +
src/qemu/qemu_monitor_json.c | 3 +
src/qemu/qemu_monitor_text.c | 3 +
src/qemu/qemu_process.c | 2 +
src/remote/remote_driver.c | 2 +
src/rpc/virkeepalive.c | 3 +
src/rpc/virnetclient.c | 3 +
src/rpc/virnetclientprogram.c | 2 +
src/rpc/virnetclientstream.c | 2 +
src/rpc/virnetmessage.c | 2 +
src/rpc/virnetsaslcontext.c | 2 +
src/rpc/virnetserver.c | 47 +---
src/rpc/virnetserverclient.c | 3 +
src/rpc/virnetservermdns.c | 2 +
src/rpc/virnetserverprogram.c | 2 +
src/rpc/virnetsocket.c | 2 +
src/rpc/virnetsshsession.c | 2 +
src/rpc/virnettlscontext.c | 3 +
src/secret/secret_driver.c | 2 +
src/security/security_apparmor.c | 3 +
src/security/security_dac.c | 3 +
src/security/security_driver.c | 2 +
src/security/security_manager.c | 1 +
src/security/security_selinux.c | 2 +
src/storage/storage_backend.c | 2 +
src/storage/storage_backend_disk.c | 2 +
src/storage/storage_backend_fs.c | 2 +
src/storage/storage_backend_gluster.c | 2 +
src/storage/storage_backend_iscsi.c | 2 +
src/storage/storage_backend_logical.c | 2 +
src/storage/storage_backend_mpath.c | 2 +
src/storage/storage_backend_rbd.c | 2 +
src/storage/storage_backend_scsi.c | 2 +
src/storage/storage_backend_sheepdog.c | 1 -
src/storage/storage_driver.c | 2 +
src/test/test_driver.c | 2 +
src/uml/uml_conf.c | 1 +
src/uml/uml_driver.c | 2 +
src/util/viralloc.c | 2 +
src/util/virarch.c | 2 +
src/util/viraudit.c | 9 +-
src/util/viraudit.h | 10 +-
src/util/virauth.c | 2 +
src/util/virauthconfig.c | 1 +
src/util/vircgroup.c | 2 +
src/util/virclosecallbacks.c | 2 +
src/util/vircommand.c | 2 +
src/util/virconf.c | 2 +
src/util/virdbus.c | 2 +
src/util/virdnsmasq.c | 3 +
src/util/virebtables.c | 2 +
src/util/virerror.c | 16 +-
src/util/virevent.c | 2 +
src/util/vireventpoll.c | 3 +
src/util/virfile.c | 2 +
src/util/virhash.c | 2 +
src/util/virhook.c | 2 +
src/util/viridentity.c | 1 +
src/util/viriptables.c | 2 +
src/util/virjson.c | 1 +
src/util/virkeyfile.c | 2 +
src/util/virlockspace.c | 2 +
src/util/virlog.c | 379 ++++--------------------------
src/util/virlog.h | 49 ++--
src/util/virnetdev.c | 2 +
src/util/virnetdevmacvlan.c | 1 +
src/util/virnetdevtap.c | 2 +
src/util/virnetdevveth.c | 2 +
src/util/virnetdevvportprofile.c | 2 +
src/util/virnetlink.c | 2 +
src/util/virnodesuspend.c | 2 +
src/util/virnuma.c | 2 +
src/util/virobject.c | 3 +
src/util/virpci.c | 2 +
src/util/virpidfile.c | 2 +
src/util/virprobe.h | 100 ++++++++
src/util/virprocess.c | 2 +
src/util/virrandom.c | 2 +
src/util/virscsi.c | 1 -
src/util/virstoragefile.c | 2 +
src/util/virstring.c | 2 +
src/util/virsysinfo.c | 1 -
src/util/virsystemd.c | 1 +
src/util/virusb.c | 2 +
src/util/virutil.c | 2 +
src/util/viruuid.c | 2 +
src/vbox/vbox_MSCOMGlue.c | 2 +
src/vbox/vbox_XPCOMCGlue.c | 1 +
src/vbox/vbox_driver.c | 1 +
src/vbox/vbox_tmpl.c | 3 +
src/vmx/vmx.c | 2 +
src/xen/xen_driver.c | 3 +
src/xen/xen_hypervisor.c | 2 +
src/xen/xen_inotify.c | 2 +
src/xen/xend_internal.c | 2 +
src/xen/xm_internal.c | 2 +
src/xen/xs_internal.c | 2 +
src/xenapi/xenapi_utils.c | 2 +
src/xenxs/xen_sxpr.c | 2 +
tests/domainconftest.c | 2 +
tests/eventtest.c | 2 +
tests/fdstreamtest.c | 2 +
tests/libvirtdconftest.c | 2 +
tests/qemumonitortestutils.c | 2 +
tests/securityselinuxlabeltest.c | 2 +
tests/securityselinuxtest.c | 2 +
tests/sockettest.c | 2 +
tests/testutils.c | 4 +-
tests/virauthconfigtest.c | 2 +
tests/vircgrouptest.c | 2 +
tests/virdbustest.c | 2 +
tests/virdrivermoduletest.c | 2 +
tests/virhashtest.c | 2 +
tests/viridentitytest.c | 1 +
tests/virkeycodetest.c | 1 +
tests/virkeyfiletest.c | 1 +
tests/virlockspacetest.c | 2 +
tests/virnetmessagetest.c | 2 +
tests/virnetsockettest.c | 2 +
tests/virnettlscontexttest.c | 2 +
tests/virnettlshelpers.c | 2 +
tests/virnettlssessiontest.c | 2 +
tests/virportallocatortest.c | 1 +
tests/virstoragetest.c | 2 +
tests/virstringtest.c | 2 +
tests/virsystemdtest.c | 2 +
tests/virtimetest.c | 2 +
tests/viruritest.c | 2 +
tools/virsh-console.c | 2 +
240 files changed, 637 insertions(+), 563 deletions(-)
create mode 100644 src/util/virprobe.h
--
1.8.5.3
Daniel P. Berrange
2014-03-03 19:18:06 UTC
Permalink
With the vast number of log debug statements in the code, the
logging framework has a measurable performance impact on libvirt
code, particularly in the daemon event loop.

The global log buffer records every single log message triggered
whether anyone cares to see them or not. This makes it impossible
to eliminate the overhead of printf format expansions in any of
the logging code. It is possible to disable the global log buffer
in libvirtd itself, but this doesn't help client side library
code. Also even if disabled by the config file, the existance of
the feature makes other performance improvements in the logging
layer impossible.

Instead of logging every single message to the global buffer, only
log messages that pass the log filters. This if libvirtd is set
to have log_filters="1:libvirt 1:qemu" the global log buffer will
only get filled with those messages instead of everything. This
reduces the performance burden, as well as improving the signal
to noise ratio of the log buffer.

As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 1 minute 40 seconds todo 51200
iterations with nearly all the time shown against the logging
code. After this optimization it only takes 4.6 seconds.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
src/util/virlog.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 68af0f3..e9bd61b 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -833,7 +833,7 @@ virLogVMessage(virLogSource source,
emit = false;
}

- if (!emit && ((virLogBuffer == NULL) || (virLogSize <= 0)))
+ if (!emit)
goto cleanup;

/*
@@ -862,11 +862,7 @@ virLogVMessage(virLogSource source,
virLogStr(timestamp);
virLogStr(": ");
virLogStr(msg);
- virLogUnlock();
- if (!emit)
- goto cleanup;

- virLogLock();
for (i = 0; i < virLogNbOutputs; i++) {
if (priority >= virLogOutputs[i].priority) {
if (virLogOutputs[i].logVersion) {
--
1.8.5.3
Eric Blake
2014-03-05 00:24:03 UTC
Permalink
Post by Daniel P. Berrange
With the vast number of log debug statements in the code, the
logging framework has a measurable performance impact on libvirt
code, particularly in the daemon event loop.
The global log buffer records every single log message triggered
whether anyone cares to see them or not. This makes it impossible
to eliminate the overhead of printf format expansions in any of
the logging code. It is possible to disable the global log buffer
in libvirtd itself, but this doesn't help client side library
code. Also even if disabled by the config file, the existance of
s/existance/existence/
Post by Daniel P. Berrange
the feature makes other performance improvements in the logging
layer impossible.
Instead of logging every single message to the global buffer, only
log messages that pass the log filters. This if libvirtd is set
to have log_filters="1:libvirt 1:qemu" the global log buffer will
only get filled with those messages instead of everything. This
reduces the performance burden, as well as improving the signal
to noise ratio of the log buffer.
For reproducible errors, this is fine - we simply tell a person to
reproduce the crash with the filters that we think are relevant to the
crash. For hard-to-reproduce errors, it means an initial report might
no longer contain the vital clue - but then again, if we have such a low
signal-to-noise ratio, the vital clue may have been flushed out of the
circular log by virtue of the amount of other verbose logging, and is
hard to locate anyways. So I'm okay with this patch.
Post by Daniel P. Berrange
As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 1 minute 40 seconds todo 51200
s/todo/to do/
Post by Daniel P. Berrange
iterations with nearly all the time shown against the logging
code. After this optimization it only takes 4.6 seconds.
---
src/util/virlog.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 68af0f3..e9bd61b 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -833,7 +833,7 @@ virLogVMessage(virLogSource source,
emit = false;
}
- if (!emit && ((virLogBuffer == NULL) || (virLogSize <= 0)))
+ if (!emit)
goto cleanup;
This skips the printf() overhead.
Post by Daniel P. Berrange
/*
@@ -862,11 +862,7 @@ virLogVMessage(virLogSource source,
virLogStr(timestamp);
virLogStr(": ");
virLogStr(msg);
- virLogUnlock();
- if (!emit)
- goto cleanup;
- virLogLock();
Why were we unlocking and relocking anyways? Less overhead than above,
but also a reasonable change.

ACK.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-03 19:18:07 UTC
Permalink
The virRaiseErrorFull method sends all error messages onto the
logging code. The logging code has some logic to skip emission
when no log outputs are configured which checks the virLogSource.
This will complicate later refactoring, and the check can easily
be done in the virRaiseErrorFull method instead of in the logging
code.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
src/util/virerror.c | 14 ++++++++++----
src/util/virlog.c | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/util/virerror.c b/src/util/virerror.c
index 820e1ad..562c871 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -709,10 +709,16 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
if (virErrorLogPriorityFilter)
priority = virErrorLogPriorityFilter(to, priority);

- virLogMessage(virErrorLogPriorityFilter ? VIR_LOG_FROM_FILE : VIR_LOG_FROM_ERROR,
- priority,
- filename, linenr, funcname,
- meta, "%s", str);
+ /* We don't want to pollute stderr if no logging outputs
+ * are explicitly requested by the user, since the default
+ * error function already pollutes stderr and most apps
+ * hate & thus disable that too.
+ */
+ if (virLogGetNbOutputs() > 0)
+ virLogMessage(virErrorLogPriorityFilter ? VIR_LOG_FROM_FILE : VIR_LOG_FROM_ERROR,
+ priority,
+ filename, linenr, funcname,
+ meta, "%s", str);

errno = save_errno;
}
diff --git a/src/util/virlog.c b/src/util/virlog.c
index e9bd61b..801f259 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -882,7 +882,7 @@ virLogVMessage(virLogSource source,
str, msg, virLogOutputs[i].data);
}
}
- if ((virLogNbOutputs == 0) && (source != VIR_LOG_FROM_ERROR)) {
+ if (virLogNbOutputs == 0) {
if (logVersionStderr) {
const char *rawver;
char *ver = NULL;
--
1.8.5.3
Eric Blake
2014-03-05 00:32:50 UTC
Permalink
Post by Daniel P. Berrange
The virRaiseErrorFull method sends all error messages onto the
s/onto/on to/
Post by Daniel P. Berrange
logging code. The logging code has some logic to skip emission
when no log outputs are configured which checks the virLogSource.
This will complicate later refactoring, and the check can easily
be done in the virRaiseErrorFull method instead of in the logging
code.
---
src/util/virerror.c | 14 ++++++++++----
src/util/virlog.c | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)
ACK
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-03 19:18:08 UTC
Permalink
The dtrace probe macros rely on the logging API. We can't make
the internal.h header include the virlog.h header though since
that'd be a circular include. Instead simply split the dtrace
probes into their own header file, since there's no compelling
reason for them to be in the main internal.h header.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
daemon/remote.c | 1 +
src/internal.h | 74 --------------------------------
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_monitor_text.c | 1 +
src/rpc/virkeepalive.c | 1 +
src/rpc/virnetclient.c | 1 +
src/rpc/virnetserverclient.c | 1 +
src/rpc/virnetsocket.c | 1 +
src/rpc/virnettlscontext.c | 1 +
src/util/vireventpoll.c | 1 +
src/util/virobject.c | 1 +
src/util/virprobe.h | 100 +++++++++++++++++++++++++++++++++++++++++++
13 files changed, 111 insertions(+), 74 deletions(-)
create mode 100644 src/util/virprobe.h

diff --git a/daemon/remote.c b/daemon/remote.c
index 932f65f..3db5df3 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -52,6 +52,7 @@
#include "object_event.h"
#include "domain_conf.h"
#include "network_conf.h"
+#include "virprobe.h"
#include "viraccessapicheck.h"

#define VIR_FROM_THIS VIR_FROM_RPC
diff --git a/src/internal.h b/src/internal.h
index cef3da0..dc1899e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -365,78 +365,4 @@
/* round up value to the closest multiple of size */
# define VIR_ROUND_UP(value, size) (VIR_DIV_UP(value, size) * (size))

-
-# if WITH_DTRACE_PROBES
-# ifndef LIBVIRT_PROBES_H
-# define LIBVIRT_PROBES_H
-# include "libvirt_probes.h"
-# endif /* LIBVIRT_PROBES_H */
-
-/* Systemtap 1.2 headers have a bug where they cannot handle a
- * variable declared with array type. Work around this by casting all
- * arguments. This is some gross use of the preprocessor because
- * PROBE is a var-arg macro, but it is better than the alternative of
- * making all callers to PROBE have to be aware of the issues. And
- * hopefully, if we ever add a call to PROBE with other than 9
- * end arguments, you can figure out the pattern to extend this hack.
- */
-# define VIR_COUNT_ARGS(...) VIR_ARG11(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
-# define VIR_ARG11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) _11
-# define VIR_ADD_CAST_EXPAND(a, b, ...) VIR_ADD_CAST_PASTE(a, b, __VA_ARGS__)
-# define VIR_ADD_CAST_PASTE(a, b, ...) a##b(__VA_ARGS__)
-
-/* The double cast is necessary to silence gcc warnings; any pointer
- * can safely go to intptr_t and back to void *, which collapses
- * arrays into pointers; while any integer can be widened to intptr_t
- * then cast to void *. */
-# define VIR_ADD_CAST(a) ((void *)(intptr_t)(a))
-# define VIR_ADD_CAST1(a) \
- VIR_ADD_CAST(a)
-# define VIR_ADD_CAST2(a, b) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b)
-# define VIR_ADD_CAST3(a, b, c) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c)
-# define VIR_ADD_CAST4(a, b, c, d) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
- VIR_ADD_CAST(d)
-# define VIR_ADD_CAST5(a, b, c, d, e) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
- VIR_ADD_CAST(d), VIR_ADD_CAST(e)
-# define VIR_ADD_CAST6(a, b, c, d, e, f) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
- VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f)
-# define VIR_ADD_CAST7(a, b, c, d, e, f, g) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
- VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f), \
- VIR_ADD_CAST(g)
-# define VIR_ADD_CAST8(a, b, c, d, e, f, g, h) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
- VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f), \
- VIR_ADD_CAST(g), VIR_ADD_CAST(h)
-# define VIR_ADD_CAST9(a, b, c, d, e, f, g, h, i) \
- VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
- VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f), \
- VIR_ADD_CAST(g), VIR_ADD_CAST(h), VIR_ADD_CAST(i)
-
-# define VIR_ADD_CASTS(...) \
- VIR_ADD_CAST_EXPAND(VIR_ADD_CAST, VIR_COUNT_ARGS(__VA_ARGS__), \
- __VA_ARGS__)
-
-# define PROBE_EXPAND(NAME, ARGS) NAME(ARGS)
-# define PROBE(NAME, FMT, ...) \
- VIR_DEBUG_INT(VIR_LOG_FROM_TRACE, \
- __FILE__, __LINE__, __func__, \
- #NAME ": " FMT, __VA_ARGS__); \
- if (LIBVIRT_ ## NAME ## _ENABLED()) { \
- PROBE_EXPAND(LIBVIRT_ ## NAME, \
- VIR_ADD_CASTS(__VA_ARGS__)); \
- }
-# else
-# define PROBE(NAME, FMT, ...) \
- VIR_DEBUG_INT(VIR_LOG_FROM_TRACE, \
- __FILE__, __LINE__, __func__, \
- #NAME ": " FMT, __VA_ARGS__);
-# endif
-
-
#endif /* __VIR_INTERNAL_H__ */
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index a2769db..8f8f5c3 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -40,6 +40,7 @@
#include "virfile.h"
#include "virprocess.h"
#include "virobject.h"
+#include "virprobe.h"
#include "virstring.h"

#ifdef WITH_DTRACE_PROBES
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5e825ac..0b39bf7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -41,6 +41,7 @@
#include "datatypes.h"
#include "virerror.h"
#include "virjson.h"
+#include "virprobe.h"
#include "virstring.h"
#include "cpu/cpu_x86.h"

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7b81079..6e520bd 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -40,6 +40,7 @@
#include "datatypes.h"
#include "virerror.h"
#include "virbuffer.h"
+#include "virprobe.h"
#include "virstring.h"

#ifdef WITH_DTRACE_PROBES
diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index 8ae5c6c..fcc43ad 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -30,6 +30,7 @@
#include "virnetsocket.h"
#include "virkeepaliveprotocol.h"
#include "virkeepalive.h"
+#include "virprobe.h"

#define VIR_FROM_THIS VIR_FROM_RPC

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 9deec9e..fe3e055 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -36,6 +36,7 @@
#include "virlog.h"
#include "virutil.h"
#include "virerror.h"
+#include "virprobe.h"
#include "virstring.h"

#define VIR_FROM_THIS VIR_FROM_RPC
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 52b4941..7b6d82d 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -35,6 +35,7 @@
#include "viralloc.h"
#include "virthread.h"
#include "virkeepalive.h"
+#include "virprobe.h"
#include "virstring.h"
#include "virutil.h"

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 04bf25a..be1df6c 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -51,6 +51,7 @@
#include "virlog.h"
#include "virfile.h"
#include "virthread.h"
+#include "virprobe.h"
#include "virprocess.h"
#include "virstring.h"
#include "passfd.h"
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index cd69794..27a00d0 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -39,6 +39,7 @@
#include "virfile.h"
#include "virutil.h"
#include "virlog.h"
+#include "virprobe.h"
#include "virthread.h"
#include "configmake.h"

diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index 8a4c8bc..6f1e184 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -38,6 +38,7 @@
#include "virutil.h"
#include "virfile.h"
#include "virerror.h"
+#include "virprobe.h"
#include "virtime.h"

#define EVENT_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 4f83bc1..5e3ee71 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -28,6 +28,7 @@
#include "viratomic.h"
#include "virerror.h"
#include "virlog.h"
+#include "virprobe.h"
#include "virstring.h"

#define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/util/virprobe.h b/src/util/virprobe.h
new file mode 100644
index 0000000..1891135
--- /dev/null
+++ b/src/util/virprobe.h
@@ -0,0 +1,100 @@
+/*
+ * virlog.h: internal logging and debugging
+ *
+ * Copyright (C) 2006-2008, 2011-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __VIR_PROBE_H__
+# define __VIR_PROBE_H__
+
+# include "internal.h"
+# include "virlog.h"
+
+# if WITH_DTRACE_PROBES
+# ifndef LIBVIRT_PROBES_H
+# define LIBVIRT_PROBES_H
+# include "libvirt_probes.h"
+# endif /* LIBVIRT_PROBES_H */
+
+/* Systemtap 1.2 headers have a bug where they cannot handle a
+ * variable declared with array type. Work around this by casting all
+ * arguments. This is some gross use of the preprocessor because
+ * PROBE is a var-arg macro, but it is better than the alternative of
+ * making all callers to PROBE have to be aware of the issues. And
+ * hopefully, if we ever add a call to PROBE with other than 9
+ * end arguments, you can figure out the pattern to extend this hack.
+ */
+# define VIR_COUNT_ARGS(...) VIR_ARG11(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
+# define VIR_ARG11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) _11
+# define VIR_ADD_CAST_EXPAND(a, b, ...) VIR_ADD_CAST_PASTE(a, b, __VA_ARGS__)
+# define VIR_ADD_CAST_PASTE(a, b, ...) a##b(__VA_ARGS__)
+
+/* The double cast is necessary to silence gcc warnings; any pointer
+ * can safely go to intptr_t and back to void *, which collapses
+ * arrays into pointers; while any integer can be widened to intptr_t
+ * then cast to void *. */
+# define VIR_ADD_CAST(a) ((void *)(intptr_t)(a))
+# define VIR_ADD_CAST1(a) \
+ VIR_ADD_CAST(a)
+# define VIR_ADD_CAST2(a, b) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b)
+# define VIR_ADD_CAST3(a, b, c) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c)
+# define VIR_ADD_CAST4(a, b, c, d) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
+ VIR_ADD_CAST(d)
+# define VIR_ADD_CAST5(a, b, c, d, e) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
+ VIR_ADD_CAST(d), VIR_ADD_CAST(e)
+# define VIR_ADD_CAST6(a, b, c, d, e, f) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
+ VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f)
+# define VIR_ADD_CAST7(a, b, c, d, e, f, g) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
+ VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f), \
+ VIR_ADD_CAST(g)
+# define VIR_ADD_CAST8(a, b, c, d, e, f, g, h) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
+ VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f), \
+ VIR_ADD_CAST(g), VIR_ADD_CAST(h)
+# define VIR_ADD_CAST9(a, b, c, d, e, f, g, h, i) \
+ VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c), \
+ VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f), \
+ VIR_ADD_CAST(g), VIR_ADD_CAST(h), VIR_ADD_CAST(i)
+
+# define VIR_ADD_CASTS(...) \
+ VIR_ADD_CAST_EXPAND(VIR_ADD_CAST, VIR_COUNT_ARGS(__VA_ARGS__), \
+ __VA_ARGS__)
+
+# define PROBE_EXPAND(NAME, ARGS) NAME(ARGS)
+# define PROBE(NAME, FMT, ...) \
+ VIR_DEBUG_INT(VIR_LOG_FROM_TRACE, \
+ NULL, __LINE__, __func__, \
+ #NAME ": " FMT, __VA_ARGS__); \
+ if (LIBVIRT_ ## NAME ## _ENABLED()) { \
+ PROBE_EXPAND(LIBVIRT_ ## NAME, \
+ VIR_ADD_CASTS(__VA_ARGS__)); \
+ }
+# else
+# define PROBE(NAME, FMT, ...) \
+ VIR_DEBUG_INT(VIR_LOG_FROM_TRACE, \
+ NULL, __LINE__, __func__, \
+ #NAME ": " FMT, __VA_ARGS__);
+# endif
+
+#endif /* __VIR_PROBE_H__ */
--
1.8.5.3
Eric Blake
2014-03-05 00:37:42 UTC
Permalink
Post by Daniel P. Berrange
The dtrace probe macros rely on the logging API. We can't make
the internal.h header include the virlog.h header though since
that'd be a circular include. Instead simply split the dtrace
probes into their own header file, since there's no compelling
reason for them to be in the main internal.h header.
---
daemon/remote.c | 1 +
src/internal.h | 74 --------------------------------
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_monitor_text.c | 1 +
src/rpc/virkeepalive.c | 1 +
src/rpc/virnetclient.c | 1 +
src/rpc/virnetserverclient.c | 1 +
src/rpc/virnetsocket.c | 1 +
src/rpc/virnettlscontext.c | 1 +
src/util/vireventpoll.c | 1 +
src/util/virobject.c | 1 +
src/util/virprobe.h | 100 +++++++++++++++++++++++++++++++++++++++++++
13 files changed, 111 insertions(+), 74 deletions(-)
create mode 100644 src/util/virprobe.h
ACK
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
John Ferlan
2014-03-05 14:18:54 UTC
Permalink
Post by Daniel P. Berrange
The dtrace probe macros rely on the logging API. We can't make
the internal.h header include the virlog.h header though since
that'd be a circular include. Instead simply split the dtrace
probes into their own header file, since there's no compelling
reason for them to be in the main internal.h header.
---
daemon/remote.c | 1 +
src/internal.h | 74 --------------------------------
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_monitor_text.c | 1 +
src/rpc/virkeepalive.c | 1 +
src/rpc/virnetclient.c | 1 +
src/rpc/virnetserverclient.c | 1 +
src/rpc/virnetsocket.c | 1 +
src/rpc/virnettlscontext.c | 1 +
src/util/vireventpoll.c | 1 +
src/util/virobject.c | 1 +
src/util/virprobe.h | 100 +++++++++++++++++++++++++++++++++++++++++++
13 files changed, 111 insertions(+), 74 deletions(-)
create mode 100644 src/util/virprobe.h
<...snip...>
Post by Daniel P. Berrange
--- /dev/null
+++ b/src/util/virprobe.h
@@ -0,0 +1,100 @@
+/*
+ * virlog.h: internal logging and debugging
NIT: virprobe.h
Post by Daniel P. Berrange
+ *
+ * Copyright (C) 2006-2008, 2011-2012 Red Hat, Inc.
+ *
Should this be just 2014 or the range?

John
Daniel P. Berrange
2014-03-10 14:27:34 UTC
Permalink
Post by John Ferlan
Post by Daniel P. Berrange
The dtrace probe macros rely on the logging API. We can't make
the internal.h header include the virlog.h header though since
that'd be a circular include. Instead simply split the dtrace
probes into their own header file, since there's no compelling
reason for them to be in the main internal.h header.
---
daemon/remote.c | 1 +
src/internal.h | 74 --------------------------------
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_monitor_text.c | 1 +
src/rpc/virkeepalive.c | 1 +
src/rpc/virnetclient.c | 1 +
src/rpc/virnetserverclient.c | 1 +
src/rpc/virnetsocket.c | 1 +
src/rpc/virnettlscontext.c | 1 +
src/util/vireventpoll.c | 1 +
src/util/virobject.c | 1 +
src/util/virprobe.h | 100 +++++++++++++++++++++++++++++++++++++++++++
13 files changed, 111 insertions(+), 74 deletions(-)
create mode 100644 src/util/virprobe.h
<...snip...>
Post by Daniel P. Berrange
--- /dev/null
+++ b/src/util/virprobe.h
@@ -0,0 +1,100 @@
+/*
+ * virlog.h: internal logging and debugging
NIT: virprobe.h
Yep
Post by John Ferlan
Post by Daniel P. Berrange
+ *
+ * Copyright (C) 2006-2008, 2011-2012 Red Hat, Inc.
+ *
Should this be just 2014 or the range?
I've changed to 2006-2014


Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Daniel P. Berrange
2014-03-03 19:18:09 UTC
Permalink
As part of the goal to get away from doing string matching on
filenames when deciding whether to emit a log message, turn
the virLogSource enum into a struct which contains a log
"name". There will eventually be one virLogSource instance
statically declared per source file. To minimise churn in this
commit though, a single global instance is used.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
src/util/viraudit.c | 7 ++++---
src/util/viraudit.h | 10 ++++++----
src/util/virerror.c | 2 +-
src/util/virlog.c | 30 ++++++++++++------------------
src/util/virlog.h | 33 ++++++++++++++++-----------------
src/util/virprobe.h | 4 ++--
tests/testutils.c | 2 +-
10 files changed, 45 insertions(+), 48 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3d8f2e3..4bd3ec3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1437,6 +1437,7 @@ virLogParseOutputs;
virLogPriorityFromSyslog;
virLogProbablyLogMessage;
virLogReset;
+virLogSelf;
virLogSetBufferSize;
virLogSetDefaultPriority;
virLogSetFromEnv;
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 5d49968..5c48fe8 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -374,7 +374,7 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,

format = virBufferContentAndReset(&buf);

- virLogVMessage(VIR_LOG_FROM_LIBRARY,
+ virLogVMessage(&virLogSelf,
virLogPriorityFromSyslog(priority),
file, line, fn, NULL, format ? format : fmt, args);

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 76a8c73..70b5f15 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2766,7 +2766,7 @@ virQEMUCapsLogProbeFailure(const char *binary)
};
virErrorPtr err = virGetLastError();

- virLogMessage(VIR_LOG_FROM_FILE,
+ virLogMessage(&virLogSelf,
VIR_LOG_WARN,
__FILE__, __LINE__, __func__,
meta,
diff --git a/src/util/viraudit.c b/src/util/viraudit.c
index 5dd4e1f..1d9442e 100644
--- a/src/util/viraudit.c
+++ b/src/util/viraudit.c
@@ -74,7 +74,8 @@ void virAuditLog(int logging)
}


-void virAuditSend(const char *filename,
+void virAuditSend(virLogSourcePtr source,
+ const char *filename,
size_t linenr,
const char *funcname,
const char *clienttty ATTRIBUTE_UNUSED,
@@ -104,11 +105,11 @@ void virAuditSend(const char *filename,

if (auditlog && str) {
if (success)
- virLogMessage(VIR_LOG_FROM_AUDIT, VIR_LOG_INFO,
+ virLogMessage(source, VIR_LOG_INFO, /* XXX */
filename, linenr, funcname,
NULL, "success=yes %s", str);
else
- virLogMessage(VIR_LOG_FROM_AUDIT, VIR_LOG_WARN,
+ virLogMessage(source, VIR_LOG_WARN, /* XXX */
filename, linenr, funcname,
NULL, "success=no %s", str);
}
diff --git a/src/util/viraudit.h b/src/util/viraudit.h
index b0356da..cf3da6c 100644
--- a/src/util/viraudit.h
+++ b/src/util/viraudit.h
@@ -24,6 +24,7 @@
# define __LIBVIRT_AUDIT_H__

# include "internal.h"
+# include "virlog.h"

enum virAuditRecordType {
VIR_AUDIT_RECORD_MACHINE_CONTROL,
@@ -35,22 +36,23 @@ int virAuditOpen(void);

void virAuditLog(int enabled);

-void virAuditSend(const char *filename, size_t linenr, const char *funcname,
+void virAuditSend(virLogSourcePtr source,
+ const char *filename, size_t linenr, const char *funcname,
const char *clienttty, const char *clientaddr,
enum virAuditRecordType type, bool success,
const char *fmt, ...)
- ATTRIBUTE_FMT_PRINTF(8, 9);
+ ATTRIBUTE_FMT_PRINTF(9, 10);

char *virAuditEncode(const char *key, const char *value);

void virAuditClose(void);

# define VIR_AUDIT(type, success, ...) \
- virAuditSend(__FILE__, __LINE__, __func__, \
+ virAuditSend(&virLogSelf, __FILE__, __LINE__, __func__, \
NULL, NULL, type, success, __VA_ARGS__);

# define VIR_AUDIT_USER(type, success, clienttty, clientaddr, ...) \
- virAuditSend(__FILE__, __LINE__, __func__, \
+ virAuditSend(&virLogSelf, __FILE__, __LINE__, __func__, \
clienttty, clientaddr, type, success, __VA_ARGS__);

# define VIR_AUDIT_STR(str) \
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 562c871..123e51f 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -715,7 +715,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
* hate & thus disable that too.
*/
if (virLogGetNbOutputs() > 0)
- virLogMessage(virErrorLogPriorityFilter ? VIR_LOG_FROM_FILE : VIR_LOG_FROM_ERROR,
+ virLogMessage(&virLogSelf,
priority,
filename, linenr, funcname,
meta, "%s", str);
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 801f259..b535623 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -60,14 +60,6 @@

#define VIR_FROM_THIS VIR_FROM_NONE

-VIR_ENUM_DECL(virLogSource)
-VIR_ENUM_IMPL(virLogSource, VIR_LOG_FROM_LAST,
- "file",
- "error",
- "audit",
- "trace",
- "library");
-
/*
* A logging buffer to keep some history over logs
*/
@@ -104,6 +96,8 @@ typedef virLogFilter *virLogFilterPtr;
static virLogFilterPtr virLogFilters = NULL;
static int virLogNbFilters = 0;

+virLogSource virLogSelf = { .name = "util.log" };
+
/*
* Outputs are used to emit the messages retained
* after filtering, multiple output can be used simultaneously
@@ -130,7 +124,7 @@ static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;

static int virLogResetFilters(void);
static int virLogResetOutputs(void);
-static void virLogOutputToFd(virLogSource src,
+static void virLogOutputToFd(virLogSourcePtr src,
virLogPriority priority,
const char *filename,
int linenr,
@@ -142,6 +136,7 @@ static void virLogOutputToFd(virLogSource src,
const char *str,
void *data);

+
/*
* Logs accesses must be serialized though a mutex
*/
@@ -765,7 +760,7 @@ virLogVersionString(const char **rawmsg,
* the message may be stored, sent to output or just discarded
*/
void
-virLogMessage(virLogSource source,
+virLogMessage(virLogSourcePtr source,
virLogPriority priority,
const char *filename,
int linenr,
@@ -797,7 +792,7 @@ virLogMessage(virLogSource source,
* the message may be stored, sent to output or just discarded
*/
void
-virLogVMessage(virLogSource source,
+virLogVMessage(virLogSourcePtr source,
virLogPriority priority,
const char *filename,
int linenr,
@@ -869,7 +864,7 @@ virLogVMessage(virLogSource source,
const char *rawver;
char *ver = NULL;
if (virLogVersionString(&rawver, &ver) >= 0)
- virLogOutputs[i].f(VIR_LOG_FROM_FILE, VIR_LOG_INFO,
+ virLogOutputs[i].f(&virLogSelf, VIR_LOG_INFO,
__FILE__, __LINE__, __func__,
timestamp, NULL, 0, rawver, ver,
virLogOutputs[i].data);
@@ -887,7 +882,7 @@ virLogVMessage(virLogSource source,
const char *rawver;
char *ver = NULL;
if (virLogVersionString(&rawver, &ver) >= 0)
- virLogOutputToFd(VIR_LOG_FROM_FILE, VIR_LOG_INFO,
+ virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
__FILE__, __LINE__, __func__,
timestamp, NULL, 0, rawver, ver,
(void *) STDERR_FILENO);
@@ -929,7 +924,7 @@ virLogStackTraceToFd(int fd)
}

static void
-virLogOutputToFd(virLogSource source ATTRIBUTE_UNUSED,
+virLogOutputToFd(virLogSourcePtr source ATTRIBUTE_UNUSED,
virLogPriority priority ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED,
int linenr ATTRIBUTE_UNUSED,
@@ -1033,7 +1028,7 @@ virLogPrioritySyslog(virLogPriority priority)

#if HAVE_SYSLOG_H
static void
-virLogOutputToSyslog(virLogSource source ATTRIBUTE_UNUSED,
+virLogOutputToSyslog(virLogSourcePtr source ATTRIBUTE_UNUSED,
virLogPriority priority,
const char *filename ATTRIBUTE_UNUSED,
int linenr ATTRIBUTE_UNUSED,
@@ -1160,7 +1155,7 @@ journalAddInt(struct journalState *state, const char *field, int value)
static int journalfd = -1;

static void
-virLogOutputToJournald(virLogSource source,
+virLogOutputToJournald(virLogSourcePtr source,
virLogPriority priority,
const char *filename,
int linenr,
@@ -1202,8 +1197,7 @@ virLogOutputToJournald(virLogSource source,
journalAddString(&state, "MESSAGE", rawstr);
journalAddInt(&state, "PRIORITY",
virLogPrioritySyslog(priority));
- journalAddString(&state, "LIBVIRT_SOURCE",
- virLogSourceTypeToString(source));
+ journalAddString(&state, "LIBVIRT_SOURCE", source->name);
if (filename)
journalAddString(&state, "CODE_FILE", filename);
journalAddInt(&state, "CODE_LINE", linenr);
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 6ba2daa..cb27725 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -44,15 +44,14 @@ typedef enum {
VIR_LOG_TO_JOURNALD,
} virLogDestination;

-typedef enum {
- VIR_LOG_FROM_FILE, /* General debugging */
- VIR_LOG_FROM_ERROR, /* Errors reported */
- VIR_LOG_FROM_AUDIT, /* Audit operations */
- VIR_LOG_FROM_TRACE, /* DTrace probe pointers */
- VIR_LOG_FROM_LIBRARY, /* 3rd party libraries */
+typedef struct _virLogSource virLogSource;
+typedef virLogSource *virLogSourcePtr;
+
+struct _virLogSource {
+ const char *name;
+};

- VIR_LOG_FROM_LAST,
-} virLogSource;
+extern virLogSource virLogSelf;

/*
* If configured with --enable-debug=yes then library calls
@@ -68,7 +67,7 @@ typedef enum {
*
* Do nothing but eat parameters.
*/
-static inline void virLogEatParams(virLogSource unused, ...)
+static inline void virLogEatParams(virLog unused, ...)
{
/* Silence gcc */
unused = unused;
@@ -85,13 +84,13 @@ static inline void virLogEatParams(virLogSource unused, ...)
virLogMessage(src, VIR_LOG_ERROR, filename, linenr, funcname, NULL, __VA_ARGS__)

# define VIR_DEBUG(...) \
- VIR_DEBUG_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+ VIR_DEBUG_INT(&virLogSelf, __FILE__, __LINE__, __func__, __VA_ARGS__)
# define VIR_INFO(...) \
- VIR_INFO_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+ VIR_INFO_INT(&virLogSelf, __FILE__, __LINE__, __func__, __VA_ARGS__)
# define VIR_WARN(...) \
- VIR_WARN_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+ VIR_WARN_INT(&virLogSelf, __FILE__, __LINE__, __func__, __VA_ARGS__)
# define VIR_ERROR(...) \
- VIR_ERROR_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+ VIR_ERROR_INT(&virLogSelf, __FILE__, __LINE__, __func__, __VA_ARGS__)


struct _virLogMetadata {
@@ -105,7 +104,7 @@ typedef struct _virLogMetadata *virLogMetadataPtr;

/**
* virLogOutputFunc:
- * @src: the src for the message
+ * @src: the source of the log message
* @priority: the priority for the message
* @filename: file where the message was emitted
* @linenr: line where the message was emitted
@@ -119,7 +118,7 @@ typedef struct _virLogMetadata *virLogMetadataPtr;
*
* Callback function used to output messages
*/
-typedef void (*virLogOutputFunc) (virLogSource src,
+typedef void (*virLogOutputFunc) (virLogSourcePtr src,
virLogPriority priority,
const char *filename,
int linenr,
@@ -172,14 +171,14 @@ extern int virLogParseDefaultPriority(const char *priority);
extern int virLogParseFilters(const char *filters);
extern int virLogParseOutputs(const char *output);
extern int virLogPriorityFromSyslog(int priority);
-extern void virLogMessage(virLogSource src,
+extern void virLogMessage(virLogSourcePtr source,
virLogPriority priority,
const char *filename,
int linenr,
const char *funcname,
virLogMetadataPtr metadata,
const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(7, 8);
-extern void virLogVMessage(virLogSource src,
+extern void virLogVMessage(virLogSourcePtr source,
virLogPriority priority,
const char *filename,
int linenr,
diff --git a/src/util/virprobe.h b/src/util/virprobe.h
index 1891135..c6e07af 100644
--- a/src/util/virprobe.h
+++ b/src/util/virprobe.h
@@ -83,7 +83,7 @@

# define PROBE_EXPAND(NAME, ARGS) NAME(ARGS)
# define PROBE(NAME, FMT, ...) \
- VIR_DEBUG_INT(VIR_LOG_FROM_TRACE, \
+ VIR_DEBUG_INT(&virLogSelf, \
NULL, __LINE__, __func__, \
#NAME ": " FMT, __VA_ARGS__); \
if (LIBVIRT_ ## NAME ## _ENABLED()) { \
@@ -92,7 +92,7 @@
}
# else
# define PROBE(NAME, FMT, ...) \
- VIR_DEBUG_INT(VIR_LOG_FROM_TRACE, \
+ VIR_DEBUG_INT(&virLogSelf, \
NULL, __LINE__, __func__, \
#NAME ": " FMT, __VA_ARGS__);
# endif
diff --git a/tests/testutils.c b/tests/testutils.c
index 97d5b50..f88c18d 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -584,7 +584,7 @@ struct virtTestLogData {
static struct virtTestLogData testLog = { VIR_BUFFER_INITIALIZER };

static void
-virtTestLogOutput(virLogSource source ATTRIBUTE_UNUSED,
+virtTestLogOutput(virLogSourcePtr source ATTRIBUTE_UNUSED,
virLogPriority priority ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED,
int lineno ATTRIBUTE_UNUSED,
--
1.8.5.3
Ján Tomko
2014-03-05 08:05:37 UTC
Permalink
Post by Daniel P. Berrange
As part of the goal to get away from doing string matching on
filenames when deciding whether to emit a log message, turn
the virLogSource enum into a struct which contains a log
"name". There will eventually be one virLogSource instance
statically declared per source file. To minimise churn in this
commit though, a single global instance is used.
---
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
src/util/viraudit.c | 7 ++++---
src/util/viraudit.h | 10 ++++++----
src/util/virerror.c | 2 +-
src/util/virlog.c | 30 ++++++++++++------------------
src/util/virlog.h | 33 ++++++++++++++++-----------------
src/util/virprobe.h | 4 ++--
tests/testutils.c | 2 +-
10 files changed, 45 insertions(+), 48 deletions(-)
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 6ba2daa..cb27725 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -68,7 +67,7 @@ typedef enum {
*
* Do nothing but eat parameters.
*/
-static inline void virLogEatParams(virLogSource unused, ...)
+static inline void virLogEatParams(virLog unused, ...)
s/virLog /virLogSourcePtr /
Post by Daniel P. Berrange
{
/* Silence gcc */
unused = unused;
Jan
Eric Blake
2014-03-07 17:28:42 UTC
Permalink
Post by Daniel P. Berrange
As part of the goal to get away from doing string matching on
filenames when deciding whether to emit a log message, turn
the virLogSource enum into a struct which contains a log
"name". There will eventually be one virLogSource instance
statically declared per source file. To minimise churn in this
commit though, a single global instance is used.
Thanks for separating the meat from the global switchover.
Post by Daniel P. Berrange
---
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
src/util/viraudit.c | 7 ++++---
src/util/viraudit.h | 10 ++++++----
src/util/virerror.c | 2 +-
src/util/virlog.c | 30 ++++++++++++------------------
src/util/virlog.h | 33 ++++++++++++++++-----------------
src/util/virprobe.h | 4 ++--
tests/testutils.c | 2 +-
10 files changed, 45 insertions(+), 48 deletions(-)
+++ b/src/node_device/node_device_udev.c
@@ -374,7 +374,7 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
format = virBufferContentAndReset(&buf);
- virLogVMessage(VIR_LOG_FROM_LIBRARY,
+ virLogVMessage(&virLogSelf,
So we're basically tossing out the enum of where an error came from, in
favor of a more complex struct that could theoretically once again
include the source information in a later patch.
Post by Daniel P. Berrange
@@ -104,11 +105,11 @@ void virAuditSend(const char *filename,
if (auditlog && str) {
if (success)
- virLogMessage(VIR_LOG_FROM_AUDIT, VIR_LOG_INFO,
+ virLogMessage(source, VIR_LOG_INFO, /* XXX */
What's the XXX for, something that gets fixed later?
Post by Daniel P. Berrange
+++ b/src/util/virerror.c
@@ -715,7 +715,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
* hate & thus disable that too.
*/
if (virLogGetNbOutputs() > 0)
- virLogMessage(virErrorLogPriorityFilter ? VIR_LOG_FROM_FILE : VIR_LOG_FROM_ERROR,
+ virLogMessage(&virLogSelf,
Prior to patch 2/7, virLogVMessage behaved differently for
VIR_LOG_FROM_ERROR than for anything else. 2/7 hoisted a condition here
to virRaiseErrorFull, but changed the distinguishing factor to whether
virErrorLogPriorityFilter is set. Now this patch gets rid of the
distinction altogether (since virLogSelf is global), although it could
theoretically be reinstated once you have per-file sources.

Exactly what was that code used for again, and why are we safe using it?

I'd feel a bit more comfortable acking 2/7 and this patch if you can
explain a bit more in the commit message why we are dropping the
distinction based on error source.
Post by Daniel P. Berrange
@@ -1202,8 +1197,7 @@ virLogOutputToJournald(virLogSource source,
journalAddString(&state, "MESSAGE", rawstr);
journalAddInt(&state, "PRIORITY",
virLogPrioritySyslog(priority));
- journalAddString(&state, "LIBVIRT_SOURCE",
- virLogSourceTypeToString(source));
+ journalAddString(&state, "LIBVIRT_SOURCE", source->name);
Ah - this means that the journal will log per-file information (after
the next patch converts global virLogSelf into per-file), instead of
just the 5 broad categories that virLogSource used to provide.
Post by Daniel P. Berrange
-typedef enum {
- VIR_LOG_FROM_FILE, /* General debugging */
- VIR_LOG_FROM_ERROR, /* Errors reported */
- VIR_LOG_FROM_AUDIT, /* Audit operations */
- VIR_LOG_FROM_TRACE, /* DTrace probe pointers */
- VIR_LOG_FROM_LIBRARY, /* 3rd party libraries */
+typedef struct _virLogSource virLogSource;
+typedef virLogSource *virLogSourcePtr;
+
+struct _virLogSource {
+ const char *name;
+};
So I think this is a fair trade, but still wonder if the commit message
can make it clearer.
Post by Daniel P. Berrange
@@ -68,7 +67,7 @@ typedef enum {
*
* Do nothing but eat parameters.
*/
-static inline void virLogEatParams(virLogSource unused, ...)
+static inline void virLogEatParams(virLog unused, ...)
Jan pointed out the compilation error here.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-10 14:00:54 UTC
Permalink
Post by Eric Blake
Post by Daniel P. Berrange
As part of the goal to get away from doing string matching on
filenames when deciding whether to emit a log message, turn
the virLogSource enum into a struct which contains a log
"name". There will eventually be one virLogSource instance
statically declared per source file. To minimise churn in this
commit though, a single global instance is used.
Thanks for separating the meat from the global switchover.
Post by Daniel P. Berrange
+++ b/src/node_device/node_device_udev.c
@@ -374,7 +374,7 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
format = virBufferContentAndReset(&buf);
- virLogVMessage(VIR_LOG_FROM_LIBRARY,
+ virLogVMessage(&virLogSelf,
So we're basically tossing out the enum of where an error came from, in
favor of a more complex struct that could theoretically once again
include the source information in a later patch.
Yep, exactly.
Post by Eric Blake
Post by Daniel P. Berrange
@@ -104,11 +105,11 @@ void virAuditSend(const char *filename,
if (auditlog && str) {
if (success)
- virLogMessage(VIR_LOG_FROM_AUDIT, VIR_LOG_INFO,
+ virLogMessage(source, VIR_LOG_INFO, /* XXX */
What's the XXX for, something that gets fixed later?
Currently the audit code forwards on the file/source/function which
raised the audit record, but used VIR_LOG_FROM_AUDIT. So with libvirt
logging you can filter based on the filename. eg if you can see all
log messages from QEMU of which audit records are some submit.

Conversely though if you queried with systemd journal you can (now)
filter based on the log source, which means if you've turned on logging
for QEMU, you could further refine it to just audit records.

With this change we're loosing the ability to refine it via systemd
and I'm unsure of the best way to re-enable that, if at all. It was
kind of an accident that this was even possible, but at the same
time it is a nice accident.
Post by Eric Blake
Post by Daniel P. Berrange
+++ b/src/util/virerror.c
@@ -715,7 +715,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
* hate & thus disable that too.
*/
if (virLogGetNbOutputs() > 0)
- virLogMessage(virErrorLogPriorityFilter ? VIR_LOG_FROM_FILE : VIR_LOG_FROM_ERROR,
+ virLogMessage(&virLogSelf,
Prior to patch 2/7, virLogVMessage behaved differently for
VIR_LOG_FROM_ERROR than for anything else. 2/7 hoisted a condition here
to virRaiseErrorFull, but changed the distinguishing factor to whether
virErrorLogPriorityFilter is set. Now this patch gets rid of the
distinction altogether (since virLogSelf is global), although it could
theoretically be reinstated once you have per-file sources.
Exactly what was that code used for again, and why are we safe using it?
I'd feel a bit more comfortable acking 2/7 and this patch if you can
explain a bit more in the commit message why we are dropping the
distinction based on error source.
In current GIT, the virlog.c file has code to skip logging any messages
with VIR_LOG_FROM_ERROR when no log outputs are prsent, since we don't
want to pollute stderr with this.

The virErrorLogPriorityFilter callback allows libvirtd to reduce the
priority of virErrorPtr triggered logs from 'error' to 'debug'. In
such a case, we do still want to include them in the debug log output.

Because of the hack in virlog.c that checks source == VIR_LOG_FROM_ERROR,
we must change the source to VIR_LOG_FROM_FILE in virerror.c to ensure
they are definitely logged.

Now that patch 2 has pushed the check for log source out of virlog.c
and into the virerror.c caller, we no longer need to munge the log
source at all. So this change should actually have been part of
patch 2, rather than this patch.
Post by Eric Blake
Post by Daniel P. Berrange
@@ -1202,8 +1197,7 @@ virLogOutputToJournald(virLogSource source,
journalAddString(&state, "MESSAGE", rawstr);
journalAddInt(&state, "PRIORITY",
virLogPrioritySyslog(priority));
- journalAddString(&state, "LIBVIRT_SOURCE",
- virLogSourceTypeToString(source));
+ journalAddString(&state, "LIBVIRT_SOURCE", source->name);
Ah - this means that the journal will log per-file information (after
the next patch converts global virLogSelf into per-file), instead of
just the 5 broad categories that virLogSource used to provide.
Yes, though this sort of duplicates the filename logging I think it
is slightly better since we have often renamed files, but we are not
likely to rename log sources much. So people querying the journal
will have slightly better long term stability guarantees by using
the log source to match on.

Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Daniel P. Berrange
2014-03-03 19:18:10 UTC
Permalink
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
daemon/libvirtd-config.c | 2 ++
daemon/libvirtd.c | 3 +++
daemon/libvirtd.h | 1 -
daemon/remote.c | 2 ++
daemon/stream.c | 2 ++
docs/apibuild.py | 30 ++++++++++++++++++++++++++++++
src/access/viraccessdriverpolkit.c | 3 +++
src/access/viraccessmanager.c | 3 +++
src/bhyve/bhyve_command.c | 2 ++
src/bhyve/bhyve_driver.c | 2 ++
src/bhyve/bhyve_process.c | 2 ++
src/conf/domain_audit.c | 2 ++
src/conf/domain_conf.c | 2 ++
src/conf/domain_event.c | 1 +
src/conf/network_event.c | 2 ++
src/conf/nwfilter_params.c | 2 ++
src/conf/object_event.c | 2 ++
src/conf/secret_conf.c | 2 ++
src/conf/snapshot_conf.c | 2 ++
src/conf/storage_conf.c | 1 -
src/conf/virchrdev.c | 2 ++
src/cpu/cpu.c | 2 ++
src/cpu/cpu_powerpc.c | 2 ++
src/cpu/cpu_x86.c | 2 ++
src/datatypes.c | 2 ++
src/driver.c | 2 ++
src/esx/esx_device_monitor.c | 1 -
src/esx/esx_driver.c | 2 ++
src/esx/esx_interface_driver.c | 2 --
src/esx/esx_network_driver.c | 2 --
src/esx/esx_nwfilter_driver.c | 2 --
src/esx/esx_secret_driver.c | 2 --
src/esx/esx_storage_backend_iscsi.c | 2 --
src/esx/esx_storage_backend_vmfs.c | 2 ++
src/esx/esx_util.c | 2 +-
src/esx/esx_vi.c | 2 +-
src/esx/esx_vi_methods.c | 1 -
src/esx/esx_vi_types.c | 2 +-
src/fdstream.c | 2 ++
src/hyperv/hyperv_device_monitor.c | 2 --
src/hyperv/hyperv_driver.c | 3 +--
src/hyperv/hyperv_interface_driver.c | 2 --
src/hyperv/hyperv_network_driver.c | 2 --
src/hyperv/hyperv_nwfilter_driver.c | 2 --
src/hyperv/hyperv_secret_driver.c | 2 --
src/hyperv/hyperv_storage_driver.c | 2 --
src/hyperv/hyperv_util.c | 2 +-
src/hyperv/hyperv_wmi.c | 2 --
src/interface/interface_backend_netcf.c | 2 ++
src/libvirt-lxc.c | 2 ++
src/libvirt-qemu.c | 2 ++
src/libvirt.c | 2 ++
src/libvirt_private.syms | 1 -
src/libxl/libxl_conf.c | 2 ++
src/libxl/libxl_domain.c | 1 +
src/libxl/libxl_driver.c | 2 ++
src/locking/domain_lock.c | 2 ++
src/locking/lock_daemon.c | 2 ++
src/locking/lock_daemon_config.c | 2 ++
src/locking/lock_daemon_dispatch.c | 5 ++++-
src/locking/lock_driver_lockd.c | 2 ++
src/locking/lock_driver_nop.c | 2 ++
src/locking/lock_driver_sanlock.c | 2 ++
src/locking/lock_manager.c | 2 ++
src/lxc/lxc_cgroup.c | 2 ++
src/lxc/lxc_conf.c | 2 ++
src/lxc/lxc_container.c | 2 ++
src/lxc/lxc_controller.c | 2 ++
src/lxc/lxc_domain.c | 2 ++
src/lxc/lxc_driver.c | 1 +
src/lxc/lxc_fuse.c | 1 -
src/lxc/lxc_hostdev.c | 2 ++
src/lxc/lxc_monitor.c | 2 ++
src/lxc/lxc_native.c | 1 +
src/lxc/lxc_process.c | 2 ++
src/network/bridge_driver.c | 2 ++
src/network/bridge_driver_linux.c | 3 +++
src/network/bridge_driver_platform.h | 1 -
src/node_device/node_device_driver.c | 2 --
src/node_device/node_device_hal.c | 2 ++
src/node_device/node_device_linux_sysfs.c | 2 ++
src/node_device/node_device_udev.c | 2 ++
src/nodeinfo.c | 1 -
src/nwfilter/nwfilter_dhcpsnoop.c | 2 ++
src/nwfilter/nwfilter_driver.c | 2 ++
src/nwfilter/nwfilter_ebiptables_driver.c | 2 ++
src/nwfilter/nwfilter_gentech_driver.c | 1 +
src/nwfilter/nwfilter_learnipaddr.c | 2 ++
src/openvz/openvz_driver.c | 2 ++
src/parallels/parallels_driver.c | 2 ++
src/phyp/phyp_driver.c | 3 +++
src/qemu/qemu_agent.c | 2 ++
src/qemu/qemu_bridge_filter.c | 1 -
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_cgroup.c | 2 ++
src/qemu/qemu_command.c | 2 ++
src/qemu/qemu_conf.c | 2 ++
src/qemu/qemu_domain.c | 2 ++
src/qemu/qemu_driver.c | 2 ++
src/qemu/qemu_hostdev.c | 2 ++
src/qemu/qemu_hotplug.c | 3 +++
src/qemu/qemu_migration.c | 2 ++
src/qemu/qemu_monitor.c | 2 ++
src/qemu/qemu_monitor_json.c | 2 ++
src/qemu/qemu_monitor_text.c | 2 ++
src/qemu/qemu_process.c | 2 ++
src/remote/remote_driver.c | 2 ++
src/rpc/virkeepalive.c | 2 ++
src/rpc/virnetclient.c | 2 ++
src/rpc/virnetclientprogram.c | 2 ++
src/rpc/virnetclientstream.c | 2 ++
src/rpc/virnetmessage.c | 2 ++
src/rpc/virnetsaslcontext.c | 2 ++
src/rpc/virnetserver.c | 2 ++
src/rpc/virnetserverclient.c | 2 ++
src/rpc/virnetservermdns.c | 2 ++
src/rpc/virnetserverprogram.c | 2 ++
src/rpc/virnetsocket.c | 1 +
src/rpc/virnetsshsession.c | 2 ++
src/rpc/virnettlscontext.c | 2 ++
src/secret/secret_driver.c | 2 ++
src/security/security_apparmor.c | 3 +++
src/security/security_dac.c | 3 +++
src/security/security_driver.c | 2 ++
src/security/security_manager.c | 1 +
src/security/security_selinux.c | 2 ++
src/storage/storage_backend.c | 2 ++
src/storage/storage_backend_disk.c | 2 ++
src/storage/storage_backend_fs.c | 2 ++
src/storage/storage_backend_gluster.c | 2 ++
src/storage/storage_backend_iscsi.c | 2 ++
src/storage/storage_backend_logical.c | 2 ++
src/storage/storage_backend_mpath.c | 2 ++
src/storage/storage_backend_rbd.c | 2 ++
src/storage/storage_backend_scsi.c | 2 ++
src/storage/storage_backend_sheepdog.c | 1 -
src/storage/storage_driver.c | 2 ++
src/test/test_driver.c | 2 ++
src/uml/uml_conf.c | 1 +
src/uml/uml_driver.c | 2 ++
src/util/viralloc.c | 2 ++
src/util/virarch.c | 2 ++
src/util/viraudit.c | 2 ++
src/util/virauth.c | 2 ++
src/util/virauthconfig.c | 1 +
src/util/vircgroup.c | 2 ++
src/util/virclosecallbacks.c | 2 ++
src/util/vircommand.c | 2 ++
src/util/virconf.c | 2 ++
src/util/virdbus.c | 2 ++
src/util/virdnsmasq.c | 3 +++
src/util/virebtables.c | 2 ++
src/util/virerror.c | 2 ++
src/util/virevent.c | 2 ++
src/util/vireventpoll.c | 2 ++
src/util/virfile.c | 2 ++
src/util/virhash.c | 2 ++
src/util/virhook.c | 2 ++
src/util/viridentity.c | 1 +
src/util/viriptables.c | 2 ++
src/util/virjson.c | 1 +
src/util/virkeyfile.c | 2 ++
src/util/virlockspace.c | 2 ++
src/util/virlog.c | 4 ++--
src/util/virlog.h | 10 +++++++++-
src/util/virnetdev.c | 2 ++
src/util/virnetdevmacvlan.c | 1 +
src/util/virnetdevtap.c | 2 ++
src/util/virnetdevveth.c | 2 ++
src/util/virnetdevvportprofile.c | 2 ++
src/util/virnetlink.c | 2 ++
src/util/virnodesuspend.c | 2 ++
src/util/virnuma.c | 2 ++
src/util/virobject.c | 2 ++
src/util/virpci.c | 2 ++
src/util/virpidfile.c | 2 ++
src/util/virprocess.c | 2 ++
src/util/virrandom.c | 2 ++
src/util/virscsi.c | 1 -
src/util/virstoragefile.c | 2 ++
src/util/virstring.c | 2 ++
src/util/virsysinfo.c | 1 -
src/util/virsystemd.c | 1 +
src/util/virusb.c | 2 ++
src/util/virutil.c | 2 ++
src/util/viruuid.c | 2 ++
src/vbox/vbox_MSCOMGlue.c | 2 ++
src/vbox/vbox_XPCOMCGlue.c | 1 +
src/vbox/vbox_driver.c | 1 +
src/vbox/vbox_tmpl.c | 3 +++
src/vmx/vmx.c | 2 ++
src/xen/xen_driver.c | 3 +++
src/xen/xen_hypervisor.c | 2 ++
src/xen/xen_inotify.c | 2 ++
src/xen/xend_internal.c | 2 ++
src/xen/xm_internal.c | 2 ++
src/xen/xs_internal.c | 2 ++
src/xenapi/xenapi_utils.c | 2 ++
src/xenxs/xen_sxpr.c | 2 ++
tests/domainconftest.c | 2 ++
tests/eventtest.c | 2 ++
tests/fdstreamtest.c | 2 ++
tests/libvirtdconftest.c | 2 ++
tests/qemumonitortestutils.c | 2 ++
tests/securityselinuxlabeltest.c | 2 ++
tests/securityselinuxtest.c | 2 ++
tests/sockettest.c | 2 ++
tests/testutils.c | 2 ++
tests/virauthconfigtest.c | 2 ++
tests/vircgrouptest.c | 2 ++
tests/virdbustest.c | 2 ++
tests/virdrivermoduletest.c | 2 ++
tests/virhashtest.c | 2 ++
tests/viridentitytest.c | 1 +
tests/virkeycodetest.c | 1 +
tests/virkeyfiletest.c | 1 +
tests/virlockspacetest.c | 2 ++
tests/virnetmessagetest.c | 2 ++
tests/virnetsockettest.c | 2 ++
tests/virnettlscontexttest.c | 2 ++
tests/virnettlshelpers.c | 2 ++
tests/virnettlssessiontest.c | 2 ++
tests/virportallocatortest.c | 1 +
tests/virstoragetest.c | 2 ++
tests/virstringtest.c | 2 ++
tests/virsystemdtest.c | 2 ++
tests/virtimetest.c | 2 ++
tests/viruritest.c | 2 ++
tools/virsh-console.c | 2 ++
229 files changed, 432 insertions(+), 48 deletions(-)

diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index c816fda..c68c6f4 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_CONF

+VIR_LOG_INIT("daemon.libvirtd-config");
+
/* Allocate an array of malloc'd strings from the config file, filename
* (used only in diagnostics), using handle "conf". Upon error, return -1
* and free any allocated memory. Otherwise, save the array in *list_arg
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b27c6fd..f2f1a83 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -35,6 +35,7 @@
#include "libvirt_internal.h"
#include "virerror.h"
#include "virfile.h"
+#include "virlog.h"
#include "virpidfile.h"
#include "virprocess.h"

@@ -104,6 +105,8 @@

#include "virdbus.h"

+VIR_LOG_INIT("daemon.libvirtd");
+
#if WITH_SASL
virNetSASLContextPtr saslCtxt = NULL;
#endif
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index c4f1f27..650267e 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -32,7 +32,6 @@
# include "remote_protocol.h"
# include "lxc_protocol.h"
# include "qemu_protocol.h"
-# include "virlog.h"
# include "virthread.h"
# if WITH_SASL
# include "virnetsaslcontext.h"
diff --git a/daemon/remote.c b/daemon/remote.c
index 3db5df3..7fd4e23 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -57,6 +57,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("daemon.remote");
+
#if SIZEOF_LONG < 8
# define HYPER_TO_TYPE(_type, _to, _from) \
do { \
diff --git a/daemon/stream.c b/daemon/stream.c
index 9e36e8a..16cdf03 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_STREAMS

+VIR_LOG_INIT("daemon.stream");
+
struct daemonClientStream {
daemonClientPrivatePtr priv;
int refs;
diff --git a/docs/apibuild.py b/docs/apibuild.py
index ab6b0b4..71494d5 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -1446,6 +1446,24 @@ class CParser:

return token

+ def parseVirLogInit(self, token):
+ if token[0] != "string":
+ self.error("parsing VIR_LOG_INIT: expecting string", token)
+
+ token = self.token()
+
+ if token[0] != "sep":
+ self.error("parsing VIR_LOG_INIT: expecting ')'", token)
+
+ if token[1] != ')':
+ self.error("parsing VIR_LOG_INIT: expecting ')'", token)
+
+ token = self.token()
+ if token[0] == "sep" and token[1] == ';':
+ token = self.token()
+
+ return token
+
#
# Parse a C definition block, used for structs or unions it parse till
# the balancing }
@@ -1617,6 +1635,18 @@ class CParser:
token = ("name", "virenumimpl")
return token

+ elif token[0] == "name" and token[1] == "VIR_LOG_INIT":
+ token = self.token()
+ if token is not None and token[0] == "sep" and token[1] == "(":
+ token = self.token()
+ token = self.parseVirLogInit(token)
+ else:
+ self.error("parsing VIR_LOG_INIT: expecting '('", token)
+ if token is not None:
+ self.lexer.push(token)
+ token = ("name", "virloginit")
+ return token
+
elif token[0] == "name":
if self.type == "":
self.type = token[1]
diff --git a/src/access/viraccessdriverpolkit.c b/src/access/viraccessdriverpolkit.c
index c325739..909994a 100644
--- a/src/access/viraccessdriverpolkit.c
+++ b/src/access/viraccessdriverpolkit.c
@@ -29,6 +29,9 @@
#include "virstring.h"

#define VIR_FROM_THIS VIR_FROM_ACCESS
+
+VIR_LOG_INIT("access.accessdriverpolkit");
+
#define virAccessError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c
index 16e3853..c042ccf 100644
--- a/src/access/viraccessmanager.c
+++ b/src/access/viraccessmanager.c
@@ -33,6 +33,9 @@
#include "virlog.h"

#define VIR_FROM_THIS VIR_FROM_ACCESS
+
+VIR_LOG_INIT("access.accessmanager");
+
#define virAccessError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 1fcc0f2..c4d67c1 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -39,6 +39,8 @@

#define VIR_FROM_THIS VIR_FROM_BHYVE

+VIR_LOG_INIT("bhyve.bhyve_command");
+
static char*
virBhyveTapGetRealDeviceName(char *name)
{
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9dbb299..bf5ade3 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -56,6 +56,8 @@

#define VIR_FROM_THIS VIR_FROM_BHYVE

+VIR_LOG_INIT("bhyve.bhyve_driver");
+
bhyveConnPtr bhyve_driver = NULL;

void
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 7717fec..990ac82 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -44,6 +44,8 @@

#define VIR_FROM_THIS VIR_FROM_BHYVE

+VIR_LOG_INIT("bhyve.bhyve_process");
+
int
virBhyveProcessStart(virConnectPtr conn,
bhyveConnPtr driver,
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index b6564c2..69632b0 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -33,6 +33,8 @@
#include "viralloc.h"
#include "virstring.h"

+VIR_LOG_INIT("conf.domain_audit");
+
/* Return nn:mm in hex for block and character devices, and NULL
* for other file types, stat failure, or allocation failure. */
#if defined major && defined minor
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1d5cc14..136fb13 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -56,6 +56,8 @@

#define VIR_FROM_THIS VIR_FROM_DOMAIN

+VIR_LOG_INIT("conf.domain_conf");
+
/* virDomainVirtType is used to set bits in the expectedVirtTypes bitmask,
* verify that it doesn't overflow an unsigned int when shifting */
verify(VIR_DOMAIN_VIRT_LAST <= 32);
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 9c18922..ee49e82 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -35,6 +35,7 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.domain_event");

static virClassPtr virDomainEventClass;
static virClassPtr virDomainEventLifecycleClass;
diff --git a/src/conf/network_event.c b/src/conf/network_event.c
index f2cfefe..298cfcb 100644
--- a/src/conf/network_event.c
+++ b/src/conf/network_event.c
@@ -29,6 +29,8 @@
#include "datatypes.h"
#include "virlog.h"

+VIR_LOG_INIT("conf.network_event");
+
struct _virNetworkEvent {
virObjectEvent parent;

diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 589fcf8..922da6b 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -35,6 +35,8 @@

#define VIR_FROM_THIS VIR_FROM_NWFILTER

+VIR_LOG_INIT("conf.nwfilter_params");
+
static bool isValidVarValue(const char *value);
static void virNWFilterVarAccessSetIntIterId(virNWFilterVarAccessPtr,
unsigned int);
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index de45257..ff51c5e 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("conf.object_event");
+
struct _virObjectEventCallbackList {
unsigned int nextID;
size_t count;
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index c3252d1..0f4ea97 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_SECRET

+VIR_LOG_INIT("conf.secret_conf");
+
VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_LAST,
"none", "volume", "ceph", "iscsi")

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 12b0930..b1f01f1 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -50,6 +50,8 @@

#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT

+VIR_LOG_INIT("conf.snapshot_conf");
+
VIR_ENUM_IMPL(virDomainSnapshotLocation, VIR_DOMAIN_SNAPSHOT_LOCATION_LAST,
"default",
"no",
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index e4232e9..13f218a 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -44,7 +44,6 @@
#include "viralloc.h"
#include "virfile.h"
#include "virstring.h"
-#include "virlog.h"

#define VIR_FROM_THIS VIR_FROM_STORAGE

diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index 3e6beaa..d23254b 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -41,6 +41,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("conf.chrdev");
+
/* structure holding information about character devices
* open in a given domain */
struct _virChrdevs {
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 677bb08..1994383 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -40,6 +40,8 @@
#define NR_DRIVERS ARRAY_CARDINALITY(drivers)
#define VIR_FROM_THIS VIR_FROM_CPU

+VIR_LOG_INIT("cpu.cpu");
+
static struct cpuArchDriver *drivers[] = {
&cpuDriverX86,
&cpuDriverPowerPC,
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index 77ffa52..36f4f25 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_CPU

+VIR_LOG_INIT("cpu.cpu_powerpc");
+
static const virArch archs[] = { VIR_ARCH_PPC64 };

struct ppc_vendor {
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 56080ef..423bcc1 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_CPU

+VIR_LOG_INIT("cpu.cpu_x86");
+
#define VENDOR_STRING_LENGTH 12

static const virCPUx86CPUID cpuidNull = { 0, 0, 0, 0, 0 };
diff --git a/src/datatypes.c b/src/datatypes.c
index 73f17e7..675c7a8 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -31,6 +31,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("datatypes");
+
virClassPtr virConnectClass;
virClassPtr virConnectCloseCallbackDataClass;
virClassPtr virDomainClass;
diff --git a/src/driver.c b/src/driver.c
index ab2a253..91ed250 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -31,6 +31,8 @@
#include "configmake.h"
#include "virstring.h"

+VIR_LOG_INIT("driver");
+
#define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"

#ifdef WITH_DRIVER_MODULES
diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index 7dc0618..c0d5047 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -26,7 +26,6 @@

#include "internal.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "esx_private.h"
#include "esx_device_monitor.h"
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 886d984..e205ace 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -50,6 +50,8 @@

#define VIR_FROM_THIS VIR_FROM_ESX

+VIR_LOG_INIT("esx.esx_driver");
+
static int esxDomainGetMaxVcpus(virDomainPtr domain);

typedef struct _esxVMX_Data esxVMX_Data;
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index dcb9f03..656ac8b 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -1,4 +1,3 @@
-
/*
* esx_interface_driver.c: interface driver functions for managing VMware ESX
* host interfaces
@@ -26,7 +25,6 @@

#include "internal.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "interface_conf.h"
#include "virsocketaddr.h"
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index c8b53b1..877a3c1 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -1,4 +1,3 @@
-
/*
* esx_network_driver.c: network driver functions for managing VMware ESX
* host networks
@@ -27,7 +26,6 @@
#include "md5.h"
#include "internal.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "network_conf.h"
#include "esx_private.h"
diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c
index 3b932de..3cf70d0 100644
--- a/src/esx/esx_nwfilter_driver.c
+++ b/src/esx/esx_nwfilter_driver.c
@@ -1,4 +1,3 @@
-
/*
* esx_nwfilter_driver.c: nwfilter driver functions for managing VMware ESX
* firewall rules
@@ -26,7 +25,6 @@

#include "internal.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "esx_private.h"
#include "esx_nwfilter_driver.h"
diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c
index 5607a2e..558cf07 100644
--- a/src/esx/esx_secret_driver.c
+++ b/src/esx/esx_secret_driver.c
@@ -1,4 +1,3 @@
-
/*
* esx_secret_driver.c: secret driver functions for VMware ESX secret manipulation
*
@@ -25,7 +24,6 @@

#include "internal.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "esx_private.h"
#include "esx_secret_driver.h"
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 66b91d1..e8f88ba 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -1,4 +1,3 @@
-
/*
* esx_storage_backend_iscsi.c: ESX storage backend for iSCSI handling
*
@@ -29,7 +28,6 @@
#include "internal.h"
#include "md5.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "storage_conf.h"
#include "virstoragefile.h"
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index f4a5d50..c199159 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -46,6 +46,8 @@

#define VIR_FROM_THIS VIR_FROM_ESX

+VIR_LOG_INIT("esx.esx_storage_backend_vmfs");
+
/*
* The UUID of a storage pool is the MD5 sum of it's mount path. Therefore,
* verify that UUID and MD5 sum match in size, because we rely on that.
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 39b7c0e..2a65130 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -38,7 +38,7 @@

#define VIR_FROM_THIS VIR_FROM_ESX

-
+VIR_LOG_INIT("esx.esx_util");

int
esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 777ce30..0bd073b 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -39,7 +39,7 @@

#define VIR_FROM_THIS VIR_FROM_ESX

-
+VIR_LOG_INIT("esx.esx_vi");

#define ESX_VI__SOAP__RESPONSE_XPATH(_type) \
((char *)"/soapenv:Envelope/soapenv:Body/" \
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 519daf6..bb2aa01 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -25,7 +25,6 @@

#include "virbuffer.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 2d6f8db..a385115 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -37,7 +37,7 @@

#define VIR_FROM_THIS VIR_FROM_ESX

-
+VIR_LOG_INIT("esx.esx_vi_types");

#define ESX_VI__TEMPLATE__ALLOC(__type) \
int \
diff --git a/src/fdstream.c b/src/fdstream.c
index f7dae39..d4ad004 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -44,6 +44,8 @@

#define VIR_FROM_THIS VIR_FROM_STREAMS

+VIR_LOG_INIT("fdstream");
+
/* Tunnelled migration stream support */
struct virFDStreamData {
int fd;
diff --git a/src/hyperv/hyperv_device_monitor.c b/src/hyperv/hyperv_device_monitor.c
index 83ea72a..5332eb2 100644
--- a/src/hyperv/hyperv_device_monitor.c
+++ b/src/hyperv/hyperv_device_monitor.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_device_monitor.c: device monitor functions for managing
* Microsoft Hyper-V host devices
@@ -27,7 +26,6 @@
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "hyperv_device_monitor.h"

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 6680e66..7a80885 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_driver.c: core driver functions for managing Microsoft Hyper-V hosts
*
@@ -45,7 +44,7 @@

#define VIR_FROM_THIS VIR_FROM_HYPERV

-
+VIR_LOG_INIT("hyperv.hyperv_driver");

static void
hypervFreePrivate(hypervPrivate **priv)
diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c
index 62123a4..b93cf30 100644
--- a/src/hyperv/hyperv_interface_driver.c
+++ b/src/hyperv/hyperv_interface_driver.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_interface_driver.c: interface driver functions for managing
* Microsoft Hyper-V host interfaces
@@ -27,7 +26,6 @@
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "hyperv_interface_driver.h"

diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c
index e23f53a..6f54f44 100644
--- a/src/hyperv/hyperv_network_driver.c
+++ b/src/hyperv/hyperv_network_driver.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_network_driver.c: network driver functions for managing
* Microsoft Hyper-V host networks
@@ -27,7 +26,6 @@
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "hyperv_network_driver.h"

diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c
index 0343238..a82db92 100644
--- a/src/hyperv/hyperv_nwfilter_driver.c
+++ b/src/hyperv/hyperv_nwfilter_driver.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_nwfilter_driver.c: nwfilter driver functions for managing
* Microsoft Hyper-V firewall rules
@@ -27,7 +26,6 @@
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "hyperv_nwfilter_driver.h"

diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c
index 3f9f8f5..8176484 100644
--- a/src/hyperv/hyperv_secret_driver.c
+++ b/src/hyperv/hyperv_secret_driver.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_secret_driver.c: secret driver functions for Microsoft Hyper-V
* secret manipulation
@@ -27,7 +26,6 @@
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "hyperv_secret_driver.h"

diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c
index 5acc4d8..af3cca4 100644
--- a/src/hyperv/hyperv_storage_driver.c
+++ b/src/hyperv/hyperv_storage_driver.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_storage_driver.c: storage driver functions for managing
* Microsoft Hyper-V host storage
@@ -27,7 +26,6 @@
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-#include "virlog.h"
#include "viruuid.h"
#include "hyperv_storage_driver.h"

diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c
index e14c634..002aabb 100644
--- a/src/hyperv/hyperv_util.c
+++ b/src/hyperv/hyperv_util.c
@@ -33,7 +33,7 @@

#define VIR_FROM_THIS VIR_FROM_HYPERV

-
+VIR_LOG_INIT("hyperv.hyperv_util");

int
hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 39eed0c..09139f3 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -1,4 +1,3 @@
-
/*
* hyperv_wmi.h: general WMI over WSMAN related functions and structures for
* managing Microsoft Hyper-V hosts
@@ -27,7 +26,6 @@
#include "internal.h"
#include "virerror.h"
#include "datatypes.h"
-#include "virlog.h"
#include "viralloc.h"
#include "viruuid.h"
#include "virbuffer.h"
diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index c525ca9..910592b 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_INTERFACE

+VIR_LOG_INIT("interface.interface_backend_netcf");
+
#define INTERFACE_DRIVER_NAME "netcf"

/* Main driver state */
diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c
index 074809a..bc3f402 100644
--- a/src/libvirt-lxc.c
+++ b/src/libvirt-lxc.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("libvirt-lxc");
+
/**
* virDomainLxcOpenNamespace:
* @domain: a domain object
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
index 617ad05..2f66e2d 100644
--- a/src/libvirt-qemu.c
+++ b/src/libvirt-qemu.c
@@ -30,6 +30,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("libvirt-qemu");
+
/**
* virDomainQemuMonitorCommand:
* @domain: a domain object
diff --git a/src/libvirt.c b/src/libvirt.c
index dcf6b53..0ef0bb5 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -102,6 +102,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("libvirt");
+
/*
* TODO:
* - use lock to protect against concurrent accesses ?
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 4bd3ec3..3d8f2e3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1437,7 +1437,6 @@ virLogParseOutputs;
virLogPriorityFromSyslog;
virLogProbablyLogMessage;
virLogReset;
-virLogSelf;
virLogSetBufferSize;
virLogSetDefaultPriority;
virLogSetFromEnv;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index ade0a08..8e478d2 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -48,6 +48,8 @@

#define VIR_FROM_THIS VIR_FROM_LIBXL

+VIR_LOG_INIT("libxl.libxl_conf");
+
/* see xen-unstable.hg/xen/include/asm-x86/cpufeature.h */
#define LIBXL_X86_FEATURE_PAE_MASK 0x40

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index fdc4661..4544d91 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -34,6 +34,7 @@

#define VIR_FROM_THIS VIR_FROM_LIBXL

+VIR_LOG_INIT("libxl.libxl_domain");

VIR_ENUM_IMPL(libxlDomainJob, LIBXL_JOB_LAST,
"none",
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a79efcb..aa840dc 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -55,6 +55,8 @@

#define VIR_FROM_THIS VIR_FROM_LIBXL

+VIR_LOG_INIT("libxl.libxl_driver");
+
#define LIBXL_DOM_REQ_POWEROFF 0
#define LIBXL_DOM_REQ_REBOOT 1
#define LIBXL_DOM_REQ_SUSPEND 2
diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index 5e02400..643a875 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -29,6 +29,8 @@

#define VIR_FROM_THIS VIR_FROM_LOCKING

+VIR_LOG_INIT("locking.domain_lock");
+

static int virDomainLockManagerAddLease(virLockManagerPtr lock,
virDomainLeaseDefPtr lease)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index e047751..46b2dd3 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_LOCKING

+VIR_LOG_INIT("locking.lock_daemon");
+
#define VIR_LOCK_DAEMON_NUM_LOCKSPACES 3

struct _virLockDaemon {
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index 8e632f5..c7d9d97 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -35,6 +35,8 @@

#define VIR_FROM_THIS VIR_FROM_CONF

+VIR_LOG_INIT("locking.lock_daemon_confijg");
+

/* A helper function used by each of the following macros. */
static int
diff --git a/src/locking/lock_daemon_dispatch.c b/src/locking/lock_daemon_dispatch.c
index c2e1000..a26e2cc 100644
--- a/src/locking/lock_daemon_dispatch.c
+++ b/src/locking/lock_daemon_dispatch.c
@@ -28,11 +28,14 @@
#include "virstring.h"
#include "lock_daemon.h"
#include "lock_protocol.h"
-#include "lock_daemon_dispatch_stubs.h"
#include "virerror.h"

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("locking.lock_daemon_dispatch");
+
+#include "lock_daemon_dispatch_stubs.h"
+
static int
virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client,
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index f3b9467..1f99275 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_LOCKING

+VIR_LOG_INIT("locking.lock_driver_lockd");
+
#define virLockError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/locking/lock_driver_nop.c b/src/locking/lock_driver_nop.c
index e8e9917..93a988e 100644
--- a/src/locking/lock_driver_nop.c
+++ b/src/locking/lock_driver_nop.c
@@ -26,6 +26,8 @@
#include "virlog.h"
#include "viruuid.h"

+VIR_LOG_INIT("locking.lock_driver_nop");
+

static int virLockManagerNopInit(unsigned int version ATTRIBUTE_UNUSED,
const char *configFile ATTRIBUTE_UNUSED,
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index f11f3c6..dba855f 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -49,6 +49,8 @@

#define VIR_FROM_THIS VIR_FROM_LOCKING

+VIR_LOG_INIT("locking.lock_driver_sanlock");
+
#define VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE "__LIBVIRT__DISKS__"
#define VIR_LOCK_MANAGER_SANLOCK_KILLPATH LIBEXECDIR "/libvirt_sanlock_helper"

diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index f09c168..54552b8 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -39,6 +39,8 @@

#define VIR_FROM_THIS VIR_FROM_LOCKING

+VIR_LOG_INIT("locking.lock_manager");
+
#define CHECK_DRIVER(field, errret) \
if (!driver->field) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 39d955c..5a1718d 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_cgroup");
+
static int virLXCCgroupSetupCpuTune(virDomainDefPtr def,
virCgroupPtr cgroup)
{
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 557191a..d4432cf 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -41,6 +41,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_conf");
+
static virClassPtr virLXCDriverConfigClass;
static void virLXCDriverConfigDispose(void *obj);

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 7154804..4dec145 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -71,6 +71,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_container");
+
/*
* GLibc headers are behind the kernel, so we define these
* constants if they're not present already.
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 5ca960f..bc83db1 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -70,6 +70,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_controller");
+
typedef struct _virLXCControllerConsole virLXCControllerConsole;
typedef virLXCControllerConsole *virLXCControllerConsolePtr;
struct _virLXCControllerConsole {
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 83c5a4e..74b7df6 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -29,6 +29,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_domain");
+
static void *virLXCDomainObjPrivateAlloc(void)
{
virLXCDomainObjPrivatePtr priv;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 10e0fbb..902cdbf 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -74,6 +74,7 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_driver");

#define LXC_NB_MEM_PARAM 3
#define LXC_NB_DOMAIN_BLOCK_STAT_PARAM 4
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index d3d8f85..81706c8 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -32,7 +32,6 @@
#include "lxc_fuse.h"
#include "lxc_cgroup.h"
#include "virerror.h"
-#include "virlog.h"
#include "virfile.h"
#include "virbuffer.h"
#include "virstring.h"
diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c
index 3b371fc..3f102d3 100644
--- a/src/lxc/lxc_hostdev.c
+++ b/src/lxc/lxc_hostdev.c
@@ -30,6 +30,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_hostdev");
+
int
virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver,
virDomainDefPtr def)
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 07e9301..e9447ce 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_monitor");
+
struct _virLXCMonitor {
virObjectLockable parent;

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 663e29c..fa0e62e 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -34,6 +34,7 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_native");

static virDomainFSDefPtr
lxcCreateFSDef(int type,
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 1ebad9c..f3e7c03 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_LXC

+VIR_LOG_INIT("lxc.lxc_process");
+
#define START_POSTFIX ": starting up\n"

static virDomainObjPtr
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c797f8f..a1af7d9 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -75,6 +75,8 @@

#define VIR_FROM_THIS VIR_FROM_NETWORK

+VIR_LOG_INIT("network.bridge_driver");
+
static void networkDriverLock(virNetworkDriverStatePtr driver)
{
virMutexLock(&driver->lock);
diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
index a2f0248..9305bca 100644
--- a/src/network/bridge_driver_linux.c
+++ b/src/network/bridge_driver_linux.c
@@ -27,9 +27,12 @@
#include "virfile.h"
#include "viriptables.h"
#include "virstring.h"
+#include "virlog.h"

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("network.bridge_driver_linux");
+
#define PROC_NET_ROUTE "/proc/net/route"

/* XXX: This function can be a lot more exhaustive, there are certainly
diff --git a/src/network/bridge_driver_platform.h b/src/network/bridge_driver_platform.h
index 82d96f6..b44d8b6 100644
--- a/src/network/bridge_driver_platform.h
+++ b/src/network/bridge_driver_platform.h
@@ -25,7 +25,6 @@
# define __VIR_BRIDGE_DRIVER_PLATFORM_H__

# include "internal.h"
-# include "virlog.h"
# include "virthread.h"
# include "virdnsmasq.h"
# include "network_conf.h"
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index d5a92cd..4fe97a8 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -33,7 +33,6 @@
#include "datatypes.h"
#include "viralloc.h"
#include "virfile.h"
-#include "virlog.h"
#include "virstring.h"
#include "node_device_conf.h"
#include "node_device_hal.h"
@@ -43,7 +42,6 @@

#define VIR_FROM_THIS VIR_FROM_NODEDEV

-
static int update_caps(virNodeDeviceObjPtr dev)
{
virNodeDevCapsDefPtr cap = dev->def->caps;
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index fafd520..1ca315b 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -43,6 +43,8 @@

#define VIR_FROM_THIS VIR_FROM_NODEDEV

+VIR_LOG_INIT("node_device.node_device_hal");
+
/*
* Host device enumeration (HAL implementation)
*/
diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c
index d68c3bd..9233be5 100644
--- a/src/node_device/node_device_linux_sysfs.c
+++ b/src/node_device/node_device_linux_sysfs.c
@@ -38,6 +38,8 @@

#ifdef __linux__

+VIR_LOG_INIT("node_device.node_device_linux_sysfs");
+
int
detect_scsi_host_caps(union _virNodeDevCapData *d)
{
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 5c48fe8..ddd54e0 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -43,6 +43,8 @@

#define VIR_FROM_THIS VIR_FROM_NODEDEV

+VIR_LOG_INIT("node_device.node_device_udev");
+
#ifndef TYPE_RAID
# define TYPE_RAID 12
#endif
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 916cb47..6d33f64 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -44,7 +44,6 @@
#include "viralloc.h"
#include "nodeinfopriv.h"
#include "physmem.h"
-#include "virlog.h"
#include "virerror.h"
#include "count-one-bits.h"
#include "intprops.h"
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index a96a790..029a1de 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -72,6 +72,8 @@

#define VIR_FROM_THIS VIR_FROM_NWFILTER

+VIR_LOG_INIT("nwfilter.nwfilter_dhcpsnoop");
+
#ifdef HAVE_LIBPCAP

# define LEASEFILE_DIR LOCALSTATEDIR "/run/libvirt/network/"
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 5908df7..e33814d 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -50,6 +50,8 @@

#define VIR_FROM_THIS VIR_FROM_NWFILTER

+VIR_LOG_INIT("nwfilter.nwfilter_driver");
+
#define DBUS_RULE_FWD_NAMEOWNERCHANGED \
"type='signal'" \
",interface='"DBUS_INTERFACE_DBUS"'" \
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index dc651a2..427e4b4 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -48,6 +48,8 @@

#define VIR_FROM_THIS VIR_FROM_NWFILTER

+VIR_LOG_INIT("nwfilter.nwfilter_ebiptables_driver");
+
#define EBTABLES_CHAIN_INCOMING "PREROUTING"
#define EBTABLES_CHAIN_OUTGOING "POSTROUTING"

diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 8c5cd57..75b98ae 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -41,6 +41,7 @@

#define VIR_FROM_THIS VIR_FROM_NWFILTER

+VIR_LOG_INIT("nwfilter.nwfilter_gentech_driver");

#define NWFILTER_STD_VAR_MAC NWFILTER_VARNAME_MAC
#define NWFILTER_STD_VAR_IP NWFILTER_VARNAME_IP
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index e071ff4..e156a93 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -58,6 +58,8 @@

#define VIR_FROM_THIS VIR_FROM_NWFILTER

+VIR_LOG_INIT("nwfilter.nwfilter_learnipaddr");
+
#define IFINDEX2STR(VARNAME, ifindex) \
char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \
snprintf(VARNAME, sizeof(VARNAME), "%d", ifindex);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index b27ac4c..623c458 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -61,6 +61,8 @@

#define VIR_FROM_THIS VIR_FROM_OPENVZ

+VIR_LOG_INIT("openvz.openvz_driver");
+
#define OPENVZ_MAX_ARG 28
#define CMDBUF_LEN 1488
#define CMDOP_LEN 288
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 33260ef..dc4b5a9 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -56,6 +56,8 @@

#define VIR_FROM_THIS VIR_FROM_PARALLELS

+VIR_LOG_INIT("parallels.parallels_driver");
+
#define PRLCTL "prlctl"
#define PRLSRVCTL "prlsrvctl"

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 9adb6b0..03fac49 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -61,6 +61,9 @@

#define VIR_FROM_THIS VIR_FROM_PHYP

+VIR_LOG_INIT("phyp.phyp_driver");
+
+
/*
* URI: phyp://user@[hmc|ivm]/managed_system
* */
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 4a3820c..018566b 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -45,6 +45,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_agent");
+
#define LINE_ENDING "\n"

#define DEBUG_IO 0
diff --git a/src/qemu/qemu_bridge_filter.c b/src/qemu/qemu_bridge_filter.c
index 49954c6..e8c6d9a 100644
--- a/src/qemu/qemu_bridge_filter.c
+++ b/src/qemu/qemu_bridge_filter.c
@@ -26,7 +26,6 @@
#include "qemu_conf.h"
#include "qemu_driver.h"
#include "virerror.h"
-#include "virlog.h"

#include "qemu_bridge_filter.h"

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 70b5f15..73ecfa8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -47,6 +47,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_capabilities");
+
/* While not public, these strings must not change. They
* are used in domain status files which are read on
* daemon restarts
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index a97f184..da8cdbf 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_cgroup");
+
static const char *const defaultDeviceACL[] = {
"/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/urandom",
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9ee84a0..6e639d4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -60,6 +60,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_command");
+
#define VIO_ADDR_NET 0x1000ul
#define VIO_ADDR_SCSI 0x2000ul
#define VIO_ADDR_SERIAL 0x30000000ul
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2c397b0..89bac97 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -57,6 +57,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_conf");
+
static virClassPtr virQEMUDriverConfigClass;
static void virQEMUDriverConfigDispose(void *obj);

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bad63c5..80be1a0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -46,6 +46,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_domain");
+
#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0"

VIR_ENUM_IMPL(qemuDomainJob, QEMU_JOB_LAST,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e04a328..adb3724 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -98,6 +98,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_driver");
+
#define QEMU_DRIVER_NAME "QEMU"

#define QEMU_NB_MEM_PARAM 3
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 1b16386..635fb08 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -40,6 +40,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_hostdev");
+
static virPCIDeviceListPtr
qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
{
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 6703c92..52620fd 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -52,6 +52,9 @@
#include "virtime.h"

#define VIR_FROM_THIS VIR_FROM_QEMU
+
+VIR_LOG_INIT("qemu.qemu_hotplug");
+
#define CHANGE_MEDIA_RETRIES 10

/* Wait up to 5 seconds for device removal to finish. */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 54c6fec..5468db0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -60,6 +60,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_migration");
+
VIR_ENUM_IMPL(qemuMigrationJobPhase, QEMU_MIGRATION_PHASE_LAST,
"none",
"perform2",
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 8f8f5c3..72bacc3 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -49,6 +49,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_monitor");
+
#define DEBUG_IO 0
#define DEBUG_RAW_IO 0

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0b39bf7..751a138 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -51,6 +51,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_monitor_json");
+
#define QOM_CPU_PATH "/machine/unattached/device[0]"

#define LINE_ENDING "\r\n"
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 6e520bd..ff32f14 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -49,6 +49,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_monitor_text");
+
#define QEMU_CMD_PROMPT "\n(qemu) "
#define QEMU_PASSWD_PROMPT "Password: "

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ffa939a..92f4ce4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -69,6 +69,8 @@

#define VIR_FROM_THIS VIR_FROM_QEMU

+VIR_LOG_INIT("qemu.qemu_process");
+
#define START_POSTFIX ": starting up\n"
#define ATTACH_POSTFIX ": attaching\n"
#define SHUTDOWN_POSTFIX ": shutting down\n"
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 955465a..92c649b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -52,6 +52,8 @@

#define VIR_FROM_THIS VIR_FROM_REMOTE

+VIR_LOG_INIT("remote.remote_driver");
+
#if SIZEOF_LONG < 8
# define HYPER_TO_TYPE(_type, _to, _from) \
do { \
diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index fcc43ad..f5c48b7 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.keepalive");
+
struct _virKeepAlive {
virObjectLockable parent;

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index fe3e055..67b3d83 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -41,6 +41,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netclient");
+
typedef struct _virNetClientCall virNetClientCall;
typedef virNetClientCall *virNetClientCallPtr;

diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c
index cbd628a..3ff27d3 100644
--- a/src/rpc/virnetclientprogram.c
+++ b/src/rpc/virnetclientprogram.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netclientprogram");
+
struct _virNetClientProgram {
virObject object;

diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index b785392..521bdda 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -31,6 +31,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netclientstream");
+
struct _virNetClientStream {
virObjectLockable parent;

diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index af07404..4e8e17d 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -33,6 +33,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netmessage");
+
virNetMessagePtr virNetMessageNew(bool tracked)
{
virNetMessagePtr msg;
diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c
index dbb9a25..abf3334 100644
--- a/src/rpc/virnetsaslcontext.c
+++ b/src/rpc/virnetsaslcontext.c
@@ -33,6 +33,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netsaslcontext");
+
struct _virNetSASLContext {
virObjectLockable parent;

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index f70e260..3a0e715 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -46,6 +46,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netserver");
+
typedef struct _virNetServerSignal virNetServerSignal;
typedef virNetServerSignal *virNetServerSignalPtr;

diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 7b6d82d..495b0b3 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -41,6 +41,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netserverclient");
+
/* Allow for filtering of incoming messages to a custom
* dispatch processing queue, instead of the workers.
* This allows for certain types of messages to be handled
diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c
index 85ae100..1319680 100644
--- a/src/rpc/virnetservermdns.c
+++ b/src/rpc/virnetservermdns.c
@@ -49,6 +49,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netservermdns");
+
struct _virNetServerMDNSEntry {
char *type;
int port;
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 93a3fb1..8aea9f0 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netserverprogram");
+
struct _virNetServerProgram {
virObject object;

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index be1df6c..16a2521 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -62,6 +62,7 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.netsocket");

struct _virNetSocket {
virObjectLockable parent;
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index f544d69..789ba2e 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -40,6 +40,8 @@

#define VIR_FROM_THIS VIR_FROM_SSH

+VIR_LOG_INIT("rpc.netsshsession");
+
static const char
vir_libssh2_key_comment[] = "added by libvirt ssh transport";
#define VIR_NET_SSH_BUFFER_SIZE 1024
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 27a00d0..7bf2a2e 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -55,6 +55,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("rpc.nettlscontext");
+
struct _virNetTLSContext {
virObjectLockable parent;

diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 9f7f946..45aeb5e 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -46,6 +46,8 @@

#define VIR_FROM_THIS VIR_FROM_SECRET

+VIR_LOG_INIT("secret.secret_driver");
+
enum { SECRET_MAX_XML_FILE = 10*1024*1024 };

/* Internal driver state */
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 257e3dd..8249fb4 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -52,6 +52,9 @@
#include "virscsi.h"

#define VIR_FROM_THIS VIR_FROM_SECURITY
+
+VIR_LOG_INIT("security.security_apparmor");
+
#define SECURITY_APPARMOR_VOID_DOI "0"
#define SECURITY_APPARMOR_NAME "apparmor"
#define VIRT_AA_HELPER LIBEXECDIR "/virt-aa-helper"
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 09b5e57..bf3828e 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -36,6 +36,9 @@
#include "virutil.h"

#define VIR_FROM_THIS VIR_FROM_SECURITY
+
+VIR_LOG_INIT("security.security_dac");
+
#define SECURITY_DAC_NAME "dac"

typedef struct _virSecurityDACData virSecurityDACData;
diff --git a/src/security/security_driver.c b/src/security/security_driver.c
index d8a8283..4800d52 100644
--- a/src/security/security_driver.c
+++ b/src/security/security_driver.c
@@ -39,6 +39,8 @@

#define VIR_FROM_THIS VIR_FROM_SECURITY

+VIR_LOG_INIT("security.security_driver");
+
static virSecurityDriverPtr security_drivers[] = {
#ifdef WITH_SECDRIVER_SELINUX
&virSecurityDriverSELinux,
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index 5ecf72f..795807a 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -33,6 +33,7 @@

#define VIR_FROM_THIS VIR_FROM_SECURITY

+VIR_LOG_INIT("security.security_manager");

struct _virSecurityManager {
virObjectLockable parent;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 448f686..02c7496 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -49,6 +49,8 @@

#define VIR_FROM_THIS VIR_FROM_SECURITY

+VIR_LOG_INIT("security.security_selinux");
+
#define MAX_CONTEXT 1024

typedef struct _virSecuritySELinuxData virSecuritySELinuxData;
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index f7b91ac..d14e633 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -86,6 +86,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend");
+
static virStorageBackendPtr backends[] = {
#if WITH_STORAGE_DIR
&virStorageBackendDirectory,
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index a7a7d0e..4b4faec 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -38,6 +38,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_disk");
+
#define PARTHELPER LIBEXECDIR "/libvirt_parthelper"

#define SECTOR_SIZE 512
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 4d69f74..c380077 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_fs");
+
#define VIR_STORAGE_VOL_FS_OPEN_FLAGS (VIR_STORAGE_VOL_OPEN_DEFAULT |\
VIR_STORAGE_VOL_OPEN_DIR)
#define VIR_STORAGE_VOL_FS_REFRESH_FLAGS (VIR_STORAGE_VOL_FS_OPEN_FLAGS &\
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 202a441..a22b23a 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_gluster");
+
struct _virStorageBackendGlusterState {
glfs_t *vol;

diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 1149e43..1aee324 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -48,6 +48,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_iscsi");
+
#define ISCSI_DEFAULT_TARGET_PORT 3260

static char *
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 15b86dc..b4720db 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -42,6 +42,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_logical");
+
#define PV_BLANK_SECTOR_SIZE 512


diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index 1e65a8d..564bb97 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -39,6 +39,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_mpath");
+
static int
virStorageBackendMpathUpdateVolTargetInfo(virStorageVolTargetPtr target,
unsigned long long *allocation,
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 22ed7de..c059e25 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_rbd");
+
struct _virStorageBackendRBDState {
rados_t cluster;
rados_ioctx_t ioctx;
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 1841816..83eee4f 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -38,6 +38,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_backend_scsi");
+
/* Function to check if the type file in the given sysfs_path is a
* Direct-Access device (i.e. type 0). Return -1 on failure, type of
* the device otherwise.
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 82df274..1673b5e 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -32,7 +32,6 @@
#include "storage_conf.h"
#include "vircommand.h"
#include "viralloc.h"
-#include "virlog.h"
#include "virstring.h"

#define VIR_FROM_THIS VIR_FROM_STORAGE
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index e0ebdb0..05f7ea6 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -52,6 +52,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("storage.storage_driver");
+
static virStorageDriverStatePtr driverState;

static int storageStateCleanup(void);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 6806ffd..52ff4e2 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -62,6 +62,8 @@

#define VIR_FROM_THIS VIR_FROM_TEST

+VIR_LOG_INIT("test.test_driver");
+
/* Driver specific info to carry with a domain */
struct _testDomainObjPrivate {
virVcpuInfoPtr vcpu_infos;
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 0f2f38e..3567b03 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -50,6 +50,7 @@

#define VIR_FROM_THIS VIR_FROM_UML

+VIR_LOG_INIT("uml.uml_conf");

virCapsPtr umlCapsInit(void) {
virCapsPtr caps;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 3496e52..eb76fc3 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -69,6 +69,8 @@

#define VIR_FROM_THIS VIR_FROM_UML

+VIR_LOG_INIT("uml.uml_driver");
+
/* For storing short-lived temporary files. */
#define TEMPDIR LOCALSTATEDIR "/cache/libvirt"

diff --git a/src/util/viralloc.c b/src/util/viralloc.c
index 27ed74a..be9f0fe 100644
--- a/src/util/viralloc.c
+++ b/src/util/viralloc.c
@@ -29,6 +29,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.alloc");
+
#if TEST_OOM
static int testMallocNext = 0;
static int testMallocFailFirst = 0;
diff --git a/src/util/virarch.c b/src/util/virarch.c
index c71c7eb..be48bcf 100644
--- a/src/util/virarch.c
+++ b/src/util/virarch.c
@@ -27,6 +27,8 @@
#include "virarch.h"
#include "verify.h"

+VIR_LOG_INIT("util.arch");
+
/* The canonical names are used in XML documents. ie ABI sensitive */
static const struct virArchData {
const char *name;
diff --git a/src/util/viraudit.c b/src/util/viraudit.c
index 1d9442e..8d46c3b 100644
--- a/src/util/viraudit.c
+++ b/src/util/viraudit.c
@@ -34,6 +34,8 @@
#include "viralloc.h"
#include "virstring.h"

+VIR_LOG_INIT("util.audit");
+
/* Provide the macros in case the header file is old.
FIXME: should be removed. */
#ifndef AUDIT_VIRT_CONTROL
diff --git a/src/util/virauth.c b/src/util/virauth.c
index e66cbf5..7f94eb6 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_AUTH

+VIR_LOG_INIT("util.auth");
+
int
virAuthGetConfigFilePathURI(virURIPtr uri,
char **path)
diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c
index 808d1cb..d7fd04a 100644
--- a/src/util/virauthconfig.c
+++ b/src/util/virauthconfig.c
@@ -37,6 +37,7 @@ struct _virAuthConfig {

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.authconfig");

virAuthConfigPtr virAuthConfigNew(const char *path)
{
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 0f04b4d..33619af 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -55,6 +55,8 @@

#include "nodeinfo.h"

+VIR_LOG_INIT("util.cgroup");
+
#define CGROUP_MAX_VAL 512

#define VIR_FROM_THIS VIR_FROM_CGROUP
diff --git a/src/util/virclosecallbacks.c b/src/util/virclosecallbacks.c
index a39be60..ff971c8 100644
--- a/src/util/virclosecallbacks.c
+++ b/src/util/virclosecallbacks.c
@@ -31,6 +31,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.closecallbacks");
+
typedef struct _virDriverCloseDef virDriverCloseDef;
typedef virDriverCloseDef *virDriverCloseDefPtr;
struct _virDriverCloseDef {
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index b137436..c44e646 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.command");
+
/* Flags for virExec */
enum {
VIR_EXEC_NONE = 0,
diff --git a/src/util/virconf.c b/src/util/virconf.c
index 63aa569..b965df7 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -41,6 +41,8 @@

#define VIR_FROM_THIS VIR_FROM_CONF

+VIR_LOG_INIT("util.conf");
+
/************************************************************************
* *
* Structures and macros used by the mini parser *
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index a6232b7..ac314d1 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -30,6 +30,8 @@

#define VIR_FROM_THIS VIR_FROM_DBUS

+VIR_LOG_INIT("util.dbus");
+
#ifdef WITH_DBUS

static bool sharedBus = true;
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index fa31d69..20dca0f 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -52,6 +52,9 @@
#include "virstring.h"

#define VIR_FROM_THIS VIR_FROM_NETWORK
+
+VIR_LOG_INIT("util.dnsmasq");
+
#define DNSMASQ_HOSTSFILE_SUFFIX "hostsfile"
#define DNSMASQ_ADDNHOSTSFILE_SUFFIX "addnhosts"

diff --git a/src/util/virebtables.c b/src/util/virebtables.c
index 67f281c..59d855a 100644
--- a/src/util/virebtables.c
+++ b/src/util/virebtables.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.ebtables");
+
#if HAVE_FIREWALLD
static char *firewall_cmd_path = NULL;

diff --git a/src/util/virerror.c b/src/util/virerror.c
index 123e51f..2089190 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -35,6 +35,8 @@
#include "virutil.h"
#include "virstring.h"

+VIR_LOG_INIT("util.error");
+
virThreadLocal virLastErr;

virErrorFunc virErrorHandler = NULL; /* global error handler */
diff --git a/src/util/virevent.c b/src/util/virevent.c
index c6dcb26..84d28a4 100644
--- a/src/util/virevent.c
+++ b/src/util/virevent.c
@@ -30,6 +30,8 @@

#include <stdlib.h>

+VIR_LOG_INIT("util.event");
+
static virEventAddHandleFunc addHandleImpl = NULL;
static virEventUpdateHandleFunc updateHandleImpl = NULL;
static virEventRemoveHandleFunc removeHandleImpl = NULL;
diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index 6f1e184..ea890de 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -45,6 +45,8 @@

#define VIR_FROM_THIS VIR_FROM_EVENT

+VIR_LOG_INIT("util.eventpoll");
+
static int virEventPollInterruptLocked(void);

/* State for a single file handle being monitored */
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 96f078d..54c455f 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -63,6 +63,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.file");
+
int virFileClose(int *fdptr, virFileCloseFlags flags)
{
int saved_errno = 0;
diff --git a/src/util/virhash.c b/src/util/virhash.c
index 0857805..9ef3554 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.hash");
+
#define MAX_HASH_LEN 8

/* #define DEBUG_GROW */
diff --git a/src/util/virhook.c b/src/util/virhook.c
index 0f5d0c5..e3ac4d2 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -41,6 +41,8 @@

#define VIR_FROM_THIS VIR_FROM_HOOK

+VIR_LOG_INIT("util.hook");
+
#define LIBVIRT_HOOK_DIR SYSCONFDIR "/libvirt/hooks"

VIR_ENUM_DECL(virHookDriver)
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index 4f5127c..fb2517f 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -39,6 +39,7 @@

#define VIR_FROM_THIS VIR_FROM_IDENTITY

+VIR_LOG_INIT("util.identity");

struct _virIdentity {
virObject parent;
diff --git a/src/util/viriptables.c b/src/util/viriptables.c
index 9b78d86..bfc06dc 100644
--- a/src/util/viriptables.c
+++ b/src/util/viriptables.c
@@ -50,6 +50,8 @@
#include "virstring.h"
#include "virutil.h"

+VIR_LOG_INIT("util.iptables");
+
bool iptables_supports_xlock = false;

#if HAVE_FIREWALLD
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 7044e11..76296d4 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -45,6 +45,7 @@
/* XXX fixme */
#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.json");

typedef struct _virJSONParserState virJSONParserState;
typedef virJSONParserState *virJSONParserStatePtr;
diff --git a/src/util/virkeyfile.c b/src/util/virkeyfile.c
index 0596d4b..acb77b9 100644
--- a/src/util/virkeyfile.c
+++ b/src/util/virkeyfile.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_CONF

+VIR_LOG_INIT("util.keyfile");
+
typedef struct _virKeyFileGroup virKeyFileGroup;
typedef virKeyFileGroup *virKeyFileGroupPtr;

diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index cab7775..95570af 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_LOCKSPACE

+VIR_LOG_INIT("util.lockspace");
+
#define VIR_LOCKSPACE_TABLE_SIZE 10

typedef struct _virLockSpaceResource virLockSpaceResource;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index b535623..6a20b89 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -60,6 +60,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.log");
+
/*
* A logging buffer to keep some history over logs
*/
@@ -96,8 +98,6 @@ typedef virLogFilter *virLogFilterPtr;
static virLogFilterPtr virLogFilters = NULL;
static int virLogNbFilters = 0;

-virLogSource virLogSelf = { .name = "util.log" };
-
/*
* Outputs are used to emit the messages retained
* after filtering, multiple output can be used simultaneously
diff --git a/src/util/virlog.h b/src/util/virlog.h
index cb27725..aff9a2c 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -51,7 +51,15 @@ struct _virLogSource {
const char *name;
};

-extern virLogSource virLogSelf;
+/*
+ * verify() call is to make gcc STFU about unused
+ * static variables
+ */
+# define VIR_LOG_INIT(n) \
+ static virLogSource virLogSelf = { \
+ .name = "" n "", \
+ }; \
+ verify(&virLogSelf == &virLogSelf)

/*
* If configured with --enable-debug=yes then library calls
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 6a1ee1e..48f1569 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.netdev");
+
#if defined(HAVE_STRUCT_IFREQ)
static int virNetDevSetupControlFull(const char *ifname,
struct ifreq *ifr,
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index e984bf2..1a1c1e2 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -65,6 +65,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
# include "virnetdev.h"
# include "virpidfile.h"

+VIR_LOG_INIT("util.netdevmacvlan");

# define MACVTAP_NAME_PREFIX "macvtap"
# define MACVTAP_NAME_PATTERN "macvtap%d"
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index ebfc4d4..a36af76 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -42,6 +42,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.netdevtap");
+
/**
* virNetDevTapGetName:
* @tapfd: a tun/tap file descriptor
diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index e698ce2..89357fe 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -37,6 +37,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.netdevveth");
+
/* Functions */

virMutex virNetDevVethCreateMutex;
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index c87837c..9a294d9 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -63,6 +63,8 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, VIR_NETDEV_VPORT_PROFILE_OP_LAST,
# include "virlog.h"
# include "virnetdev.h"

+VIR_LOG_INIT("util.netdevvportprofile");
+
# define MICROSEC_PER_SEC (1000 * 1000)

# define NLMSGBUF_SIZE 256
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index ba6c4b5..b163ffb 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -48,6 +48,8 @@

#define VIR_FROM_THIS VIR_FROM_NET

+VIR_LOG_INIT("util.netlink");
+
#define NETLINK_ACK_TIMEOUT_S (2*1000)

#if defined(__linux__) && defined(HAVE_LIBNL)
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 72a17cd..6d2f50d 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.nodesuspend");
+
#define SUSPEND_DELAY 10 /* in seconds */

/* Give sufficient time for performing the suspend operation on the host */
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 162872c..6ed1cb9 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -43,6 +43,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.numa");
+
VIR_ENUM_IMPL(virDomainNumatuneMemMode,
VIR_DOMAIN_NUMATUNE_MEM_LAST,
"strict",
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 5e3ee71..d1612be 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -33,6 +33,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.object");
+
static unsigned int magicCounter = 0xCAFE0000;

struct _virClass {
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 00d1064..c658430 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -46,6 +46,8 @@
#include "virstring.h"
#include "virutil.h"

+VIR_LOG_INIT("util.pci");
+
#define PCI_SYSFS "/sys/bus/pci/"
#define PCI_ID_LEN 10 /* "XXXX XXXX" */
#define PCI_ADDR_LEN 13 /* "XXXX:XX:XX.X" */
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 298d57c..9309c75 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -40,6 +40,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.pidfile");
+
char *virPidFileBuildPath(const char *dir, const char* name)
{
char *pidfile;
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 305c095..cfabcdc 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.process");
+
/**
* virProcessTranslateStatus:
* @status: child exit status to translate
diff --git a/src/util/virrandom.c b/src/util/virrandom.c
index 491a3af..49181ad 100644
--- a/src/util/virrandom.c
+++ b/src/util/virrandom.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.random");
+
/* The algorithm of virRandomBits relies on gnulib's guarantee that
* 'random_r' matches the POSIX requirements on 'random' of being
* evenly distributed among exactly [0, 2**31) (that is, we always get
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 2f469f2..d2b3106 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -36,7 +36,6 @@
#include <unistd.h>

#include "virscsi.h"
-#include "virlog.h"
#include "viralloc.h"
#include "virfile.h"
#include "virutil.h"
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index e45236f..92a9366 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -51,6 +51,8 @@

#define VIR_FROM_THIS VIR_FROM_STORAGE

+VIR_LOG_INIT("util.storagefile");
+
VIR_ENUM_IMPL(virStorageFileFormat,
VIR_STORAGE_FILE_LAST,
"none",
diff --git a/src/util/virstring.c b/src/util/virstring.c
index b3912f3..9256de7 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.string");
+
/*
* The following virStringSplit & virStringJoin methods
* are derived from g_strsplit / g_strjoin in glib2,
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index f58122f9..7c79aa3 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -32,7 +32,6 @@

#include "virerror.h"
#include "virsysinfo.h"
-#include "virlog.h"
#include "viralloc.h"
#include "vircommand.h"
#include "virfile.h"
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 8adf209..69e9ed0 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -35,6 +35,7 @@

#define VIR_FROM_THIS VIR_FROM_SYSTEMD

+VIR_LOG_INIT("util.systemd");

static void virSystemdEscapeName(virBufferPtr buf,
const char *name)
diff --git a/src/util/virusb.c b/src/util/virusb.c
index bb5980d..3a157c5 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -48,6 +48,8 @@
/* For virReportOOMError() and virReportSystemError() */
#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.usb");
+
struct _virUSBDevice {
unsigned int bus;
unsigned int dev;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 7a2fbb0..ac4c312 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -90,6 +90,8 @@ verify(sizeof(gid_t) <= sizeof(unsigned int) &&

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("util.util");
+
#ifndef WIN32

int virSetInherit(int fd, bool inherit) {
diff --git a/src/util/viruuid.c b/src/util/viruuid.c
index c5fa9a8..0bf6f61 100644
--- a/src/util/viruuid.c
+++ b/src/util/viruuid.c
@@ -44,6 +44,8 @@
#include "virfile.h"
#include "virrandom.h"

+VIR_LOG_INIT("util.uuid");
+
#ifndef ENODATA
# define ENODATA EIO
#endif
diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c
index c87004a..2421763 100644
--- a/src/vbox/vbox_MSCOMGlue.c
+++ b/src/vbox/vbox_MSCOMGlue.c
@@ -40,6 +40,8 @@

#define VIR_FROM_THIS VIR_FROM_VBOX

+VIR_LOG_INIT("vbox.vbox_MSCOMGlue");
+
#define VBOX_REGKEY_ORACLE "Software\\Oracle\\VirtualBox"
#define VBOX_REGKEY_SUN "Software\\Sun\\xVM VirtualBox"

diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index 8652e3a..7775079 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -46,6 +46,7 @@

#define VIR_FROM_THIS VIR_FROM_VBOX

+VIR_LOG_INIT("vbox.vbox_XPCOMCGlue");

/*******************************************************************************
* Defined Constants And Macros *
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index c22b6ce..e26b10a 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -42,6 +42,7 @@

#define VIR_FROM_THIS VIR_FROM_VBOX

+VIR_LOG_INIT("vbox.vbox_driver");

extern virDriver vbox22Driver;
extern virNetworkDriver vbox22NetworkDriver;
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 382d7b4..51a5d86 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -89,6 +89,9 @@


#define VIR_FROM_THIS VIR_FROM_VBOX
+
+VIR_LOG_INIT("vbox.vbox_tmpl");
+
#define VBOX_UTF16_FREE(arg) \
do { \
if (arg) { \
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 8fb2a93..1ebb0f9 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -35,6 +35,8 @@
#include "viruri.h"
#include "virstring.h"

+VIR_LOG_INIT("vmx.vmx");
+
/*

mapping:
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 7506e8c..d6a23e1 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -69,6 +69,9 @@
#include "viraccessapicheck.h"

#define VIR_FROM_THIS VIR_FROM_XEN
+
+VIR_LOG_INIT("xen.xen_driver");
+
#define XEN_SAVE_DIR LOCALSTATEDIR "/lib/libvirt/xen/save"

static int
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index f9c7b40..dbbec01 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -83,6 +83,8 @@

#define VIR_FROM_THIS VIR_FROM_XEN

+VIR_LOG_INIT("xen.xen_hypervisor");
+
/*
* so far there is 2 versions of the structures usable for doing
* hypervisor calls.
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 2e9787f..d36cef8 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -44,6 +44,8 @@

#define VIR_FROM_THIS VIR_FROM_XEN_INOTIFY

+VIR_LOG_INIT("xen.xen_inotify");
+
static int
xenInotifyXenCacheLookup(virConnectPtr conn,
const char *filename,
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 25137b8..4b10f42 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -63,6 +63,8 @@

#define VIR_FROM_THIS VIR_FROM_XEND

+VIR_LOG_INIT("xen.xend_internal");
+
/*
* The number of Xen scheduler parameters
*/
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index d9a3502..456b09e 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -53,6 +53,8 @@

#define VIR_FROM_THIS VIR_FROM_XENXM

+VIR_LOG_INIT("xen.xm_internal");
+
#ifdef WITH_RHEL5_API
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index ccdb736..1d153be 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -54,6 +54,8 @@

#define VIR_FROM_THIS VIR_FROM_XEN

+VIR_LOG_INIT("xen.xs_internal");
+
static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
static void xenStoreWatchListFree(xenStoreWatchListPtr list);

diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 427fc21..610e0f0 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -38,6 +38,8 @@
#include "xenapi_utils.h"
#include "virstring.h"

+VIR_LOG_INIT("xenapi.xenapi_utils");
+
void
xenSessionFree(xen_session *session)
{
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index d366b1b..e3b1be4 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -39,6 +39,8 @@
#include "virstoragefile.h"
#include "virstring.h"

+VIR_LOG_INIT("xenxs.xen_sxpr");
+
/* Get a domain id from a S-expression string */
int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion, int *id)
{
diff --git a/tests/domainconftest.c b/tests/domainconftest.c
index d38ef5c..c87da5d 100644
--- a/tests/domainconftest.c
+++ b/tests/domainconftest.c
@@ -29,6 +29,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.domainconftest");
+
static virCapsPtr caps;
static virDomainXMLOptionPtr xmlopt;

diff --git a/tests/eventtest.c b/tests/eventtest.c
index 821745f..2cfa0c6 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -34,6 +34,8 @@
#include "virutil.h"
#include "vireventpoll.h"

+VIR_LOG_INIT("tests.eventtest");
+
#define NUM_FDS 31
#define NUM_TIME 31

diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c
index 0eeb8a5..92e7add 100644
--- a/tests/fdstreamtest.c
+++ b/tests/fdstreamtest.c
@@ -36,6 +36,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.fdstreamtest");
+
#define PATTERN_LEN 256

static int testFDStreamReadCommon(const char *scratchdir, bool blocking)
diff --git a/tests/libvirtdconftest.c b/tests/libvirtdconftest.c
index fbc0f3f..3dee6f1 100644
--- a/tests/libvirtdconftest.c
+++ b/tests/libvirtdconftest.c
@@ -34,6 +34,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.libvirtdconftest");
+
struct testCorruptData {
size_t *params;
const char *filedata;
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 60ffe90..9dae9a5 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -38,6 +38,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.qemumonitortestutils");
+
struct _qemuMonitorTestItem {
qemuMonitorTestResponseCallback cb;
void *opaque;
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index f98033d..b723515 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -42,6 +42,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.securityselinuxlabeltest");
+
static virCapsPtr caps;
static virDomainXMLOptionPtr xmlopt;

diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
index 99b9b24..af596ce 100644
--- a/tests/securityselinuxtest.c
+++ b/tests/securityselinuxtest.c
@@ -39,6 +39,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.securityselinuxtest");
+
struct testSELinuxGenLabelData {
virSecurityManagerPtr mgr;

diff --git a/tests/sockettest.c b/tests/sockettest.c
index f98955d..1945b44 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -30,6 +30,8 @@
#include "virlog.h"
#include "viralloc.h"

+VIR_LOG_INIT("tests.sockettest");
+
static int testParse(virSocketAddr *addr, const char *addrstr, int family, bool pass)
{
int rc;
diff --git a/tests/testutils.c b/tests/testutils.c
index f88c18d..8f65b81 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -60,6 +60,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.testutils");
+
#define GETTIMEOFDAY(T) gettimeofday(T, NULL)
#define DIFF_MSEC(T, U) \
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
diff --git a/tests/virauthconfigtest.c b/tests/virauthconfigtest.c
index 0bed997..840a3bd 100644
--- a/tests/virauthconfigtest.c
+++ b/tests/virauthconfigtest.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.authconfigtest");
+
struct ConfigLookupData {
virAuthConfigPtr config;
const char *hostname;
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 5d5eccc..f7dda28 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -37,6 +37,8 @@

# define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.cgrouptest");
+
static int validateCgroup(virCgroupPtr cgroup,
const char *expectPath,
const char **expectMountPoint,
diff --git a/tests/virdbustest.c b/tests/virdbustest.c
index cd4edc7..0234911 100644
--- a/tests/virdbustest.c
+++ b/tests/virdbustest.c
@@ -26,6 +26,8 @@
#include "virlog.h"
#include "testutils.h"

+VIR_LOG_INIT("tests.dbustest");
+
#define VERIFY(typname, valorig, valnew, fmt) \
do { \
VIR_DEBUG("Compare " typname " '" fmt "' to '" \
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index ba6e39d..d527dc4 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -28,6 +28,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.drivermoduletest");
+
struct testDriverData {
const char *name;
const char *dep1;
diff --git a/tests/virhashtest.c b/tests/virhashtest.c
index dbc0dba..eead479 100644
--- a/tests/virhashtest.c
+++ b/tests/virhashtest.c
@@ -15,6 +15,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.hashtest");
+
#define testError(...) \
do { \
char *str; \
diff --git a/tests/viridentitytest.c b/tests/viridentitytest.c
index 814db4f..4f9fdd2 100644
--- a/tests/viridentitytest.c
+++ b/tests/viridentitytest.c
@@ -33,6 +33,7 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.identitytest");

static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED)
{
diff --git a/tests/virkeycodetest.c b/tests/virkeycodetest.c
index 5d1a87b..77378ec 100644
--- a/tests/virkeycodetest.c
+++ b/tests/virkeycodetest.c
@@ -34,6 +34,7 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.keycodetest");

static int testKeycodeMapping(const void *data ATTRIBUTE_UNUSED)
{
diff --git a/tests/virkeyfiletest.c b/tests/virkeyfiletest.c
index 1570ad6..5448298 100644
--- a/tests/virkeyfiletest.c
+++ b/tests/virkeyfiletest.c
@@ -32,6 +32,7 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.keyfiletest");

static int testParse(const void *args ATTRIBUTE_UNUSED)
{
diff --git a/tests/virlockspacetest.c b/tests/virlockspacetest.c
index 78094ef..e3123db 100644
--- a/tests/virlockspacetest.c
+++ b/tests/virlockspacetest.c
@@ -35,6 +35,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.lockspacetest");
+
#define LOCKSPACE_DIR abs_builddir "/virlockspacedata"

static int testLockSpaceCreate(const void *args ATTRIBUTE_UNUSED)
diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c
index ad619de..096a464 100644
--- a/tests/virnetmessagetest.c
+++ b/tests/virnetmessagetest.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.netmessagetest");
+
static int testMessageHeaderEncode(const void *args ATTRIBUTE_UNUSED)
{
virNetMessagePtr msg = virNetMessageNew(true);
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index a14371a..980466e 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -39,6 +39,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.netsockettest");
+
#if HAVE_IFADDRS_H
# define BASE_PORT 5672

diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index 1cc9946..1742981 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -40,6 +40,8 @@

# define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.nettlscontexttest");
+
# define KEYFILE "key-ctx.pem"

struct testTLSContextData {
diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c
index 8a10340..47a1b12 100644
--- a/tests/virnettlshelpers.c
+++ b/tests/virnettlshelpers.c
@@ -34,6 +34,8 @@

# define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.nettlshelpers");
+
/*
* These store some static data that is needed when
* encoding extensions in the x509 certs
diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c
index 6d77d35..fe5b945 100644
--- a/tests/virnettlssessiontest.c
+++ b/tests/virnettlssessiontest.c
@@ -38,6 +38,8 @@

# define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.nettlssessiontest");
+
# define KEYFILE "key-sess.pem"

struct testTLSSessionData {
diff --git a/tests/virportallocatortest.c b/tests/virportallocatortest.c
index 5a93dad..d6dd597 100644
--- a/tests/virportallocatortest.c
+++ b/tests/virportallocatortest.c
@@ -116,6 +116,7 @@ int bind(int sockfd ATTRIBUTE_UNUSED,

# define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.portallocatortest");

static int testAllocAll(const void *args ATTRIBUTE_UNUSED)
{
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index db0cf1c..38581db 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.storagetest");
+
#define datadir abs_builddir "/virstoragedata"

/* This test creates the following files, all in datadir:
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index 8d45e71..92970b2 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -31,6 +31,8 @@

#define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.stringtest");
+
struct testSplitData {
const char *string;
const char *delim;
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 9f6fc83..d3b90be 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -31,6 +31,8 @@

# define VIR_FROM_THIS VIR_FROM_NONE

+VIR_LOG_INIT("tests.systemdtest");
+
static int testCreateContainer(const void *opaque ATTRIBUTE_UNUSED)
{
unsigned char uuid[VIR_UUID_BUFLEN] = {
diff --git a/tests/virtimetest.c b/tests/virtimetest.c
index c1f8f4b..9014b71 100644
--- a/tests/virtimetest.c
+++ b/tests/virtimetest.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.timetest");
+
struct testTimeFieldsData {
unsigned long long when;
struct tm fields;
diff --git a/tests/viruritest.c b/tests/viruritest.c
index 41a8ca7..b5b884e 100644
--- a/tests/viruritest.c
+++ b/tests/viruritest.c
@@ -32,6 +32,8 @@

#define VIR_FROM_THIS VIR_FROM_RPC

+VIR_LOG_INIT("tests.uritest");
+
struct URIParseData {
const char *uri;
const char *uri_out;
diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index 9c39ac4..bb164ef 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -46,6 +46,8 @@
# include "virthread.h"
# include "virerror.h"

+VIR_LOG_INIT("tools.virsh-console");
+
/*
* Convert given character to control character.
* Basically, we assume ASCII, and take lower 6 bits.
--
1.8.5.3
John Ferlan
2014-03-05 15:09:55 UTC
Permalink
Post by Daniel P. Berrange
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.
---
<...snip...>

I found just one typo - I assume this is added anywhere a VIR_FROM_THIS
was found (although I didn't check :-))
Post by Daniel P. Berrange
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index 8e632f5..c7d9d97 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -35,6 +35,8 @@
#define VIR_FROM_THIS VIR_FROM_CONF
+VIR_LOG_INIT("locking.lock_daemon_confijg");
+
s/lock_daemon_confijg/lock_daemon_config
Post by Daniel P. Berrange
/* A helper function used by each of the following macros. */
static int
ACK

John
Daniel P. Berrange
2014-03-05 15:15:03 UTC
Permalink
Post by John Ferlan
Post by Daniel P. Berrange
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.
---
<...snip...>
I found just one typo - I assume this is added anywhere a VIR_FROM_THIS
was found (although I didn't check :-))
Actually anywhere a VIR_DEBUG or equiv statement is set. Fortunately
we will get a compile error if i missed any...

Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Eric Blake
2014-03-07 17:43:04 UTC
Permalink
Post by Daniel P. Berrange
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.
---
daemon/libvirtd-config.c | 2 ++
daemon/libvirtd.c | 3 +++
daemon/libvirtd.h | 1 -
daemon/remote.c | 2 ++
daemon/stream.c | 2 ++
docs/apibuild.py | 30 ++++++++++++++++++++++++++++++
You know, generating the patch with git's '-Ofile' containing globs to
float the important files first into the diff makes review a bit easier.
Post by Daniel P. Berrange
229 files changed, 432 insertions(+), 48 deletions(-)
Big, but I don't see any way to break it down.
Post by Daniel P. Berrange
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index c816fda..c68c6f4 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -37,6 +37,8 @@
#define VIR_FROM_THIS VIR_FROM_CONF
+VIR_LOG_INIT("daemon.libvirtd-config");
Idea for a followup patch - instead of having VIR_FROM_THIS hard-coded
as a macro, could we instead inline it as an argument to VIR_LOG_INIT()
which populates another member of the static struct? Then all the error
logging functions would read it out of the struct as a single argument,
instead of the current setup of getting an argument for both the struct
and the VIR_FROM_THIS macro expansion as two separate arguments. If you
respin the patch series, it might be nice to do the all-file-touching
patch only once, rather than having to do it in two pieces.
Post by Daniel P. Berrange
+++ b/src/util/virlog.h
@@ -51,7 +51,15 @@ struct _virLogSource {
const char *name;
};
-extern virLogSource virLogSelf;
+/*
+ * verify() call is to make gcc STFU about unused
+ * static variables
+ */
+# define VIR_LOG_INIT(n) \
+ static virLogSource virLogSelf = { \
+ .name = "" n "", \
+ }; \
+ verify(&virLogSelf == &virLogSelf)
Isn't an unused variable the sign of a file with no log messages? On
the other hand, ease of maintenance says it is easier to always have the
logging framework in place than it is to turn it on/off per file as we
edit messages in or out of a file.

Would the compiler warning also go away if you used:

static ATTRIBUTE_UNUSED virLogSource virlogSelf = {...};

without needing the use of a verify()?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Eric Blake
2014-03-07 19:32:56 UTC
Permalink
Post by Eric Blake
Post by Daniel P. Berrange
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.
#define VIR_FROM_THIS VIR_FROM_CONF
+VIR_LOG_INIT("daemon.libvirtd-config");
Idea for a followup patch - instead of having VIR_FROM_THIS hard-coded
as a macro, could we instead inline it as an argument to VIR_LOG_INIT()
which populates another member of the static struct? Then all the error
logging functions would read it out of the struct as a single argument,
instead of the current setup of getting an argument for both the struct
and the VIR_FROM_THIS macro expansion as two separate arguments. If you
respin the patch series, it might be nice to do the all-file-touching
patch only once, rather than having to do it in two pieces.
Hmm. I noticed that VIR_INSERT_ELEMENT also relies on VIR_FROM_THIS,
but in doing so, it loses the virLogSelf of the caller as part of
calling into the viralloc.c with its own virLogSelf. But if we rework
VIR_INSERT_ELEMENT to pass virLogSelf instead of VIR_FROM_THIS, and
rework viralloc.c to reuse the passed in context instead of its own
virLogSelf, we could report errors on behalf of the caller - which may
or may not be a good thing for purposes of deciding what log filters to
enable when inspecting an OOM failure. So maybe the idea of dropping
VIR_FROM_THIS is not worthwhile after all.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-10 10:14:29 UTC
Permalink
Post by Eric Blake
Post by Daniel P. Berrange
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.
---
daemon/libvirtd-config.c | 2 ++
daemon/libvirtd.c | 3 +++
daemon/libvirtd.h | 1 -
daemon/remote.c | 2 ++
daemon/stream.c | 2 ++
docs/apibuild.py | 30 ++++++++++++++++++++++++++++++
You know, generating the patch with git's '-Ofile' containing globs to
float the important files first into the diff makes review a bit easier.
Post by Daniel P. Berrange
229 files changed, 432 insertions(+), 48 deletions(-)
Big, but I don't see any way to break it down.
Post by Daniel P. Berrange
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index c816fda..c68c6f4 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -37,6 +37,8 @@
#define VIR_FROM_THIS VIR_FROM_CONF
+VIR_LOG_INIT("daemon.libvirtd-config");
Idea for a followup patch - instead of having VIR_FROM_THIS hard-coded
as a macro, could we instead inline it as an argument to VIR_LOG_INIT()
which populates another member of the static struct? Then all the error
logging functions would read it out of the struct as a single argument,
instead of the current setup of getting an argument for both the struct
and the VIR_FROM_THIS macro expansion as two separate arguments. If you
respin the patch series, it might be nice to do the all-file-touching
patch only once, rather than having to do it in two pieces.
NB there is a 1-1 mapping of VIR_LOG_INIT <-> source files, but the
same is not always true of error reporting APIs. Most will use VIR_FROM_THIS
but there are a bunch of special cases where we won't rely on that macro.
In particular in the RPC code.
Post by Eric Blake
Post by Daniel P. Berrange
+++ b/src/util/virlog.h
@@ -51,7 +51,15 @@ struct _virLogSource {
const char *name;
};
-extern virLogSource virLogSelf;
+/*
+ * verify() call is to make gcc STFU about unused
+ * static variables
+ */
+# define VIR_LOG_INIT(n) \
+ static virLogSource virLogSelf = { \
+ .name = "" n "", \
+ }; \
+ verify(&virLogSelf == &virLogSelf)
Isn't an unused variable the sign of a file with no log messages? On
the other hand, ease of maintenance says it is easier to always have the
logging framework in place than it is to turn it on/off per file as we
edit messages in or out of a file.
The issue I hit was that a number of source files only have log messages
when certain configure time flags are set, and some of the conditions
you'd have to protect VIR_LOG_INIT are rather hairy. So I think it is
actually more reliable to just silence the compiler, otherwise certain
configure setups will continually get broken.
Post by Eric Blake
static ATTRIBUTE_UNUSED virLogSource virlogSelf = {...};
without needing the use of a verify()?
No idea, worth a try. I didn't know ATTRIBUTE_UNUSED would even work
on global variables - thought it was only function parameters.

Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Daniel P. Berrange
2014-03-03 19:18:11 UTC
Permalink
Currently the log filter strings are used in a string comparison
against the source filename each time log message is emitted.
If no log filters at all are set, there's obviously no string
comparison to be done. If any single log filter is set though,
this imposes a compute burden on every logging call even if logs
from the file in question are disabled. This string comparison
must also be done while the logging mutex is held, which has
implications for concurrency when multiple threads are emitting
log messages.

This changes the log filtering to be done baed on the virLogSource
object name. The virLogSource struct is extended to container
'serial' and 'priority' fields. Any time the global log filter
rules are changed a global serial number is incremented. When a
log message is emitted, the serial in the virLogSource instance
is compared with the global serial number. If out of date, then
the 'priority' field in the virLogSource instance is updated based
on the new filter rules. The 'priority' field is checked to see
whether the log message should be sent to the log outputs.

The comparisons of the 'serial' and 'priority' fields are done
with no locks held. So in the common case each logging call has
an overhead of 2 integer comparisons, with no locks held. Only
if the decision is made to forward the message to the log output,
or if the 'serial' value is out of date do locks need to be
acquired.

Technically the comparisons of the 'serial' and 'priority' fields
should be done with locks held, or using atomic operations. Both
of these options have a notable performance impact, however, and
it is believed that worst case behaviour where the fields are
read concurrently with being written would merely result in an
mistaken emissions or dropping of the log message in question.
This is an acceptable tradeoff for the performance benefit of
avoiding locking.

As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 4.6 seconds todo 51200 iterations.
After this optimization it only takes 3.3 seconds, with the log
APIs no longer being a relevant factor in the running time.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
src/util/virlog.c | 81 +++++++++++++++++++++++++------------------------------
src/util/virlog.h | 6 +++++
2 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 6a20b89..048d2c4 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -95,6 +95,7 @@ struct _virLogFilter {
typedef struct _virLogFilter virLogFilter;
typedef virLogFilter *virLogFilterPtr;

+static int virLogFiltersSerial = 1;
static virLogFilterPtr virLogFilters = NULL;
static int virLogNbFilters = 0;

@@ -514,6 +515,7 @@ virLogResetFilters(void)
VIR_FREE(virLogFilters[i].match);
VIR_FREE(virLogFilters);
virLogNbFilters = 0;
+ virLogFiltersSerial++;
return i;
}

@@ -569,6 +571,7 @@ virLogDefineFilter(const char *match,
virLogFilters[i].priority = priority;
virLogFilters[i].flags = flags;
virLogNbFilters++;
+ virLogFiltersSerial++;
cleanup:
virLogUnlock();
if (ret < 0)
@@ -576,37 +579,6 @@ cleanup:
return ret;
}

-
-/**
- * virLogFiltersCheck:
- * @input: the input string
- *
- * Check the input of the message against the existing filters. Currently
- * the match is just a substring check of the category used as the input
- * string, a more subtle approach could be used instead
- *
- * Returns 0 if not matched or the new priority if found.
- */
-static int
-virLogFiltersCheck(const char *input,
- unsigned int *flags)
-{
- int ret = 0;
- size_t i;
-
- virLogLock();
- for (i = 0; i < virLogNbFilters; i++) {
- if (strstr(input, virLogFilters[i].match)) {
- ret = virLogFilters[i].priority;
- *flags = virLogFilters[i].flags;
- break;
- }
- }
- virLogUnlock();
- return ret;
-}
-
-
/**
* virLogResetOutputs:
*
@@ -745,6 +717,30 @@ virLogVersionString(const char **rawmsg,
}


+static void
+virLogSourceUpdate(virLogSourcePtr source)
+{
+ virLogLock();
+ if (source->serial < virLogFiltersSerial) {
+ unsigned int priority = virLogDefaultPriority;
+ unsigned int flags = 0;
+ size_t i;
+
+ for (i = 0; i < virLogNbFilters; i++) {
+ if (strstr(source->name, virLogFilters[i].match)) {
+ priority = virLogFilters[i].priority;
+ flags = virLogFilters[i].flags;
+ break;
+ }
+ }
+
+ source->priority = priority;
+ source->flags = flags;
+ source->serial = virLogFiltersSerial;
+ }
+ virLogUnlock();
+}
+
/**
* virLogMessage:
* @source: where is that message coming from
@@ -805,31 +801,28 @@ virLogVMessage(virLogSourcePtr source,
char *str = NULL;
char *msg = NULL;
char timestamp[VIR_TIME_STRING_BUFLEN];
- int fprio, ret;
+ int ret;
size_t i;
int saved_errno = errno;
- bool emit = true;
unsigned int filterflags = 0;

if (virLogInitialize() < 0)
return;

if (fmt == NULL)
- goto cleanup;
+ return;

/*
- * check against list of specific logging patterns
+ * 3 intentionally non-thread safe variable reads.
+ * Worst case result is a log message is accidentally
+ * dropped or emitted, if another thread is updating
+ * log filter list concurrently with a log message
*/
- fprio = virLogFiltersCheck(filename, &filterflags);
- if (fprio == 0) {
- if (priority < virLogDefaultPriority)
- emit = false;
- } else if (priority < fprio) {
- emit = false;
- }
-
- if (!emit)
+ if (source->serial < virLogFiltersSerial)
+ virLogSourceUpdate(source);
+ if (priority < source->priority)
goto cleanup;
+ filterflags = source->flags;

/*
* serialize the error message, add level and timestamp
diff --git a/src/util/virlog.h b/src/util/virlog.h
index aff9a2c..b2d5edc 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -49,6 +49,9 @@ typedef virLogSource *virLogSourcePtr;

struct _virLogSource {
const char *name;
+ unsigned int priority;
+ unsigned int serial;
+ unsigned int flags;
};

/*
@@ -58,6 +61,9 @@ struct _virLogSource {
# define VIR_LOG_INIT(n) \
static virLogSource virLogSelf = { \
.name = "" n "", \
+ .priority = VIR_LOG_ERROR, \
+ .serial = 0, \
+ .flags = 0, \
}; \
verify(&virLogSelf == &virLogSelf)
--
1.8.5.3
Eric Blake
2014-03-07 18:05:28 UTC
Permalink
Post by Daniel P. Berrange
Currently the log filter strings are used in a string comparison
against the source filename each time log message is emitted.
If no log filters at all are set, there's obviously no string
comparison to be done. If any single log filter is set though,
this imposes a compute burden on every logging call even if logs
from the file in question are disabled. This string comparison
must also be done while the logging mutex is held, which has
implications for concurrency when multiple threads are emitting
log messages.
This changes the log filtering to be done baed on the virLogSource
s/baed/based/
Post by Daniel P. Berrange
object name. The virLogSource struct is extended to container
s/container/contain/
Post by Daniel P. Berrange
'serial' and 'priority' fields. Any time the global log filter
rules are changed a global serial number is incremented. When a
log message is emitted, the serial in the virLogSource instance
is compared with the global serial number. If out of date, then
the 'priority' field in the virLogSource instance is updated based
on the new filter rules. The 'priority' field is checked to see
whether the log message should be sent to the log outputs.
The comparisons of the 'serial' and 'priority' fields are done
with no locks held. So in the common case each logging call has
an overhead of 2 integer comparisons, with no locks held. Only
if the decision is made to forward the message to the log output,
or if the 'serial' value is out of date do locks need to be
acquired.
Technically the comparisons of the 'serial' and 'priority' fields
should be done with locks held, or using atomic operations.
Only if we care about strict happens-after relationships between code
that adjust logging levels vs. code testing whether to emit a particular
log message.
Post by Daniel P. Berrange
Both
of these options have a notable performance impact, however, and
it is believed that worst case behaviour where the fields are
read concurrently with being written would merely result in an
mistaken emissions or dropping of the log message in question.
This is an acceptable tradeoff for the performance benefit of
avoiding locking.
Almost. As long as writes are safe, the worst that can happen is we
fail to emit a message that just got enabled, or we emit a message that
just got disabled. But had we used locks to avoid this race, and the
locks get obtained in reverse order, we would see the same behavior. So
the locks add no protection, and eliding them in favor of simpler
non-atomic integer ops is a safe action.

If there were only a single writer, then writes would be automatically
safe. However, you have multiple writers. Thus, you have the situation
that if two writers both try to increment the global serial with no
locks or atomic increments, you could end up with the classic symptoms
of over- or under-incrementing the global serial. If three threads compete:

start: global is 1
thread one: read global to compute its increment
thread two: read global to compute its increment
thread two: write the increment, global is now 2
thread three: compare local 0 against global 2, recompute priority
thread one: write the increment, global is now 2
thread three: compare local 2 against global 2, no priority recompute

Oops - if thread one changed priority so that thread three should no
longer log, we've messed up, and may have LOTS of messages logged that
should not have been, rather than just one or two at the race boundary
case. So I think your _increments_ need to be atomic, to protect the
writers, but those are not the hot path; while the READS of the global
can remain unprotected, and those are the actual hot path you are
optimizing in this patch.
Post by Daniel P. Berrange
As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 4.6 seconds todo 51200 iterations.
s/todo/to do/
Post by Daniel P. Berrange
After this optimization it only takes 3.3 seconds, with the log
APIs no longer being a relevant factor in the running time.
---
src/util/virlog.c | 81 +++++++++++++++++++++++++------------------------------
src/util/virlog.h | 6 +++++
2 files changed, 43 insertions(+), 44 deletions(-)
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 6a20b89..048d2c4 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -95,6 +95,7 @@ struct _virLogFilter {
typedef struct _virLogFilter virLogFilter;
typedef virLogFilter *virLogFilterPtr;
+static int virLogFiltersSerial = 1;
Good - starting at 1 while all per-file structs start at 0 means that
the first time any logging is attempted it recomputes priority in each file.
Post by Daniel P. Berrange
static virLogFilterPtr virLogFilters = NULL;
static int virLogNbFilters = 0;
@@ -514,6 +515,7 @@ virLogResetFilters(void)
VIR_FREE(virLogFilters[i].match);
VIR_FREE(virLogFilters);
virLogNbFilters = 0;
+ virLogFiltersSerial++;
return i;
}
@@ -569,6 +571,7 @@ virLogDefineFilter(const char *match,
virLogFilters[i].priority = priority;
virLogFilters[i].flags = flags;
virLogNbFilters++;
+ virLogFiltersSerial++;
These are the increments that I think are not hotpath, and need to be
serialized with an atomic increment.
Post by Daniel P. Berrange
+static void
+virLogSourceUpdate(virLogSourcePtr source)
+{
+ virLogLock();
The common case is that the per-log serial will match the global serial;
while holding the lock on the boundary case of an updated global serial
is not going to affect hot case.
Post by Daniel P. Berrange
/*
- * check against list of specific logging patterns
+ * 3 intentionally non-thread safe variable reads.
+ * Worst case result is a log message is accidentally
+ * dropped or emitted, if another thread is updating
+ * log filter list concurrently with a log message
and again, if we WERE thread-safe, the race could have always been won
the other way in obtaining the lock, for the same end result, so our
lack of thread-safety isn't critical.
Post by Daniel P. Berrange
*/
- fprio = virLogFiltersCheck(filename, &filterflags);
- if (fprio == 0) {
- if (priority < virLogDefaultPriority)
- emit = false;
- } else if (priority < fprio) {
- emit = false;
- }
-
- if (!emit)
+ if (source->serial < virLogFiltersSerial)
+ virLogSourceUpdate(source);
+ if (priority < source->priority)
goto cleanup;
+ filterflags = source->flags;
Makes sense.
Post by Daniel P. Berrange
@@ -58,6 +61,9 @@ struct _virLogSource {
# define VIR_LOG_INIT(n) \
static virLogSource virLogSelf = { \
.name = "" n "", \
+ .priority = VIR_LOG_ERROR, \
+ .serial = 0, \
+ .flags = 0, \
The last two are not strictly necessary; static initialization
guarantees zero-initialization. But it doesn't hurt.

I'll let you either spin a v2 to address my atomic increment concerns,
or provide a counterargument on why I should ACK as-is.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-10 10:18:58 UTC
Permalink
Post by Eric Blake
Post by Daniel P. Berrange
Both
of these options have a notable performance impact, however, and
it is believed that worst case behaviour where the fields are
read concurrently with being written would merely result in an
mistaken emissions or dropping of the log message in question.
This is an acceptable tradeoff for the performance benefit of
avoiding locking.
Almost. As long as writes are safe, the worst that can happen is we
fail to emit a message that just got enabled, or we emit a message that
just got disabled. But had we used locks to avoid this race, and the
locks get obtained in reverse order, we would see the same behavior. So
the locks add no protection, and eliding them in favor of simpler
non-atomic integer ops is a safe action.
If there were only a single writer, then writes would be automatically
safe. However, you have multiple writers. Thus, you have the situation
that if two writers both try to increment the global serial with no
locks or atomic increments, you could end up with the classic symptoms
start: global is 1
thread one: read global to compute its increment
thread two: read global to compute its increment
thread two: write the increment, global is now 2
thread three: compare local 0 against global 2, recompute priority
thread one: write the increment, global is now 2
thread three: compare local 2 against global 2, no priority recompute
Oops - if thread one changed priority so that thread three should no
longer log, we've messed up, and may have LOTS of messages logged that
should not have been, rather than just one or two at the race boundary
case. So I think your _increments_ need to be atomic, to protect the
writers, but those are not the hot path; while the READS of the global
can remain unprotected, and those are the actual hot path you are
optimizing in this patch.
The writes are already protected by a mutex so I don't think we need
to use atomic ops for increment either.
Post by Eric Blake
Post by Daniel P. Berrange
static virLogFilterPtr virLogFilters = NULL;
static int virLogNbFilters = 0;
@@ -514,6 +515,7 @@ virLogResetFilters(void)
VIR_FREE(virLogFilters[i].match);
VIR_FREE(virLogFilters);
virLogNbFilters = 0;
+ virLogFiltersSerial++;
return i;
}
@@ -569,6 +571,7 @@ virLogDefineFilter(const char *match,
virLogFilters[i].priority = priority;
virLogFilters[i].flags = flags;
virLogNbFilters++;
+ virLogFiltersSerial++;
These are the increments that I think are not hotpath, and need to be
serialized with an atomic increment.
These two functions run with the global log mutex held, so there can
only be one writer at a time.
Post by Eric Blake
Post by Daniel P. Berrange
+static void
+virLogSourceUpdate(virLogSourcePtr source)
+{
+ virLogLock();
The common case is that the per-log serial will match the global serial;
while holding the lock on the boundary case of an updated global serial
is not going to affect hot case.
Post by Daniel P. Berrange
/*
- * check against list of specific logging patterns
+ * 3 intentionally non-thread safe variable reads.
+ * Worst case result is a log message is accidentally
+ * dropped or emitted, if another thread is updating
+ * log filter list concurrently with a log message
and again, if we WERE thread-safe, the race could have always been won
the other way in obtaining the lock, for the same end result, so our
lack of thread-safety isn't critical.
Post by Daniel P. Berrange
*/
- fprio = virLogFiltersCheck(filename, &filterflags);
- if (fprio == 0) {
- if (priority < virLogDefaultPriority)
- emit = false;
- } else if (priority < fprio) {
- emit = false;
- }
-
- if (!emit)
+ if (source->serial < virLogFiltersSerial)
+ virLogSourceUpdate(source);
+ if (priority < source->priority)
goto cleanup;
+ filterflags = source->flags;
Makes sense.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Eric Blake
2014-03-10 15:39:41 UTC
Permalink
Post by Daniel P. Berrange
Post by Eric Blake
Post by Daniel P. Berrange
Both
of these options have a notable performance impact, however, and
it is believed that worst case behaviour where the fields are
read concurrently with being written would merely result in an
mistaken emissions or dropping of the log message in question.
This is an acceptable tradeoff for the performance benefit of
avoiding locking.
Almost. As long as writes are safe, the worst that can happen is we
fail to emit a message that just got enabled, or we emit a message that
just got disabled. But had we used locks to avoid this race, and the
locks get obtained in reverse order, we would see the same behavior. So
the locks add no protection, and eliding them in favor of simpler
non-atomic integer ops is a safe action.
If there were only a single writer, then writes would be automatically
safe. However, you have multiple writers. Thus, you have the situation
that if two writers both try to increment the global serial with no
locks or atomic increments, you could end up with the classic symptoms
The writes are already protected by a mutex so I don't think we need
to use atomic ops for increment either.
These two functions run with the global log mutex held, so there can
only be one writer at a time.
Ah, I missed the bigger picture. Indeed, the increments happen while
the mutex is held, so ACK.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-03 19:18:12 UTC
Permalink
A earlier commit changed the global log buffer so that it only
records messages that are explicitly requested via the log
filters setting. This removes the performance burden, and
improves the signal/noise ratio for messages in the global
buffer. At the same time though, it is somewhat pointless, since
all the recorded log messages are already going to be sent to an
explicit log output like syslog, stderr or the journal. The
global log buffer is thus just duplicating this data on stderr
upon crash.

Signed-off-by: Daniel P. Berrange <***@redhat.com>
---
daemon/libvirtd-config.c | 3 -
daemon/libvirtd-config.h | 1 -
daemon/libvirtd.aug | 1 -
daemon/libvirtd.c | 2 -
daemon/libvirtd.conf | 7 -
daemon/test_libvirtd.aug.in | 1 -
docs/logging.html.in | 10 --
src/locking/lock_daemon.c | 2 -
src/locking/lock_daemon_config.c | 2 -
src/locking/lock_daemon_config.h | 1 -
src/locking/test_virtlockd.aug.in | 2 -
src/locking/virtlockd.aug | 1 -
src/locking/virtlockd.conf | 7 -
src/rpc/virnetserver.c | 45 -------
src/util/virlog.c | 264 +-------------------------------------
src/util/virlog.h | 2 -
16 files changed, 3 insertions(+), 348 deletions(-)

diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index c68c6f4..95134ab 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -267,8 +267,6 @@ daemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
data->max_requests = 20;
data->max_client_requests = 5;

- data->log_buffer_size = 64;
-
data->audit_level = 1;
data->audit_logging = 0;

@@ -431,7 +429,6 @@ daemonConfigLoadOptions(struct daemonConfig *data,
GET_CONF_INT(conf, filename, log_level);
GET_CONF_STR(conf, filename, log_filters);
GET_CONF_STR(conf, filename, log_outputs);
- GET_CONF_INT(conf, filename, log_buffer_size);

GET_CONF_INT(conf, filename, keepalive_interval);
GET_CONF_INT(conf, filename, keepalive_count);
diff --git a/daemon/libvirtd-config.h b/daemon/libvirtd-config.h
index a24d5d2..b8558ea 100644
--- a/daemon/libvirtd-config.h
+++ b/daemon/libvirtd-config.h
@@ -73,7 +73,6 @@ struct daemonConfig {
int log_level;
char *log_filters;
char *log_outputs;
- int log_buffer_size;

int audit_level;
int audit_logging;
diff --git a/daemon/libvirtd.aug b/daemon/libvirtd.aug
index 70fce5c..73843ed 100644
--- a/daemon/libvirtd.aug
+++ b/daemon/libvirtd.aug
@@ -64,7 +64,6 @@ module Libvirtd =
let logging_entry = int_entry "log_level"
| str_entry "log_filters"
| str_entry "log_outputs"
- | int_entry "log_buffer_size"

let auditing_entry = int_entry "audit_level"
| bool_entry "audit_logging"
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index f2f1a83..a805a2c 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -661,8 +661,6 @@ daemonSetupLogging(struct daemonConfig *config,

virLogSetFromEnv();

- virLogSetBufferSize(config->log_buffer_size);
-
if (virLogGetNbFilters() == 0)
virLogParseFilters(config->log_filters);

diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
index 073c178..3b864ce 100644
--- a/daemon/libvirtd.conf
+++ b/daemon/libvirtd.conf
@@ -345,13 +345,6 @@
#log_outputs="3:syslog:libvirtd"
#

-# Log debug buffer size: default 64
-# The daemon keeps an internal debug log buffer which will be dumped in case
-# of crash or upon receiving a SIGUSR2 signal. This setting allows to override
-# the default buffer size in kilobytes.
-# If value is 0 or less the debug log buffer is deactivated
-#log_buffer_size = 64
-

##################################################################
#
diff --git a/daemon/test_libvirtd.aug.in b/daemon/test_libvirtd.aug.in
index a7e8515..ac4cdd7 100644
--- a/daemon/test_libvirtd.aug.in
+++ b/daemon/test_libvirtd.aug.in
@@ -44,7 +44,6 @@ module Test_libvirtd =
{ "log_level" = "3" }
{ "log_filters" = "3:remote 4:event" }
{ "log_outputs" = "3:syslog:libvirtd" }
- { "log_buffer_size" = "64" }
{ "audit_level" = "2" }
{ "audit_logging" = "1" }
{ "host_uuid" = "00000000-0000-0000-0000-000000000000" }
diff --git a/docs/logging.html.in b/docs/logging.html.in
index a8cb538..d8d8f1e 100644
--- a/docs/logging.html.in
+++ b/docs/logging.html.in
@@ -38,12 +38,6 @@
all messages to a debugging file but only allow errors to be
logged through syslog.</li>
</ul>
- <p>Note that the logging module saves all logs to a <b>debug buffer</b>
- filled in a round-robin fashion as to keep a full log of the
- recent logs including all debug. The debug buffer can be resized
- or deactivated in the daemon using the log_buffer_size variable,
- default is 64 kB. This can be used when debugging the library
- (see the virLogBuffer variable content).</p>

<h2>
<a name="log_config">Configuring logging in the library</a>
@@ -245,9 +239,5 @@ log_outputs="1:file:/var/log/libvirt/libvirtd.log"</pre>
<p>in libvirtd.conf and restart the daemon will allow to
gather a copious amount of debugging traces for the operations done
in those areas.</p>
- <p>On the other hand to deactivate the logbuffer in the daemon
- for stable high load servers, set</p>
- <pre>log_buffer_size=0</pre>
- <p>in the libvirtd.conf.</p>
</body>
</html>
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 46b2dd3..54d98d4 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -478,8 +478,6 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,

virLogSetFromEnv();

- virLogSetBufferSize(config->log_buffer_size);
-
if (virLogGetNbFilters() == 0)
virLogParseFilters(config->log_filters);

diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index c7d9d97..38f1a8d 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -115,7 +115,6 @@ virLockDaemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
if (VIR_ALLOC(data) < 0)
return NULL;

- data->log_buffer_size = 64;
data->max_clients = 1024;

return data;
@@ -141,7 +140,6 @@ virLockDaemonConfigLoadOptions(virLockDaemonConfigPtr data,
GET_CONF_INT(conf, filename, log_level);
GET_CONF_STR(conf, filename, log_filters);
GET_CONF_STR(conf, filename, log_outputs);
- GET_CONF_INT(conf, filename, log_buffer_size);
GET_CONF_INT(conf, filename, max_clients);

return 0;
diff --git a/src/locking/lock_daemon_config.h b/src/locking/lock_daemon_config.h
index e75d4a9..1c79a4e 100644
--- a/src/locking/lock_daemon_config.h
+++ b/src/locking/lock_daemon_config.h
@@ -33,7 +33,6 @@ struct _virLockDaemonConfig {
int log_level;
char *log_filters;
char *log_outputs;
- int log_buffer_size;
int max_clients;
};

diff --git a/src/locking/test_virtlockd.aug.in b/src/locking/test_virtlockd.aug.in
index 799818e..e2e3409 100644
--- a/src/locking/test_virtlockd.aug.in
+++ b/src/locking/test_virtlockd.aug.in
@@ -2,11 +2,9 @@ module Test_virtlockd =
let conf = "log_level = 3
log_filters=\"3:remote 4:event\"
log_outputs=\"3:syslog:libvirtd\"
-log_buffer_size = 64
"

test Virtlockd.lns get conf =
{ "log_level" = "3" }
{ "log_filters" = "3:remote 4:event" }
{ "log_outputs" = "3:syslog:libvirtd" }
- { "log_buffer_size" = "64" }
diff --git a/src/locking/virtlockd.aug b/src/locking/virtlockd.aug
index ec8d2b5..7d0d32a 100644
--- a/src/locking/virtlockd.aug
+++ b/src/locking/virtlockd.aug
@@ -27,7 +27,6 @@ module Virtlockd =
let logging_entry = int_entry "log_level"
| str_entry "log_filters"
| str_entry "log_outputs"
- | int_entry "log_buffer_size"
| int_entry "max_clients"

(* Each enty in the config is one of the following three ... *)
diff --git a/src/locking/virtlockd.conf b/src/locking/virtlockd.conf
index 652e156..7a00873 100644
--- a/src/locking/virtlockd.conf
+++ b/src/locking/virtlockd.conf
@@ -52,13 +52,6 @@
#log_outputs="3:syslog:virtlockd"
#

-# Log debug buffer size: default 64
-# The daemon keeps an internal debug log buffer which will be dumped in case
-# of crash or upon receiving a SIGUSR2 signal. This setting allows to override
-# the default buffer size in kilobytes.
-# If value is 0 or less the debug log buffer is deactivated
-#log_buffer_size = 64
-
# The maximum number of concurrent client connections to allow
# over all sockets combined.
# Each running virtual machine will require one open connection
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 3a0e715..0ce89bf 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -326,34 +326,6 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc,
}


-static void
-virNetServerFatalSignal(int sig, siginfo_t *siginfo ATTRIBUTE_UNUSED,
- void *context ATTRIBUTE_UNUSED)
-{
- struct sigaction sig_action;
- int origerrno;
-
- origerrno = errno;
- virLogEmergencyDumpAll(sig);
-
- /*
- * If the signal is fatal, avoid looping over this handler
- * by deactivating it
- */
-#ifdef SIGUSR2
- if (sig != SIGUSR2) {
-#endif
- memset(&sig_action, 0, sizeof(sig_action));
- sig_action.sa_handler = SIG_DFL;
- sigaction(sig, &sig_action, NULL);
- raise(sig);
-#ifdef SIGUSR2
- }
-#endif
- errno = origerrno;
-}
-
-
virNetServerPtr virNetServerNew(size_t min_workers,
size_t max_workers,
size_t priority_workers,
@@ -412,23 +384,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
sig_action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sig_action, NULL);

- /*
- * catch fatal errors to dump a log, also hook to USR2 for dynamic
- * debugging purposes or testing
- */
- sig_action.sa_sigaction = virNetServerFatalSignal;
- sig_action.sa_flags = SA_SIGINFO;
- sigaction(SIGFPE, &sig_action, NULL);
- sigaction(SIGSEGV, &sig_action, NULL);
- sigaction(SIGILL, &sig_action, NULL);
- sigaction(SIGABRT, &sig_action, NULL);
-#ifdef SIGBUS
- sigaction(SIGBUS, &sig_action, NULL);
-#endif
-#ifdef SIGUSR2
- sigaction(SIGUSR2, &sig_action, NULL);
-#endif
-
return srv;

error:
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 048d2c4..f8d0a7a 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -30,7 +30,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <signal.h>
#include <execinfo.h>
#include <regex.h>
#if HAVE_SYSLOG_H
@@ -62,15 +61,6 @@

VIR_LOG_INIT("util.log");

-/*
- * A logging buffer to keep some history over logs
- */
-
-static int virLogSize = 64 * 1024;
-static char *virLogBuffer = NULL;
-static int virLogLen = 0;
-static int virLogStart = 0;
-static int virLogEnd = 0;
static regex_t *virLogRegex = NULL;


@@ -194,29 +184,10 @@ virLogPriorityString(virLogPriority lvl)
static int
virLogOnceInit(void)
{
- const char *pbm = NULL;
-
if (virMutexInit(&virLogMutex) < 0)
return -1;

virLogLock();
- if (VIR_ALLOC_N_QUIET(virLogBuffer, virLogSize + 1) < 0) {
- /*
- * The debug buffer is not a critical component, allow startup
- * even in case of failure to allocate it in case of a
- * configuration mistake.
- */
- virLogSize = 64 * 1024;
- if (VIR_ALLOC_N_QUIET(virLogBuffer, virLogSize + 1) < 0) {
- pbm = "Failed to allocate debug buffer: deactivating debug log\n";
- virLogSize = 0;
- } else {
- pbm = "Failed to allocate debug buffer: reduced to 64 kB\n";
- }
- }
- virLogLen = 0;
- virLogStart = 0;
- virLogEnd = 0;
virLogDefaultPriority = VIR_LOG_DEFAULT;

if (VIR_ALLOC_QUIET(virLogRegex) >= 0) {
@@ -225,8 +196,6 @@ virLogOnceInit(void)
}

virLogUnlock();
- if (pbm)
- VIR_WARN("%s", pbm);
return 0;
}

@@ -234,65 +203,6 @@ VIR_ONCE_GLOBAL_INIT(virLog)


/**
- * virLogSetBufferSize:
- * @size: size of the buffer in kilobytes or <= 0 to deactivate
- *
- * Dynamically set the size or deactivate the logging buffer used to keep
- * a trace of all recent debug output. Note that the content of the buffer
- * is lost if it gets reallocated.
- *
- * Return -1 in case of failure or 0 in case of success
- */
-int
-virLogSetBufferSize(int size)
-{
- int ret = 0;
- int oldsize;
- char *oldLogBuffer;
- const char *pbm = NULL;
-
- if (size < 0)
- size = 0;
-
- if (virLogInitialize() < 0)
- return -1;
-
- if (size * 1024 == virLogSize)
- return ret;
-
- virLogLock();
-
- oldsize = virLogSize;
- oldLogBuffer = virLogBuffer;
-
- if (INT_MAX / 1024 <= size) {
- pbm = "Requested log size of %d kB too large\n";
- ret = -1;
- goto error;
- }
-
- virLogSize = size * 1024;
- if (VIR_ALLOC_N_QUIET(virLogBuffer, virLogSize + 1) < 0) {
- pbm = "Failed to allocate debug buffer of %d kB\n";
- virLogBuffer = oldLogBuffer;
- virLogSize = oldsize;
- ret = -1;
- goto error;
- }
- VIR_FREE(oldLogBuffer);
- virLogLen = 0;
- virLogStart = 0;
- virLogEnd = 0;
-
-error:
- virLogUnlock();
- if (pbm)
- VIR_ERROR(pbm, size);
- return ret;
-}
-
-
-/**
* virLogReset:
*
* Reset the logging module to its default initial state
@@ -308,172 +218,11 @@ virLogReset(void)
virLogLock();
virLogResetFilters();
virLogResetOutputs();
- virLogLen = 0;
- virLogStart = 0;
- virLogEnd = 0;
virLogDefaultPriority = VIR_LOG_DEFAULT;
virLogUnlock();
return 0;
}

-
-/*
- * Store a string in the ring buffer
- */
-static void
-virLogStr(const char *str)
-{
- int tmp;
- int len;
-
- if ((str == NULL) || (virLogBuffer == NULL) || (virLogSize <= 0))
- return;
- len = strlen(str);
- if (len >= virLogSize)
- return;
-
- /*
- * copy the data and reset the end, we cycle over the end of the buffer
- */
- if (virLogEnd + len >= virLogSize) {
- tmp = virLogSize - virLogEnd;
- memcpy(&virLogBuffer[virLogEnd], str, tmp);
- memcpy(&virLogBuffer[0], &str[tmp], len - tmp);
- virLogEnd = len - tmp;
- } else {
- memcpy(&virLogBuffer[virLogEnd], str, len);
- virLogEnd += len;
- }
- virLogBuffer[virLogEnd] = 0;
- /*
- * Update the log length, and if full move the start index
- */
- virLogLen += len;
- if (virLogLen > virLogSize) {
- tmp = virLogLen - virLogSize;
- virLogLen = virLogSize;
- virLogStart += tmp;
- if (virLogStart >= virLogSize)
- virLogStart -= virLogSize;
- }
-}
-
-
-static void
-virLogDumpAllFD(const char *msg, int len)
-{
- size_t i;
- bool found = false;
-
- if (len <= 0)
- len = strlen(msg);
-
- for (i = 0; i < virLogNbOutputs; i++) {
- if (virLogOutputs[i].f == virLogOutputToFd) {
- int fd = (intptr_t) virLogOutputs[i].data;
-
- if (fd >= 0) {
- ignore_value(safewrite(fd, msg, len));
- found = true;
- }
- }
- }
- if (!found)
- ignore_value(safewrite(STDERR_FILENO, msg, len));
-}
-
-
-/**
- * virLogEmergencyDumpAll:
- * @signum: the signal number
- *
- * Emergency function called, possibly from a signal handler.
- * It need to output the debug ring buffer through the log
- * output which are safe to use from a signal handler.
- * In case none is found it is emitted to standard error.
- */
-void
-virLogEmergencyDumpAll(int signum)
-{
- int len;
- int oldLogStart, oldLogLen;
-
- switch (signum) {
-#ifdef SIGFPE
- case SIGFPE:
- virLogDumpAllFD("Caught signal Floating-point exception", -1);
- break;
-#endif
-#ifdef SIGSEGV
- case SIGSEGV:
- virLogDumpAllFD("Caught Segmentation violation", -1);
- break;
-#endif
-#ifdef SIGILL
- case SIGILL:
- virLogDumpAllFD("Caught illegal instruction", -1);
- break;
-#endif
-#ifdef SIGABRT
- case SIGABRT:
- virLogDumpAllFD("Caught abort signal", -1);
- break;
-#endif
-#ifdef SIGBUS
- case SIGBUS:
- virLogDumpAllFD("Caught bus error", -1);
- break;
-#endif
-#ifdef SIGUSR2
- case SIGUSR2:
- virLogDumpAllFD("Caught User-defined signal 2", -1);
- break;
-#endif
- default:
- virLogDumpAllFD("Caught unexpected signal", -1);
- break;
- }
- if ((virLogBuffer == NULL) || (virLogSize <= 0)) {
- virLogDumpAllFD(" internal log buffer deactivated\n", -1);
- return;
- }
-
- virLogDumpAllFD(" dumping internal log buffer:\n", -1);
- virLogDumpAllFD("\n\n ====== start of log =====\n\n", -1);
-
- /*
- * Since we can't lock the buffer safely from a signal handler
- * we mark it as empty in case of concurrent access, and proceed
- * with the data, at worse we will output something a bit weird
- * if another thread start logging messages at the same time.
- * Note that virLogStr() uses virLogEnd for the computations and
- * writes to the buffer and only then updates virLogLen and virLogStart
- * so it's best to reset it first.
- */
- oldLogStart = virLogStart;
- oldLogLen = virLogLen;
- virLogEnd = 0;
- virLogLen = 0;
- virLogStart = 0;
-
- while (oldLogLen > 0) {
- if (oldLogStart + oldLogLen < virLogSize) {
- virLogBuffer[oldLogStart + oldLogLen] = 0;
- virLogDumpAllFD(&virLogBuffer[oldLogStart], oldLogLen);
- oldLogStart += oldLogLen;
- oldLogLen = 0;
- } else {
- len = virLogSize - oldLogStart;
- virLogBuffer[virLogSize] = 0;
- virLogDumpAllFD(&virLogBuffer[oldLogStart], len);
- oldLogLen -= len;
- oldLogStart = 0;
- }
- }
- virLogDumpAllFD("\n\n ====== end of log =====\n\n", -1);
-}
-
-
/**
* virLogSetDefaultPriority:
* @priority: the default priority level
@@ -838,19 +587,12 @@ virLogVMessage(virLogSourcePtr source,
if (virTimeStringNowRaw(timestamp) < 0)
timestamp[0] = '\0';

+ virLogLock();
+
/*
- * Log based on defaults, first store in the history buffer,
- * then if emit push the message on the outputs defined, if none
+ * Push the message to the outputs defined, if none exist then
* use stderr.
- * NOTE: the locking is a single point of contention for multiple
- * threads, but avoid intermixing. Maybe set up locks per output
- * to improve paralellism.
*/
- virLogLock();
- virLogStr(timestamp);
- virLogStr(": ");
- virLogStr(msg);
-
for (i = 0; i < virLogNbOutputs; i++) {
if (priority >= virLogOutputs[i].priority) {
if (virLogOutputs[i].logVersion) {
diff --git a/src/util/virlog.h b/src/util/virlog.h
index b2d5edc..f62dd01 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -200,8 +200,6 @@ extern void virLogVMessage(virLogSourcePtr source,
virLogMetadataPtr metadata,
const char *fmt,
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
-extern int virLogSetBufferSize(int size);
-extern void virLogEmergencyDumpAll(int signum);

bool virLogProbablyLogMessage(const char *str);
--
1.8.5.3
Eric Blake
2014-03-07 18:27:53 UTC
Permalink
Post by Daniel P. Berrange
A earlier commit changed the global log buffer so that it only
records messages that are explicitly requested via the log
filters setting. This removes the performance burden, and
improves the signal/noise ratio for messages in the global
buffer. At the same time though, it is somewhat pointless, since
all the recorded log messages are already going to be sent to an
explicit log output like syslog, stderr or the journal. The
global log buffer is thus just duplicating this data on stderr
upon crash.
I still wonder if there is value on keeping the ring buffer for when
logging is not stderr. That is, if we dump to syslog by default but
ALSO dump the ring buffer to stderr, it may be easier to find what got
logged by reading stderr rather than having to hunt for the syslog. But
that's a weak argument.

If we commit to patch 1, then the logging ring really is duplicated
overhead, and I'm fine ditching it. You may want to get DV's opinion,
but I'm fine with this patch going in on the premise that patch 1 made
sense.

On the other hand, if patch 1 meets resistance, should we look at ways
to minimize printf() overhead? For example, a LOT of our overhead is
tied to the fact that we malloc() a lot when constructing the log
string. It may be possible to fine-tune things so that most (if not
all) log messages get computed into a static buffer (gnulib's asnprintf
is cool in how it avoids malloc in the common case if you provide a
large enough buffer, while still being robust to larger strings). It
won't kill as much overhead as what you killed by completely ditching
the ring buffer, but may still be enough improvement to merit keeping
the ring buffer around.

I'm not tied to the ring buffer - I still think that targetted logging
is easier to sift through than the signal-to-noise ratio of a ring
buffer dump. I'm just raising the question to make sure we think of the
issues before applying patch 1 and losing what might still be a useful
last-ditch debug aid for hard-to-reproduce crashes.
Post by Daniel P. Berrange
---
daemon/libvirtd-config.c | 3 -
daemon/libvirtd-config.h | 1 -
daemon/libvirtd.aug | 1 -
daemon/libvirtd.c | 2 -
daemon/libvirtd.conf | 7 -
daemon/test_libvirtd.aug.in | 1 -
docs/logging.html.in | 10 --
src/locking/lock_daemon.c | 2 -
src/locking/lock_daemon_config.c | 2 -
src/locking/lock_daemon_config.h | 1 -
src/locking/test_virtlockd.aug.in | 2 -
src/locking/virtlockd.aug | 1 -
src/locking/virtlockd.conf | 7 -
src/rpc/virnetserver.c | 45 -------
src/util/virlog.c | 264 +-------------------------------------
src/util/virlog.h | 2 -
16 files changed, 3 insertions(+), 348 deletions(-)
Wow - quite a lot tied up in the log ring buffer.
Post by Daniel P. Berrange
@@ -431,7 +429,6 @@ daemonConfigLoadOptions(struct daemonConfig *data,
GET_CONF_INT(conf, filename, log_level);
GET_CONF_STR(conf, filename, log_filters);
GET_CONF_STR(conf, filename, log_outputs);
- GET_CONF_INT(conf, filename, log_buffer_size);
Does augeas gracefully handle an option that is no longer used by
current libvirtd, but which mattered to older versions? That is, I
think you still have to support the option in the .conf file, and
document that it is now ignored, but guarantee that having it in the
.conf file doesn't cause a syntax error.
Post by Daniel P. Berrange
+++ b/daemon/libvirtd.aug
@@ -64,7 +64,6 @@ module Libvirtd =
let logging_entry = int_entry "log_level"
| str_entry "log_filters"
| str_entry "log_outputs"
- | int_entry "log_buffer_size"
That is, I don't think you can safely delete this line.
Post by Daniel P. Berrange
+++ b/daemon/libvirtd.conf
@@ -345,13 +345,6 @@
#log_outputs="3:syslog:libvirtd"
#
-# Log debug buffer size: default 64
-# The daemon keeps an internal debug log buffer which will be dumped in case
-# of crash or upon receiving a SIGUSR2 signal. This setting allows to override
-# the default buffer size in kilobytes.
-# If value is 0 or less the debug log buffer is deactivated
-#log_buffer_size = 64
And that you may need to mention that this variable is present but
ignored for backward compatibility, rather than deleting it altogether.
Post by Daniel P. Berrange
+++ b/src/locking/virtlockd.aug
@@ -27,7 +27,6 @@ module Virtlockd =
let logging_entry = int_entry "log_level"
| str_entry "log_filters"
| str_entry "log_outputs"
- | int_entry "log_buffer_size"
| int_entry "max_clients"
Same story.
Post by Daniel P. Berrange
-static void
-virNetServerFatalSignal(int sig, siginfo_t *siginfo ATTRIBUTE_UNUSED,
- void *context ATTRIBUTE_UNUSED)
-{
- struct sigaction sig_action;
- int origerrno;
-
- origerrno = errno;
- virLogEmergencyDumpAll(sig);
We may not be dumping the ring buffer any more, but I _still_ think it's
worth keeping this signal handler and dumping a message that we detected
a fatal crash, as well as pointing the user to go read the contents of
the logging files (and/or rerun libvirtd with more logging enabled). In
other words, delete the ring buffer, but DON'T delete this last-ditch
message to the user.
Post by Daniel P. Berrange
@@ -412,23 +384,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
sig_action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sig_action, NULL);
- /*
- * catch fatal errors to dump a log, also hook to USR2 for dynamic
- * debugging purposes or testing
Deleting USR2 handling makes sense, though.
Post by Daniel P. Berrange
-/**
- *
- * Emergency function called, possibly from a signal handler.
- * It need to output the debug ring buffer through the log
- * output which are safe to use from a signal handler.
- * In case none is found it is emitted to standard error.
- */
-void
-virLogEmergencyDumpAll(int signum)
-{
Again, I still think this function is useful - not to dump the ring
buffer, but to mention that we are going down and to check the logs and
give an address where to report the bug.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Daniel P. Berrange
2014-03-10 14:10:15 UTC
Permalink
Post by Eric Blake
Post by Daniel P. Berrange
A earlier commit changed the global log buffer so that it only
records messages that are explicitly requested via the log
filters setting. This removes the performance burden, and
improves the signal/noise ratio for messages in the global
buffer. At the same time though, it is somewhat pointless, since
all the recorded log messages are already going to be sent to an
explicit log output like syslog, stderr or the journal. The
global log buffer is thus just duplicating this data on stderr
upon crash.
I still wonder if there is value on keeping the ring buffer for when
logging is not stderr. That is, if we dump to syslog by default but
ALSO dump the ring buffer to stderr, it may be easier to find what got
logged by reading stderr rather than having to hunt for the syslog. But
that's a weak argument.
Yep, that is the only real reason I know of for keeping this. eg
syslog may be configured to throw away the libvirt logs...
Post by Eric Blake
If we commit to patch 1, then the logging ring really is duplicated
overhead, and I'm fine ditching it. You may want to get DV's opinion,
but I'm fine with this patch going in on the premise that patch 1 made
sense.
On the other hand, if patch 1 meets resistance, should we look at ways
to minimize printf() overhead? For example, a LOT of our overhead is
tied to the fact that we malloc() a lot when constructing the log
string. It may be possible to fine-tune things so that most (if not
all) log messages get computed into a static buffer (gnulib's asnprintf
is cool in how it avoids malloc in the common case if you provide a
large enough buffer, while still being robust to larger strings). It
won't kill as much overhead as what you killed by completely ditching
the ring buffer, but may still be enough improvement to merit keeping
the ring buffer around.
I'm not tied to the ring buffer - I still think that targetted logging
is easier to sift through than the signal-to-noise ratio of a ring
buffer dump. I'm just raising the question to make sure we think of the
issues before applying patch 1 and losing what might still be a useful
last-ditch debug aid for hard-to-reproduce crashes.
If we were to keep the global log buffer pretty much none of this
patch series is worthwhile, because as long as the global log buffer
exists the other performance improvements in this patch are dwarved
by the printf. Just minimizing malloc/printf overhead might let you
cut overhead in 1/2 or even in 1/4, but that still leaves massive
overhead behind. This patch series is reducing the execution time
in the test program from 1 minute 40 secs, to 3 secs.

I don't see any optimization of printf/malloc being able to get us
anywhere near this kind of level of improvement.
Post by Eric Blake
Post by Daniel P. Berrange
@@ -431,7 +429,6 @@ daemonConfigLoadOptions(struct daemonConfig *data,
GET_CONF_INT(conf, filename, log_level);
GET_CONF_STR(conf, filename, log_filters);
GET_CONF_STR(conf, filename, log_outputs);
- GET_CONF_INT(conf, filename, log_buffer_size);
Does augeas gracefully handle an option that is no longer used by
current libvirtd, but which mattered to older versions? That is, I
think you still have to support the option in the .conf file, and
document that it is now ignored, but guarantee that having it in the
.conf file doesn't cause a syntax error.
If the user had set this config file, and they now try to parse the
file with augeas, it will raise an error.
Post by Eric Blake
Post by Daniel P. Berrange
+++ b/daemon/libvirtd.aug
@@ -64,7 +64,6 @@ module Libvirtd =
let logging_entry = int_entry "log_level"
| str_entry "log_filters"
| str_entry "log_outputs"
- | int_entry "log_buffer_size"
That is, I don't think you can safely delete this line.
I guess so.
Post by Eric Blake
Post by Daniel P. Berrange
+++ b/daemon/libvirtd.conf
@@ -345,13 +345,6 @@
#log_outputs="3:syslog:libvirtd"
#
-# Log debug buffer size: default 64
-# The daemon keeps an internal debug log buffer which will be dumped in case
-# of crash or upon receiving a SIGUSR2 signal. This setting allows to override
-# the default buffer size in kilobytes.
-# If value is 0 or less the debug log buffer is deactivated
-#log_buffer_size = 64
And that you may need to mention that this variable is present but
ignored for backward compatibility, rather than deleting it altogether.
Ok.
Post by Eric Blake
Post by Daniel P. Berrange
-static void
-virNetServerFatalSignal(int sig, siginfo_t *siginfo ATTRIBUTE_UNUSED,
- void *context ATTRIBUTE_UNUSED)
-{
- struct sigaction sig_action;
- int origerrno;
-
- origerrno = errno;
- virLogEmergencyDumpAll(sig);
We may not be dumping the ring buffer any more, but I _still_ think it's
worth keeping this signal handler and dumping a message that we detected
a fatal crash, as well as pointing the user to go read the contents of
the logging files (and/or rerun libvirtd with more logging enabled). In
other words, delete the ring buffer, but DON'T delete this last-ditch
message to the user.
But if you don't install any SEGV signal handler, the kernel/glibc default
will already print

Segmentation fault (core dumped)

So what more would libvirt do ?

I'm open to suggestions of what else libvirt could usefully (& safely)
add to this, but I couldn't think of anything worthwhile.


Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Eric Blake
2014-03-10 15:43:27 UTC
Permalink
Post by Daniel P. Berrange
If we were to keep the global log buffer pretty much none of this
patch series is worthwhile, because as long as the global log buffer
exists the other performance improvements in this patch are dwarved
by the printf. Just minimizing malloc/printf overhead might let you
cut overhead in 1/2 or even in 1/4, but that still leaves massive
overhead behind. This patch series is reducing the execution time
in the test program from 1 minute 40 secs, to 3 secs.
I don't see any optimization of printf/malloc being able to get us
anywhere near this kind of level of improvement.
I agree that killing the printfs into the ring buffer makes sense - just
waiting for anyone else to express an opinion.
Post by Daniel P. Berrange
Post by Eric Blake
We may not be dumping the ring buffer any more, but I _still_ think it's
worth keeping this signal handler and dumping a message that we detected
a fatal crash, as well as pointing the user to go read the contents of
the logging files (and/or rerun libvirtd with more logging enabled). In
other words, delete the ring buffer, but DON'T delete this last-ditch
message to the user.
But if you don't install any SEGV signal handler, the kernel/glibc default
will already print
Segmentation fault (core dumped)
So what more would libvirt do ?
Print a nicer message, something like:

Fatal signal detected; please report this bug to libvir-***@redhat.com:
Segmentation fault
Post by Daniel P. Berrange
I'm open to suggestions of what else libvirt could usefully (& safely)
add to this, but I couldn't think of anything worthwhile.
Bug reporting address is nice. Backtrace would be useful, but hard to
prove that it would work safely, and may be non-portable outside of linux).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Continue reading on narkive:
Loading...