[libvirt] [PATCH 0/7 v2] Remove overhead of disabled logging calls

A v2 of https://www.redhat.com/archives/libvir-list/2014-March/msg00124.html 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 cfg.mk | 3 + daemon/libvirtd-config.c | 5 +- daemon/libvirtd-config.h | 1 - daemon/libvirtd.c | 5 +- daemon/libvirtd.conf | 10 +- daemon/libvirtd.h | 1 - daemon/remote.c | 3 + daemon/stream.c | 2 + 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 | 72 ------ src/libvirt-lxc.c | 2 + src/libvirt-qemu.c | 2 + src/libvirt.c | 2 + src/libvirt_private.syms | 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/virtlockd.conf | 10 +- 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 | 19 +- 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 | 381 +++++------------------------- 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 + 238 files changed, 655 insertions(+), 554 deletions(-) create mode 100644 src/util/virprobe.h -- 1.8.5.3

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 existence 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 to do 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 <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

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
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 existence 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 to do 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 <berrange@redhat.com> --- src/util/virlog.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
No one else has countered the loss of the crash buffer, so I think we're good to make this change. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

The error reporting code will invoke a callback when any error is raised and the default callback will print to stderr. The virRaiseErrorFull method also sends all error messages on to the logging code, which also prints to stderr by default. To avoid duplicated data on stderr, the logging code has some logic to skip emission when no log outputs are configured, which checks whether the virLogSource == VIR_LOG_FROM_ERROR. Meanwhile the libvirtd daemon can register another callback which is used to reduce log message priority from error to a lower level. When this is used we do want messages to end up on stderr, so the error code will conditionally use either VIR_LOG_FROM_FILE or VIR_LOG_FROM_ERROR depending on whether such a callback is provided. This will all complicate later refactoring. By pushing the checks for whether a log output is present up a level into the error code, the special cases can be isolated in one place. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virerror.c | 17 +++++++++++++---- src/util/virlog.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/util/virerror.c b/src/util/virerror.c index 820e1ad..f85f6b3 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -709,10 +709,19 @@ 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 the daemon has set + * a priority filter though, we should always forward + * all errors to the logging code. + */ + if (virLogGetNbOutputs() > 0 || + virErrorLogPriorityFilter) + virLogMessage(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

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
The error reporting code will invoke a callback when any error is raised and the default callback will print to stderr. The virRaiseErrorFull method also sends all error messages on to the logging code, which also prints to stderr by default. To avoid duplicated data on stderr, the logging code has some logic to skip emission when no log outputs are configured, which checks whether the virLogSource == VIR_LOG_FROM_ERROR.
Meanwhile the libvirtd daemon can register another callback which is used to reduce log message priority from error to a lower level. When this is used we do want messages to end up on stderr, so the error code will conditionally use either VIR_LOG_FROM_FILE or VIR_LOG_FROM_ERROR depending on whether such a callback is provided.
This will all complicate later refactoring. By pushing the checks for whether a log output is present up a level into the error code, the special cases can be isolated in one place.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virerror.c | 17 +++++++++++++---- src/util/virlog.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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 <berrange@redhat.com> --- daemon/remote.c | 1 + src/internal.h | 72 ------------------------------- 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(+), 72 deletions(-) create mode 100644 src/util/virprobe.h diff --git a/daemon/remote.c b/daemon/remote.c index b48d456..8bb4ed2 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 5a38448..0b36de9 100644 --- a/src/internal.h +++ b/src/internal.h @@ -366,78 +366,6 @@ # 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 - /* Specific error values for use in forwarding programs such as * virt-login-shell; these values match what GNU env does. */ enum { 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 7d6b88b..4da2011 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 f4992f1..6610ba4 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 327768b..6caae61 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..3950e49 --- /dev/null +++ b/src/util/virprobe.h @@ -0,0 +1,100 @@ +/* + * virprobe.h: dynamic operation tracing + * + * Copyright (C) 2006-2014 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

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
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 <berrange@redhat.com> --- daemon/remote.c | 1 + src/internal.h | 72 ------------------------------- 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(+), 72 deletions(-) create mode 100644 src/util/virprobe.h
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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 <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 80070c5..993f76a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1442,6 +1442,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 cae25e0..6811d2e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2767,7 +2767,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..ac787f8 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, filename, linenr, funcname, NULL, "success=yes %s", str); else - virLogMessage(VIR_LOG_FROM_AUDIT, VIR_LOG_WARN, + virLogMessage(source, VIR_LOG_WARN, 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 f85f6b3..4da8bcf 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -718,7 +718,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED, */ if (virLogGetNbOutputs() > 0 || virErrorLogPriorityFilter) - virLogMessage(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..4ac4c47 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(virLogSourcePtr 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 3950e49..fe3c422 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 ede6239..f5c815f 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

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
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 <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(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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 <berrange@redhat.com> --- cfg.mk | 3 +++ 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 ++ 230 files changed, 435 insertions(+), 48 deletions(-) diff --git a/cfg.mk b/cfg.mk index 2a8957a..7d89515 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1033,3 +1033,6 @@ exclude_file_name_regexp--sc_prohibit_int_ijk = \ exclude_file_name_regexp--sc_prohibit_getenv = \ ^tests/.*\.[ch]$$ + +exclude_file_name_regexp--sc_avoid_attribute_unused_in_header = \ + ^src/util/virlog\.h$$ 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 72f0e81..6bee3dd 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 8bb4ed2..de75de1 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 d9ebc49..70db860 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 ee85680..f5433f3 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 e1b0115..85ee716 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 2379aa7..fa37ede 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 5ceca8a..697c85f 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 ac323d0..cd2aaea 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 33d941d..4867b4a 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 04d62b8..8813f6f 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 abfb93f..f31b556 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -39,6 +39,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 a385935..cb41921 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 993f76a..80070c5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1442,7 +1442,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..f27bdf9 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_config"); + /* 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 e034051..b6c788a 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 b7248df..bc319d0 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 fcdcb2d..2f4121c 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 9e31afb..d2a8062 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 2e89d07..3925dcd 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 9d6cc90..6ed20ef 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 e576dc4..bf96d6b 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 393f397..7efaa30 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 2cba3ca..626a1e2 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 e819256..d97b39f 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 6811d2e..6009dc7 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 775e139..6bb9ee7 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 20fd62d..8c68db2 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 8a54b8a..24af61d 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_NB_MEM_PARAM 3 #define QEMU_NB_BLOCK_IO_TUNE_PARAM 6 diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index e4f6b1b..094e599 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 4da2011..94e6365 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 6610ba4..efb3654 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 6caae61..f95a101 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 bcabfcd..198d6a2 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 a74a91c..f7b67ba 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 b261773..48e4a6c 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 bab02dd..edb7cd0 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 ada6c48..2628005 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 1ac48e6..667fb06 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 5d0ed32..897911e 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 bc52474..51d5a9f 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 4397257..572d855 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 7dbff6c..f3e18ba 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 986f215..22a0d54 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 ac787f8..33ed2f6 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 db4166f..a3bbc78 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 9bddbfc..e3236d8 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 ce5e813..df94658 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 4da8bcf..9e05adc 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 6da564b..5fe21d7 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 bd6adcf..351fdd7 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 9e03cc4..83793fa 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 02b5f3f..5125ad0 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 90a39bb..6e8ba27 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 4ac4c47..3a4abd1 100644 --- a/src/util/virlog.h +++ b/src/util/virlog.h @@ -51,7 +51,15 @@ struct _virLogSource { const char *name; }; -extern virLogSource virLogSelf; +/* + * ATTRIBUTE_UNUSED is to make gcc keep quiet if all the + * log statements in a file are conditionally disabled + * at compile time due to configure options. + */ +# define VIR_LOG_INIT(n) \ + static ATTRIBUTE_UNUSED virLogSource virLogSelf = { \ + .name = "" n "", \ + }; /* * 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 62d4774..834bee3 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 e6133a9..0874456 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 3620041..5032886 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -55,6 +55,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 802f515..81a294d 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 d263c58..f2eeb8c 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 90a0061..1b6d76f 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 1880b22..54ad1a2 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 a58509b..75ba510 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 8037b2e..9b2d0e8 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 2d02e6e..8040bc3 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 1319c74..01d1ca1 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 3505f8c..d52f9f9 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 feb5366..4ea2b72 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 f5c815f..e21e2f4 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 9fcdcd3..edfe181 100644 --- a/tests/viridentitytest.c +++ b/tests/viridentitytest.c @@ -37,6 +37,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 fd48c11..a6a5d6d 100644 --- a/tests/virportallocatortest.c +++ b/tests/virportallocatortest.c @@ -118,6 +118,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 9752d12..82411ff 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 c664a3a..34a0578 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

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
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 <berrange@redhat.com> ---
230 files changed, 435 insertions(+), 48 deletions(-)
Big, but mostly mechanical, and the fact that it compiles is good.
diff --git a/cfg.mk b/cfg.mk index 2a8957a..7d89515 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1033,3 +1033,6 @@ exclude_file_name_regexp--sc_prohibit_int_ijk = \
exclude_file_name_regexp--sc_prohibit_getenv = \ ^tests/.*\.[ch]$$ + +exclude_file_name_regexp--sc_avoid_attribute_unused_in_header = \ + ^src/util/virlog\.h$$
Yeah, I can see where that comes from.
+++ b/src/util/virlog.h @@ -51,7 +51,15 @@ struct _virLogSource { const char *name; };
-extern virLogSource virLogSelf; +/* + * ATTRIBUTE_UNUSED is to make gcc keep quiet if all the + * log statements in a file are conditionally disabled + * at compile time due to configure options. + */ +# define VIR_LOG_INIT(n) \ + static ATTRIBUTE_UNUSED virLogSource virLogSelf = { \ + .name = "" n "", \ + };
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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 based on the virLogSource object name. The virLogSource struct is extended to contain '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 since all writes a protected by a global mutex, it is believed that worst case behaviour where the fields are read concurrently with being written would merely result in an mistaken emission 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 to do 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 <berrange@redhat.com> --- src/util/virlog.c | 83 ++++++++++++++++++++++++++----------------------------- src/util/virlog.h | 6 ++++ 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 6a20b89..21b82da 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,30 @@ 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. + * Since writes to the variable are serialized on + * virLogLock, 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 emission. */ - 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 3a4abd1..c73867a 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; }; /* @@ -59,6 +62,9 @@ struct _virLogSource { # define VIR_LOG_INIT(n) \ static ATTRIBUTE_UNUSED virLogSource virLogSelf = { \ .name = "" n "", \ + .priority = VIR_LOG_ERROR, \ + .serial = 0, \ + .flags = 0, \ }; /* -- 1.8.5.3

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
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.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virlog.c | 83 ++++++++++++++++++++++++++----------------------------- src/util/virlog.h | 6 ++++ 2 files changed, 45 insertions(+), 44 deletions(-)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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 <berrange@redhat.com> --- daemon/libvirtd-config.c | 3 - daemon/libvirtd-config.h | 1 - daemon/libvirtd.c | 2 - daemon/libvirtd.conf | 10 +- docs/logging.html.in | 10 -- src/libvirt_private.syms | 2 - src/locking/lock_daemon.c | 2 - src/locking/lock_daemon_config.c | 2 - src/locking/lock_daemon_config.h | 1 - src/locking/virtlockd.conf | 10 +- src/rpc/virnetserver.c | 45 ------- src/util/virlog.c | 264 +-------------------------------------- src/util/virlog.h | 2 - 13 files changed, 13 insertions(+), 341 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.c b/daemon/libvirtd.c index 6bee3dd..7a44897 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..5fc9e91 100644 --- a/daemon/libvirtd.conf +++ b/daemon/libvirtd.conf @@ -345,11 +345,11 @@ #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 debug buffer size: +# +# This configuration option is no longer used, since the global +# log buffer functionality has been removed. Please configure +# suitable log_outputs/log_filters settings to obtain logs. #log_buffer_size = 64 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/libvirt_private.syms b/src/libvirt_private.syms index 80070c5..acf8122 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1428,7 +1428,6 @@ virLockSpaceReleaseResourcesForOwner; # util/virlog.h virLogDefineFilter; virLogDefineOutput; -virLogEmergencyDumpAll; virLogGetDefaultPriority; virLogGetFilters; virLogGetNbFilters; @@ -1442,7 +1441,6 @@ virLogParseOutputs; virLogPriorityFromSyslog; virLogProbablyLogMessage; virLogReset; -virLogSetBufferSize; virLogSetDefaultPriority; virLogSetFromEnv; virLogUnlock; 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 f27bdf9..3a9f2e3 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/virtlockd.conf b/src/locking/virtlockd.conf index 652e156..4c935d0 100644 --- a/src/locking/virtlockd.conf +++ b/src/locking/virtlockd.conf @@ -52,11 +52,11 @@ #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 debug buffer size: +# +# This configuration option is no longer used, since the global +# log buffer functionality has been removed. Please configure +# suitable log_outputs/log_filters settings to obtain logs. #log_buffer_size = 64 # The maximum number of concurrent client connections to allow diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 198d6a2..70d80d2 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 21b82da..5d4d3c7 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 @@ -840,19 +589,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 c73867a..5b38891 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

On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
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 <berrange@redhat.com> --- daemon/libvirtd-config.c | 3 - daemon/libvirtd-config.h | 1 - daemon/libvirtd.c | 2 - daemon/libvirtd.conf | 10 +- docs/logging.html.in | 10 -- src/libvirt_private.syms | 2 - src/locking/lock_daemon.c | 2 - src/locking/lock_daemon_config.c | 2 - src/locking/lock_daemon_config.h | 1 - src/locking/virtlockd.conf | 10 +- src/rpc/virnetserver.c | 45 ------- src/util/virlog.c | 264 +-------------------------------------- src/util/virlog.h | 2 - 13 files changed, 13 insertions(+), 341 deletions(-)
+++ b/daemon/libvirtd.conf @@ -345,11 +345,11 @@ #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 debug buffer size: +# +# This configuration option is no longer used, since the global +# log buffer functionality has been removed. Please configure +# suitable log_outputs/log_filters settings to obtain logs. #log_buffer_size = 64
Yay, this fixes my concern from v1.
@@ -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
This says we now let fatal errors be handled normally; but the old code merely tried to dump the log then re-raise the fatal error. So I can live with this (I still think it might be nicer to try and output a bug-reporting address before crashing, but I'm not going to insist). ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake