[PATCH] maint: kill all remaining uses of old DEBUG macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Done mechanically with:
$ git grep -l '\bDEBUG0\? *(' | xargs -L1 sed -i 's/\bDEBUG0\? *(/VIR_&/'

followed by manual deletion of qemudDebug in daemon/libvirtd.c, along
with a single 'make syntax-check' fallout in the same file, and the
actual deletion in src/util/logging.h.

* src/util/logging.h (DEBUG, DEBUG0): Delete.
* daemon/libvirtd.h (qemudDebug): Likewise.
* global: Change remaining clients over to VIR_DEBUG counterpart.
---

Obviously a post-0.8.8 cleanup, but I might as well get feedback
on it now.

 daemon/dispatch.c                                  |    8 +-
 daemon/event.c                                     |   12 +-
 daemon/libvirtd.c                                  |   32 +-
 daemon/libvirtd.h                                  |    4 +-
 daemon/mdns.c                                      |    2 +-
 daemon/remote.c                                    |    2 +-
 daemon/stream.c                                    |   24 +-
 .../0004-implement-the-public-APIs.patch           |    4 +-
 examples/domain-events/events-c/event-test.c       |   28 +-
 src/datatypes.c                                    |   72 ++--
 src/driver.c                                       |    2 +-
 src/libvirt-qemu.c                                 |    2 +-
 src/libvirt.c                                      |  398 ++++++++++----------
 src/lxc/lxc_container.c                            |   16 +-
 src/lxc/lxc_controller.c                           |    2 +-
 src/lxc/lxc_driver.c                               |    8 +-
 src/lxc/veth.c                                     |   10 +-
 src/node_device/node_device_hal.c                  |   18 +-
 src/qemu/qemu_driver.c                             |   44 ++--
 src/qemu/qemu_monitor.c                            |  104 +++---
 src/qemu/qemu_monitor_json.c                       |    2 +-
 src/qemu/qemu_monitor_text.c                       |   18 +-
 src/remote/remote_driver.c                         |  112 +++---
 src/security/security_dac.c                        |    2 +-
 src/storage/storage_backend_disk.c                 |    8 +-
 src/test/test_driver.c                             |    2 +-
 src/util/logging.h                                 |   10 +-
 src/util/util.c                                    |    6 +-
 src/vbox/vbox_driver.c                             |   16 +-
 src/vbox/vbox_tmpl.c                               |  258 +++++++-------
 src/xen/xen_driver.c                               |   28 +-
 src/xen/xen_hypervisor.c                           |   20 +-
 src/xen/xen_inotify.c                              |   20 +-
 src/xen/xend_internal.c                            |   10 +-
 src/xen/xm_internal.c                              |   12 +-
 src/xen/xs_internal.c                              |   12 +-
 36 files changed, 660 insertions(+), 668 deletions(-)

diff --git a/daemon/dispatch.c b/daemon/dispatch.c
index bf2ac73..3397a00 100644
--- a/daemon/dispatch.c
+++ b/daemon/dispatch.c
@@ -141,7 +141,7 @@ remoteSerializeError(struct qemud_client *client,
     unsigned int len;
     struct qemud_client_message *msg = NULL;

-    DEBUG("prog=%d ver=%d proc=%d type=%d serial=%d, msg=%s",
+    VIR_DEBUG("prog=%d ver=%d proc=%d type=%d serial=%d, msg=%s",
           program, version, procedure, type, serial,
           rerr->message ? *rerr->message : "(none)");

@@ -372,7 +372,7 @@ remoteDispatchClientRequest(struct qemud_server *server,
     remote_error rerr;
     bool qemu_call;

-    DEBUG("prog=%d ver=%d type=%d status=%d serial=%d proc=%d",
+    VIR_DEBUG("prog=%d ver=%d type=%d status=%d serial=%d proc=%d",
           msg->hdr.prog, msg->hdr.vers, msg->hdr.type,
           msg->hdr.status, msg->hdr.serial, msg->hdr.proc);

@@ -631,7 +631,7 @@ remoteSendStreamData(struct qemud_client *client,
     struct qemud_client_message *msg;
     XDR xdr;

-    DEBUG("client=%p stream=%p data=%p len=%d", client, stream, data, len);
+    VIR_DEBUG("client=%p stream=%p data=%p len=%d", client, stream, data, len);

     if (VIR_ALLOC(msg) < 0) {
         return -1;
@@ -682,7 +682,7 @@ remoteSendStreamData(struct qemud_client *client,

         xdr_destroy (&xdr);

-        DEBUG("Total %d", msg->bufferOffset);
+        VIR_DEBUG("Total %d", msg->bufferOffset);
     }
     if (data)
         msg->streamTX = 1;
diff --git a/daemon/event.c b/daemon/event.c
index 4c97fb9..1a31717 100644
--- a/daemon/event.c
+++ b/daemon/event.c
@@ -37,7 +37,7 @@
 #include "util.h"
 #include "ignore-value.h"

-#define EVENT_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
+#define EVENT_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)

 static int virEventInterruptLocked(void);

@@ -390,7 +390,7 @@ static int virEventDispatchTimeouts(void) {
     int i;
     /* Save this now - it may be changed during dispatch */
     int ntimeouts = eventLoop.timeoutsCount;
-    DEBUG("Dispatch %d", ntimeouts);
+    VIR_DEBUG("Dispatch %d", ntimeouts);

     if (gettimeofday(&tv, NULL) < 0) {
         return -1;
@@ -435,7 +435,7 @@ static int virEventDispatchTimeouts(void) {
  */
 static int virEventDispatchHandles(int nfds, struct pollfd *fds) {
     int i, n;
-    DEBUG("Dispatch %d", nfds);
+    VIR_DEBUG("Dispatch %d", nfds);

     /* NB, use nfds not eventLoop.handlesCount, because new
      * fds might be added on end of list, and they're not
@@ -449,7 +449,7 @@ static int virEventDispatchHandles(int nfds, struct pollfd *fds) {
         if (i == eventLoop.handlesCount)
             break;

-        DEBUG("i=%d w=%d", i, eventLoop.handles[i].watch);
+        VIR_DEBUG("i=%d w=%d", i, eventLoop.handles[i].watch);
         if (eventLoop.handles[i].deleted) {
             EVENT_DEBUG("Skip deleted n=%d w=%d f=%d", i,
                         eventLoop.handles[i].watch, eventLoop.handles[i].fd);
@@ -480,7 +480,7 @@ static int virEventDispatchHandles(int nfds, struct pollfd *fds) {
 static int virEventCleanupTimeouts(void) {
     int i;
     size_t gap;
-    DEBUG("Cleanup %zu", eventLoop.timeoutsCount);
+    VIR_DEBUG("Cleanup %zu", eventLoop.timeoutsCount);

     /* Remove deleted entries, shuffling down remaining
      * entries as needed to form contiguous series
@@ -523,7 +523,7 @@ static int virEventCleanupTimeouts(void) {
 static int virEventCleanupHandles(void) {
     int i;
     size_t gap;
-    DEBUG("Cleanup %zu", eventLoop.handlesCount);
+    VIR_DEBUG("Cleanup %zu", eventLoop.handlesCount);

     /* Remove deleted entries, shuffling down remaining
      * entries as needed to form contiguous series
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index f4b3327..b2e5e20 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1,7 +1,7 @@
 /*
  * libvirtd.c: daemon start of day, guest process & i/o management
  *
- * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -310,7 +310,7 @@ remoteInitializeGnuTLS (void)
         if (remoteCheckCertFile("CA certificate", ca_file) < 0)
             return -1;

-        qemudDebug ("loading CA cert from %s", ca_file);
+        VIR_DEBUG("loading CA cert from %s", ca_file);
         err = gnutls_certificate_set_x509_trust_file (x509_cred, ca_file,
                                                       GNUTLS_X509_FMT_PEM);
         if (err < 0) {
@@ -324,7 +324,7 @@ remoteInitializeGnuTLS (void)
         if (remoteCheckCertFile("CA revocation list", crl_file) < 0)
             return -1;

-        DEBUG("loading CRL from %s", crl_file);
+        VIR_DEBUG("loading CRL from %s", crl_file);
         err = gnutls_certificate_set_x509_crl_file (x509_cred, crl_file,
                                                     GNUTLS_X509_FMT_PEM);
         if (err < 0) {
@@ -339,7 +339,7 @@ remoteInitializeGnuTLS (void)
             return -1;
         if (remoteCheckCertFile("server key", key_file) < 0)
             return -1;
-        DEBUG("loading cert and key from %s and %s", cert_file, key_file);
+        VIR_DEBUG("loading cert and key from %s and %s", cert_file, key_file);
         err =
             gnutls_certificate_set_x509_key_file (x509_cred,
                                                   cert_file, key_file,
@@ -1150,7 +1150,7 @@ remoteCheckDN (const char *dname)
     }

     /* Print the client's DN. */
-    DEBUG(_("remoteCheckDN: failed: client DN is %s"), dname);
+    VIR_DEBUG("remoteCheckDN: failed: client DN is %s", dname);

     return 0; /* Not found. */
 }
@@ -1531,7 +1531,7 @@ void qemudDispatchClientFailure(struct qemud_client *client) {

         for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++) {
             if (client->domainEventCallbackID[i] != -1) {
-                DEBUG("Deregistering to relay remote events %d", i);
+                VIR_DEBUG("Deregistering to relay remote events %d", i);
                 virConnectDomainEventDeregisterAny(client->conn,
                                                    client->domainEventCallbackID[i]);
             }
@@ -1678,7 +1678,7 @@ static ssize_t qemudClientReadBuf(struct qemud_client *client,
         return -1;
     }

-    /*qemudDebug ("qemudClientRead: len = %d", len);*/
+    /* VIR_DEBUG("qemudClientRead: len = %d", len);*/

     if (!client->tlssession) {
         char ebuf[1024];
@@ -1812,7 +1812,7 @@ static ssize_t qemudClientRead(struct qemud_client *client) {
  */
 static void qemudDispatchClientRead(struct qemud_server *server,
                                     struct qemud_client *client) {
-    /*qemudDebug ("qemudDispatchClientRead: mode = %d", client->mode);*/
+    /* VIR_DEBUG("qemudDispatchClientRead: mode = %d", client->mode);*/

 readmore:
     if (qemudClientRead(client) < 0)
@@ -1830,14 +1830,14 @@ readmore:

         if (!xdr_u_int(&x, &len)) {
             xdr_destroy (&x);
-            DEBUG0("Failed to decode packet length");
+            VIR_DEBUG0("Failed to decode packet length");
             qemudDispatchClientFailure(client);
             return;
         }
         xdr_destroy (&x);

         if (len < REMOTE_MESSAGE_HEADER_XDR_LEN) {
-            DEBUG("Packet length %u too small", len);
+            VIR_DEBUG("Packet length %u too small", len);
             qemudDispatchClientFailure(client);
             return;
         }
@@ -1846,7 +1846,7 @@ readmore:
         len -= REMOTE_MESSAGE_HEADER_XDR_LEN;

         if (len > REMOTE_MESSAGE_MAX) {
-            DEBUG("Packet length %u too large", len);
+            VIR_DEBUG("Packet length %u too large", len);
             qemudDispatchClientFailure(client);
             return;
         }
@@ -2283,10 +2283,10 @@ static void qemudInactiveTimer(int timerid, void *data) {

     if (virStateActive() ||
         server->clients) {
-        DEBUG0("Timer expired but still active, not shutting down");
+        VIR_DEBUG0("Timer expired but still active, not shutting down");
         virEventUpdateTimeoutImpl(timerid, -1);
     } else {
-        DEBUG0("Timer expired and inactive, shutting down");
+        VIR_DEBUG0("Timer expired and inactive, shutting down");
         server->quitEventThread = 1;
     }
 }
@@ -2357,14 +2357,14 @@ static void *qemudRunLoop(void *opaque) {
         if (timeout > 0) {
             if (timerActive) {
                 if (server->clients) {
-                    DEBUG("Deactivating shutdown timer %d", timerid);
+                    VIR_DEBUG("Deactivating shutdown timer %d", timerid);
                     virEventUpdateTimeoutImpl(timerid, -1);
                     timerActive = 0;
                 }
             } else {
                 if (!virStateActive() &&
                     !server->clients) {
-                    DEBUG("Activating shutdown timer %d", timerid);
+                    VIR_DEBUG("Activating shutdown timer %d", timerid);
                     virEventUpdateTimeoutImpl(timerid, timeout * 1000);
                     timerActive = 1;
                 }
@@ -2374,7 +2374,7 @@ static void *qemudRunLoop(void *opaque) {
         virMutexUnlock(&server->lock);
         if (qemudOneLoop() < 0) {
             virMutexLock(&server->lock);
-            DEBUG0("Loop iteration error, exiting");
+            VIR_DEBUG0("Loop iteration error, exiting");
             break;
         }
         virMutexLock(&server->lock);
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index af20e56..7da3cfd 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -1,7 +1,7 @@
 /*
  * libvirtd.h: daemon data structure definitions
  *
- * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -128,8 +128,6 @@
 #  endif
 # endif

-# define qemudDebug DEBUG
-
 /* Whether we're passing reads & writes through a sasl SSF */
 enum qemud_sasl_ssf {
     QEMUD_SASL_SSF_NONE = 0,
diff --git a/daemon/mdns.c b/daemon/mdns.c
index ae8dc40..8be3aa9 100644
--- a/daemon/mdns.c
+++ b/daemon/mdns.c
@@ -42,7 +42,7 @@
 #include "event.h"
 #include "memory.h"

-#define AVAHI_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
+#define AVAHI_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)

 struct libvirtd_mdns_entry {
     char *type;
diff --git a/daemon/remote.c b/daemon/remote.c
index d53b466..c5509ad 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -62,7 +62,7 @@
 #include "libvirt/libvirt-qemu.h"

 #define VIR_FROM_THIS VIR_FROM_REMOTE
-#define REMOTE_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
+#define REMOTE_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)

 static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
 static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
diff --git a/daemon/stream.c b/daemon/stream.c
index cac54ea..967aea2 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -82,7 +82,7 @@ remoteStreamEvent(virStreamPtr st, int events, void *opaque)
         goto cleanup;
     }

-    DEBUG("st=%p events=%d", st, events);
+    VIR_DEBUG("st=%p events=%d", st, events);

     if (events & VIR_STREAM_EVENT_WRITABLE) {
         if (remoteStreamHandleWrite(client, stream) < 0) {
@@ -149,7 +149,7 @@ remoteStreamFilter(struct qemud_client *client,
     if (msg->hdr.serial == stream->serial &&
         msg->hdr.proc == stream->procedure &&
         msg->hdr.type == REMOTE_STREAM) {
-        DEBUG("Incoming rx=%p serial=%d proc=%d status=%d",
+        VIR_DEBUG("Incoming rx=%p serial=%d proc=%d status=%d",
               stream->rx, msg->hdr.proc, msg->hdr.serial, msg->hdr.status);

         /* If there are queued packets, we need to queue all further
@@ -207,7 +207,7 @@ remoteCreateClientStream(virConnectPtr conn,
 {
     struct qemud_client_stream *stream;

-    DEBUG("proc=%d serial=%d", hdr->proc, hdr->serial);
+    VIR_DEBUG("proc=%d serial=%d", hdr->proc, hdr->serial);

     if (VIR_ALLOC(stream) < 0)
         return NULL;
@@ -241,7 +241,7 @@ void remoteFreeClientStream(struct qemud_client *client,
     if (!stream)
         return;

-    DEBUG("proc=%d serial=%d", stream->procedure, stream->serial);
+    VIR_DEBUG("proc=%d serial=%d", stream->procedure, stream->serial);

     msg = stream->rx;
     while (msg) {
@@ -265,7 +265,7 @@ int remoteAddClientStream(struct qemud_client *client,
 {
     struct qemud_client_stream *tmp = client->streams;

-    DEBUG("client=%p proc=%d serial=%d", client, stream->procedure, stream->serial);
+    VIR_DEBUG("client=%p proc=%d serial=%d", client, stream->procedure, stream->serial);

     if (virStreamEventAddCallback(stream->st, 0,
                                   remoteStreamEvent, client, NULL) < 0)
@@ -328,7 +328,7 @@ int
 remoteRemoveClientStream(struct qemud_client *client,
                          struct qemud_client_stream *stream)
 {
-    DEBUG("client=%p proc=%d serial=%d", client, stream->procedure, stream->serial);
+    VIR_DEBUG("client=%p proc=%d serial=%d", client, stream->procedure, stream->serial);

     struct qemud_client_stream *curr = client->streams;
     struct qemud_client_stream *prev = NULL;
@@ -381,7 +381,7 @@ remoteStreamHandleWriteData(struct qemud_client *client,
     remote_error rerr;
     int ret;

-    DEBUG("stream=%p proc=%d serial=%d len=%d offset=%d",
+    VIR_DEBUG("stream=%p proc=%d serial=%d len=%d offset=%d",
           stream, msg->hdr.proc, msg->hdr.serial, msg->bufferLength, msg->bufferOffset);

     memset(&rerr, 0, sizeof rerr);
@@ -426,7 +426,7 @@ remoteStreamHandleFinish(struct qemud_client *client,
     remote_error rerr;
     int ret;

-    DEBUG("stream=%p proc=%d serial=%d",
+    VIR_DEBUG("stream=%p proc=%d serial=%d",
           stream, msg->hdr.proc, msg->hdr.serial);

     memset(&rerr, 0, sizeof rerr);
@@ -460,7 +460,7 @@ remoteStreamHandleAbort(struct qemud_client *client,
 {
     remote_error rerr;

-    DEBUG("stream=%p proc=%d serial=%d",
+    VIR_DEBUG("stream=%p proc=%d serial=%d",
           stream, msg->hdr.proc, msg->hdr.serial);

     memset(&rerr, 0, sizeof rerr);
@@ -495,7 +495,7 @@ remoteStreamHandleWrite(struct qemud_client *client,
 {
     struct qemud_client_message *msg, *tmp;

-    DEBUG("stream=%p", stream);
+    VIR_DEBUG("stream=%p", stream);

     msg = stream->rx;
     while (msg && !stream->closed) {
@@ -550,7 +550,7 @@ remoteStreamHandleRead(struct qemud_client *client,
     size_t bufferLen = REMOTE_MESSAGE_PAYLOAD_MAX;
     int ret;

-    DEBUG("stream=%p", stream);
+    VIR_DEBUG("stream=%p", stream);

     /* Shouldn't ever be called unless we're marked able to
      * transmit, but doesn't hurt to check */
@@ -603,7 +603,7 @@ remoteStreamMessageFinished(struct qemud_client *client,
         stream = stream->next;
     }

-    DEBUG("Message client=%p stream=%p proc=%d serial=%d", client, stream, msg->hdr.proc, msg->hdr.serial);
+    VIR_DEBUG("Message client=%p stream=%p proc=%d serial=%d", client, stream, msg->hdr.proc, msg->hdr.serial);

     if (stream) {
         stream->tx = 1;
diff --git a/docs/api_extension/0004-implement-the-public-APIs.patch b/docs/api_extension/0004-implement-the-public-APIs.patch
index 96c3439..7f13f0a 100644
--- a/docs/api_extension/0004-implement-the-public-APIs.patch
+++ b/docs/api_extension/0004-implement-the-public-APIs.patch
@@ -62,7 +62,7 @@ index 629d97b..1b39210 100644
 +                       unsigned int flags)
 +{
 +    virConnectPtr conn;
-+    DEBUG("domain=%p, nvcpus=%u, flags=%u", domain, nvcpus, flags);
++    VIR_DEBUG("domain=%p, nvcpus=%u, flags=%u", domain, nvcpus, flags);
 +
 +    virResetLastError();
 +
@@ -125,7 +125,7 @@ index 629d97b..1b39210 100644
 +virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
 +{
 +    virConnectPtr conn;
-+    DEBUG("domain=%p, flags=%u", domain, flags);
++    VIR_DEBUG("domain=%p, flags=%u", domain, flags);
 +
 +    virResetLastError();
 +
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 74eabba..6e3a160 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -10,9 +10,9 @@
 # include <sys/poll.h>
 # include <libvirt/libvirt.h>

-# define DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
+# define VIR_DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
         __func__, __LINE__)
-# define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
+# define VIR_DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
         __func__, __LINE__, __VA_ARGS__)
 # define STREQ(a,b) (strcmp(a,b) == 0)

@@ -300,7 +300,7 @@ int  myEventAddHandleFunc(int fd, int event,
                           void *opaque,
                           virFreeCallback ff)
 {
-    DEBUG("Add handle %d %d %p %p", fd, event, cb, opaque);
+    VIR_DEBUG("Add handle %d %d %p %p", fd, event, cb, opaque);
     h_fd = fd;
     h_event = myEventHandleTypeToPollEvent(event);
     h_cb = cb;
@@ -311,14 +311,14 @@ int  myEventAddHandleFunc(int fd, int event,

 void myEventUpdateHandleFunc(int fd, int event)
 {
-    DEBUG("Updated Handle %d %d", fd, event);
+    VIR_DEBUG("Updated Handle %d %d", fd, event);
     h_event = myEventHandleTypeToPollEvent(event);
     return;
 }

 int  myEventRemoveHandleFunc(int fd)
 {
-    DEBUG("Removed Handle %d", fd);
+    VIR_DEBUG("Removed Handle %d", fd);
     h_fd = 0;
     if (h_ff)
        (h_ff)(h_opaque);
@@ -330,7 +330,7 @@ int myEventAddTimeoutFunc(int timeout,
                           void *opaque,
                           virFreeCallback ff)
 {
-    DEBUG("Adding Timeout %d %p %p", timeout, cb, opaque);
+    VIR_DEBUG("Adding Timeout %d %p %p", timeout, cb, opaque);
     t_active = 1;
     t_timeout = timeout;
     t_cb = cb;
@@ -341,13 +341,13 @@ int myEventAddTimeoutFunc(int timeout,

 void myEventUpdateTimeoutFunc(int timer ATTRIBUTE_UNUSED, int timeout)
 {
-    /*DEBUG("Timeout updated %d %d", timer, timeout);*/
+    /*VIR_DEBUG("Timeout updated %d %d", timer, timeout);*/
     t_timeout = timeout;
 }

 int myEventRemoveTimeoutFunc(int timer)
 {
-   DEBUG("Timeout removed %d", timer);
+   VIR_DEBUG("Timeout removed %d", timer);
    t_active = 0;
    if (t_ff)
        (t_ff)(t_opaque);
@@ -408,7 +408,7 @@ int main(int argc, char **argv)
     sigaction(SIGTERM, &action_stop, NULL);
     sigaction(SIGINT, &action_stop, NULL);

-    DEBUG0("Registering domain event cbs");
+    VIR_DEBUG0("Registering domain event cbs");

     /* Add 2 callbacks to prove this works with more than just one */
     callback1ret = virConnectDomainEventRegister(dconn, myDomainEventCallback1,
@@ -464,15 +464,15 @@ int main(int argc, char **argv)
             }

             if (sts == 0) {
-                /* DEBUG0("Poll timeout"); */
+                /* VIR_DEBUG0("Poll timeout"); */
                 continue;
             }
             if (sts < 0 ) {
-                DEBUG0("Poll failed");
+                VIR_DEBUG0("Poll failed");
                 continue;
             }
             if ( pfd.revents & POLLHUP ) {
-                DEBUG0("Reset by peer");
+                VIR_DEBUG0("Reset by peer");
                 return -1;
             }

@@ -485,7 +485,7 @@ int main(int argc, char **argv)

         }

-        DEBUG0("Deregistering event handlers");
+        VIR_DEBUG0("Deregistering event handlers");
         virConnectDomainEventDeregister(dconn, myDomainEventCallback1);
         virConnectDomainEventDeregisterAny(dconn, callback2ret);
         virConnectDomainEventDeregisterAny(dconn, callback3ret);
@@ -495,7 +495,7 @@ int main(int argc, char **argv)
         virConnectDomainEventDeregisterAny(dconn, callback7ret);
     }

-    DEBUG0("Closing connection");
+    VIR_DEBUG0("Closing connection");
     if( dconn && virConnectClose(dconn)<0 ) {
         printf("error closing\n");
     }
diff --git a/src/datatypes.c b/src/datatypes.c
index d870e5d..0e99268 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -243,7 +243,7 @@ failed:
  */
 static void
 virReleaseConnect(virConnectPtr conn) {
-    DEBUG("release connection %p", conn);
+    VIR_DEBUG("release connection %p", conn);

     /* make sure to release the connection lock before we call the
      * close callbacks, otherwise we will deadlock if an error
@@ -311,7 +311,7 @@ virUnrefConnect(virConnectPtr conn) {
         return -1;
     }
     virMutexLock(&conn->lock);
-    DEBUG("unref connection %p %d", conn, conn->refs);
+    VIR_DEBUG("unref connection %p %d", conn, conn->refs);
     conn->refs--;
     refs = conn->refs;
     if (refs == 0) {
@@ -389,9 +389,9 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
             goto error;
         }
         conn->refs++;
-        DEBUG("New hash entry %p", ret);
+        VIR_DEBUG("New hash entry %p", ret);
     } else {
-        DEBUG("Existing hash entry %p: refs now %d", ret, ret->refs+1);
+        VIR_DEBUG("Existing hash entry %p: refs now %d", ret, ret->refs+1);
     }
     ret->refs++;
     virMutexUnlock(&conn->lock);
@@ -423,7 +423,7 @@ virReleaseDomain(virDomainPtr domain) {
     char uuidstr[VIR_UUID_STRING_BUFLEN];

     virUUIDFormat(domain->uuid, uuidstr);
-    DEBUG("release domain %p %s %s", domain, domain->name, uuidstr);
+    VIR_DEBUG("release domain %p %s %s", domain, domain->name, uuidstr);

     if (virHashRemoveEntry(conn->domains, uuidstr, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -440,7 +440,7 @@ virReleaseDomain(virDomainPtr domain) {
     VIR_FREE(domain);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -470,7 +470,7 @@ virUnrefDomain(virDomainPtr domain) {
         return -1;
     }
     virMutexLock(&domain->conn->lock);
-    DEBUG("unref domain %p %s %d", domain, domain->name, domain->refs);
+    VIR_DEBUG("unref domain %p %s %d", domain, domain->name, domain->refs);
     domain->refs--;
     refs = domain->refs;
     if (refs == 0) {
@@ -572,7 +572,7 @@ virReleaseNetwork(virNetworkPtr network) {
     char uuidstr[VIR_UUID_STRING_BUFLEN];

     virUUIDFormat(network->uuid, uuidstr);
-    DEBUG("release network %p %s %s", network, network->name, uuidstr);
+    VIR_DEBUG("release network %p %s %s", network, network->name, uuidstr);

     if (virHashRemoveEntry(conn->networks, uuidstr, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -586,7 +586,7 @@ virReleaseNetwork(virNetworkPtr network) {
     VIR_FREE(network);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -617,7 +617,7 @@ virUnrefNetwork(virNetworkPtr network) {
         return -1;
     }
     virMutexLock(&network->conn->lock);
-    DEBUG("unref network %p %s %d", network, network->name, network->refs);
+    VIR_DEBUG("unref network %p %s %d", network, network->name, network->refs);
     network->refs--;
     refs = network->refs;
     if (refs == 0) {
@@ -756,7 +756,7 @@ virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
 static void
 virReleaseInterface(virInterfacePtr iface) {
     virConnectPtr conn = iface->conn;
-    DEBUG("release interface %p %s", iface, iface->name);
+    VIR_DEBUG("release interface %p %s", iface, iface->name);

     if (virHashRemoveEntry(conn->interfaces, iface->name, NULL) < 0) {
         /* unlock before reporting error because error report grabs lock */
@@ -773,7 +773,7 @@ virReleaseInterface(virInterfacePtr iface) {
     VIR_FREE(iface);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -804,7 +804,7 @@ virUnrefInterface(virInterfacePtr iface) {
         return -1;
     }
     virMutexLock(&iface->conn->lock);
-    DEBUG("unref interface %p %s %d", iface, iface->name, iface->refs);
+    VIR_DEBUG("unref interface %p %s %d", iface, iface->name, iface->refs);
     iface->refs--;
     refs = iface->refs;
     if (refs == 0) {
@@ -909,7 +909,7 @@ virReleaseStoragePool(virStoragePoolPtr pool) {
     char uuidstr[VIR_UUID_STRING_BUFLEN];

     virUUIDFormat(pool->uuid, uuidstr);
-    DEBUG("release pool %p %s %s", pool, pool->name, uuidstr);
+    VIR_DEBUG("release pool %p %s %s", pool, pool->name, uuidstr);

     if (virHashRemoveEntry(conn->storagePools, uuidstr, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -923,7 +923,7 @@ virReleaseStoragePool(virStoragePoolPtr pool) {
     VIR_FREE(pool);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -954,7 +954,7 @@ virUnrefStoragePool(virStoragePoolPtr pool) {
         return -1;
     }
     virMutexLock(&pool->conn->lock);
-    DEBUG("unref pool %p %s %d", pool, pool->name, pool->refs);
+    VIR_DEBUG("unref pool %p %s %d", pool, pool->name, pool->refs);
     pool->refs--;
     refs = pool->refs;
     if (refs == 0) {
@@ -1066,7 +1066,7 @@ error:
 static void
 virReleaseStorageVol(virStorageVolPtr vol) {
     virConnectPtr conn = vol->conn;
-    DEBUG("release vol %p %s", vol, vol->name);
+    VIR_DEBUG("release vol %p %s", vol, vol->name);

     if (virHashRemoveEntry(conn->storageVols, vol->key, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -1081,7 +1081,7 @@ virReleaseStorageVol(virStorageVolPtr vol) {
     VIR_FREE(vol);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -1112,7 +1112,7 @@ virUnrefStorageVol(virStorageVolPtr vol) {
         return -1;
     }
     virMutexLock(&vol->conn->lock);
-    DEBUG("unref vol %p %s %d", vol, vol->name, vol->refs);
+    VIR_DEBUG("unref vol %p %s %d", vol, vol->name, vol->refs);
     vol->refs--;
     refs = vol->refs;
     if (refs == 0) {
@@ -1205,7 +1205,7 @@ error:
 static void
 virReleaseNodeDevice(virNodeDevicePtr dev) {
     virConnectPtr conn = dev->conn;
-    DEBUG("release dev %p %s", dev, dev->name);
+    VIR_DEBUG("release dev %p %s", dev, dev->name);

     if (virHashRemoveEntry(conn->nodeDevices, dev->name, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -1220,7 +1220,7 @@ virReleaseNodeDevice(virNodeDevicePtr dev) {
     VIR_FREE(dev);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -1246,7 +1246,7 @@ virUnrefNodeDevice(virNodeDevicePtr dev) {
     int refs;

     virMutexLock(&dev->conn->lock);
-    DEBUG("unref dev %p %s %d", dev, dev->name, dev->refs);
+    VIR_DEBUG("unref dev %p %s %d", dev, dev->name, dev->refs);
     dev->refs--;
     refs = dev->refs;
     if (refs == 0) {
@@ -1348,7 +1348,7 @@ virReleaseSecret(virSecretPtr secret) {
     char uuidstr[VIR_UUID_STRING_BUFLEN];

     virUUIDFormat(secret->uuid, uuidstr);
-    DEBUG("release secret %p %s", secret, uuidstr);
+    VIR_DEBUG("release secret %p %s", secret, uuidstr);

     if (virHashRemoveEntry(conn->secrets, uuidstr, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -1362,7 +1362,7 @@ virReleaseSecret(virSecretPtr secret) {
     VIR_FREE(secret);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -1391,7 +1391,7 @@ virUnrefSecret(virSecretPtr secret) {
         return -1;
     }
     virMutexLock(&secret->conn->lock);
-    DEBUG("unref secret %p %p %d", secret, secret->uuid, secret->refs);
+    VIR_DEBUG("unref secret %p %p %d", secret, secret->uuid, secret->refs);
     secret->refs--;
     refs = secret->refs;
     if (refs == 0) {
@@ -1429,12 +1429,12 @@ error:
 static void
 virReleaseStream(virStreamPtr st) {
     virConnectPtr conn = st->conn;
-    DEBUG("release dev %p", st);
+    VIR_DEBUG("release dev %p", st);

     st->magic = -1;
     VIR_FREE(st);

-    DEBUG("unref connection %p %d", conn, conn->refs);
+    VIR_DEBUG("unref connection %p %d", conn, conn->refs);
     conn->refs--;
     if (conn->refs == 0) {
         virReleaseConnect(conn);
@@ -1449,7 +1449,7 @@ int virUnrefStream(virStreamPtr st) {
     int refs;

     virMutexLock(&st->conn->lock);
-    DEBUG("unref stream %p %d", st, st->refs);
+    VIR_DEBUG("unref stream %p %d", st, st->refs);
     st->refs--;
     refs = st->refs;
     if (refs == 0) {
@@ -1554,7 +1554,7 @@ virReleaseNWFilter(virNWFilterPtr nwfilter)
     char uuidstr[VIR_UUID_STRING_BUFLEN];

     virUUIDFormat(nwfilter->uuid, uuidstr);
-    DEBUG("release nwfilter %p %s %s", nwfilter, nwfilter->name, uuidstr);
+    VIR_DEBUG("release nwfilter %p %s %s", nwfilter, nwfilter->name, uuidstr);

     if (virHashRemoveEntry(conn->nwfilters, uuidstr, NULL) < 0) {
         virMutexUnlock(&conn->lock);
@@ -1568,7 +1568,7 @@ virReleaseNWFilter(virNWFilterPtr nwfilter)
     VIR_FREE(nwfilter);

     if (conn) {
-        DEBUG("unref connection %p %d", conn, conn->refs);
+        VIR_DEBUG("unref connection %p %d", conn, conn->refs);
         conn->refs--;
         if (conn->refs == 0) {
             virReleaseConnect(conn);
@@ -1600,7 +1600,7 @@ virUnrefNWFilter(virNWFilterPtr nwfilter)
         return -1;
     }
     virMutexLock(&nwfilter->conn->lock);
-    DEBUG("unref pool %p %s %d", nwfilter, nwfilter->name, nwfilter->refs);
+    VIR_DEBUG("unref pool %p %s %d", nwfilter, nwfilter->name, nwfilter->refs);
     nwfilter->refs--;
     refs = nwfilter->refs;
     if (refs == 0) {
@@ -1652,9 +1652,9 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name)
             goto error;
         }
         domain->refs++;
-        DEBUG("New hash entry %p", ret);
+        VIR_DEBUG("New hash entry %p", ret);
     } else {
-        DEBUG("Existing hash entry %p: refs now %d", ret, ret->refs+1);
+        VIR_DEBUG("Existing hash entry %p: refs now %d", ret, ret->refs+1);
     }
     ret->refs++;
     virMutexUnlock(&domain->conn->lock);
@@ -1673,7 +1673,7 @@ static void
 virReleaseDomainSnapshot(virDomainSnapshotPtr snapshot)
 {
     virDomainPtr domain = snapshot->domain;
-    DEBUG("release snapshot %p %s", snapshot, snapshot->name);
+    VIR_DEBUG("release snapshot %p %s", snapshot, snapshot->name);

     if (virHashRemoveEntry(domain->snapshots, snapshot->name, NULL) < 0) {
         virMutexUnlock(&domain->conn->lock);
@@ -1687,7 +1687,7 @@ virReleaseDomainSnapshot(virDomainSnapshotPtr snapshot)
     VIR_FREE(snapshot);

     if (domain) {
-        DEBUG("unref domain %p %d", domain, domain->refs);
+        VIR_DEBUG("unref domain %p %d", domain, domain->refs);
         domain->refs--;
         if (domain->refs == 0) {
             virReleaseDomain(domain);
@@ -1709,7 +1709,7 @@ virUnrefDomainSnapshot(virDomainSnapshotPtr snapshot)
     }

     virMutexLock(&snapshot->domain->conn->lock);
-    DEBUG("unref snapshot %p %s %d", snapshot, snapshot->name, snapshot->refs);
+    VIR_DEBUG("unref snapshot %p %s %d", snapshot, snapshot->name, snapshot->refs);
     snapshot->refs--;
     refs = snapshot->refs;
     if (refs == 0) {
diff --git a/src/driver.c b/src/driver.c
index 6e4aa9f..f882ea1 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -53,7 +53,7 @@ virDriverLoadModule(const char *name)
     if (moddir == NULL)
         moddir = DEFAULT_DRIVER_DIR;

-    DEBUG("Module load %s", name);
+    VIR_DEBUG("Module load %s", name);

     if (virAsprintf(&modfile, "%s/libvirt_driver_%s.so", moddir, name) < 0)
         return NULL;
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
index 2c418f8..d914ac8 100644
--- a/src/libvirt-qemu.c
+++ b/src/libvirt-qemu.c
@@ -42,7 +42,7 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
 {
     virConnectPtr conn;

-    DEBUG("domain=%p, cmd=%s, result=%p, flags=%u", domain, cmd, result, flags);
+    VIR_DEBUG("domain=%p, cmd=%s, result=%p, flags=%u", domain, cmd, result, flags);

     virResetLastError();

diff --git a/src/libvirt.c b/src/libvirt.c
index f65cc24..e4b451e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -326,7 +326,7 @@ static struct gcry_thread_cbs virTLSThreadImpl = {
         _domname = (dom)->name;                           \
     }                                                     \
                                                           \
-    DEBUG("dom=%p, (VM: name=%s, uuid=%s), " fmt,         \
+    VIR_DEBUG("dom=%p, (VM: name=%s, uuid=%s), " fmt,         \
           dom, NULLSTR(_domname), _uuidstr, __VA_ARGS__)

 #define VIR_DOMAIN_DEBUG0(dom) VIR_DOMAIN_DEBUG(dom, "%s", "")
@@ -358,7 +358,7 @@ virInitialize(void)

     virLogSetFromEnv();

-    DEBUG0("register drivers");
+    VIR_DEBUG0("register drivers");

 #if HAVE_WINSOCK2_H
     if (winsock_init () == -1) return -1;
@@ -529,7 +529,7 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as network driver %d",
+    VIR_DEBUG ("registering %s as network driver %d",
            driver->name, virNetworkDriverTabCount);

     virNetworkDriverTab[virNetworkDriverTabCount] = driver;
@@ -562,7 +562,7 @@ virRegisterInterfaceDriver(virInterfaceDriverPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as interface driver %d",
+    VIR_DEBUG ("registering %s as interface driver %d",
            driver->name, virInterfaceDriverTabCount);

     virInterfaceDriverTab[virInterfaceDriverTabCount] = driver;
@@ -595,7 +595,7 @@ virRegisterStorageDriver(virStorageDriverPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as storage driver %d",
+    VIR_DEBUG ("registering %s as storage driver %d",
            driver->name, virStorageDriverTabCount);

     virStorageDriverTab[virStorageDriverTabCount] = driver;
@@ -628,7 +628,7 @@ virRegisterDeviceMonitor(virDeviceMonitorPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as device driver %d",
+    VIR_DEBUG ("registering %s as device driver %d",
            driver->name, virDeviceMonitorTabCount);

     virDeviceMonitorTab[virDeviceMonitorTabCount] = driver;
@@ -661,7 +661,7 @@ virRegisterSecretDriver(virSecretDriverPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as secret driver %d",
+    VIR_DEBUG ("registering %s as secret driver %d",
            driver->name, virSecretDriverTabCount);

     virSecretDriverTab[virSecretDriverTabCount] = driver;
@@ -694,7 +694,7 @@ virRegisterNWFilterDriver(virNWFilterDriverPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as network filter driver %d",
+    VIR_DEBUG ("registering %s as network filter driver %d",
            driver->name, virNWFilterDriverTabCount);

     virNWFilterDriverTab[virNWFilterDriverTabCount] = driver;
@@ -713,7 +713,7 @@ virRegisterNWFilterDriver(virNWFilterDriverPtr driver)
 int
 virRegisterDriver(virDriverPtr driver)
 {
-    DEBUG("driver=%p name=%s", driver, driver ? NULLSTR(driver->name) : "(null)");
+    VIR_DEBUG("driver=%p name=%s", driver, driver ? NULLSTR(driver->name) : "(null)");

     if (virInitialize() < 0)
         return -1;
@@ -736,7 +736,7 @@ virRegisterDriver(virDriverPtr driver)
         return -1;
     }

-    DEBUG ("registering %s as driver %d",
+    VIR_DEBUG ("registering %s as driver %d",
            driver->name, virDriverTabCount);

     virDriverTab[virDriverTabCount] = driver;
@@ -876,7 +876,7 @@ int
 virGetVersion(unsigned long *libVer, const char *type,
               unsigned long *typeVer)
 {
-    DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer);
+    VIR_DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer);

     if (!initialized)
         if (virInitialize() < 0)
@@ -983,7 +983,7 @@ do_open (const char *name,
     if (!name || name[0] == '\0') {
         char *defname = getenv("LIBVIRT_DEFAULT_URI");
         if (defname && *defname) {
-            DEBUG("Using LIBVIRT_DEFAULT_URI %s", defname);
+            VIR_DEBUG("Using LIBVIRT_DEFAULT_URI %s", defname);
             name = defname;
         } else {
             name = NULL;
@@ -1008,7 +1008,7 @@ do_open (const char *name,
             goto failed;
         }

-        DEBUG("name \"%s\" to URI components:\n"
+        VIR_DEBUG("name \"%s\" to URI components:\n"
               "  scheme %s\n"
               "  opaque %s\n"
               "  authority %s\n"
@@ -1022,7 +1022,7 @@ do_open (const char *name,
               NULLSTR(ret->uri->user), ret->uri->port,
               NULLSTR(ret->uri->path));
     } else {
-        DEBUG0("no name, allowing driver auto-select");
+        VIR_DEBUG0("no name, allowing driver auto-select");
     }

     /* Cleansing flags */
@@ -1058,10 +1058,10 @@ do_open (const char *name,
             goto failed;
         }

-        DEBUG("trying driver %d (%s) ...",
+        VIR_DEBUG("trying driver %d (%s) ...",
               i, virDriverTab[i]->name);
         res = virDriverTab[i]->open (ret, auth, flags);
-        DEBUG("driver %d %s returned %s",
+        VIR_DEBUG("driver %d %s returned %s",
               i, virDriverTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1083,7 +1083,7 @@ do_open (const char *name,

     for (i = 0; i < virNetworkDriverTabCount; i++) {
         res = virNetworkDriverTab[i]->open (ret, auth, flags);
-        DEBUG("network driver %d %s returned %s",
+        VIR_DEBUG("network driver %d %s returned %s",
               i, virNetworkDriverTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1098,7 +1098,7 @@ do_open (const char *name,

     for (i = 0; i < virInterfaceDriverTabCount; i++) {
         res = virInterfaceDriverTab[i]->open (ret, auth, flags);
-        DEBUG("interface driver %d %s returned %s",
+        VIR_DEBUG("interface driver %d %s returned %s",
               i, virInterfaceDriverTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1114,7 +1114,7 @@ do_open (const char *name,
     /* Secondary driver for storage. Optional */
     for (i = 0; i < virStorageDriverTabCount; i++) {
         res = virStorageDriverTab[i]->open (ret, auth, flags);
-        DEBUG("storage driver %d %s returned %s",
+        VIR_DEBUG("storage driver %d %s returned %s",
               i, virStorageDriverTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1130,7 +1130,7 @@ do_open (const char *name,
     /* Node driver (optional) */
     for (i = 0; i < virDeviceMonitorTabCount; i++) {
         res = virDeviceMonitorTab[i]->open (ret, auth, flags);
-        DEBUG("node driver %d %s returned %s",
+        VIR_DEBUG("node driver %d %s returned %s",
               i, virDeviceMonitorTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1146,7 +1146,7 @@ do_open (const char *name,
     /* Secret manipulation driver. Optional */
     for (i = 0; i < virSecretDriverTabCount; i++) {
         res = virSecretDriverTab[i]->open (ret, auth, flags);
-        DEBUG("secret driver %d %s returned %s",
+        VIR_DEBUG("secret driver %d %s returned %s",
               i, virSecretDriverTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1162,7 +1162,7 @@ do_open (const char *name,
     /* Network filter driver. Optional */
     for (i = 0; i < virNWFilterDriverTabCount; i++) {
         res = virNWFilterDriverTab[i]->open (ret, auth, flags);
-        DEBUG("nwfilter driver %d %s returned %s",
+        VIR_DEBUG("nwfilter driver %d %s returned %s",
               i, virNWFilterDriverTab[i]->name,
               res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
               (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
@@ -1213,7 +1213,7 @@ virConnectOpen (const char *name)
         if (virInitialize() < 0)
             goto error;

-    DEBUG("name=%s", name);
+    VIR_DEBUG("name=%s", name);
     ret = do_open (name, NULL, 0);
     if (!ret)
         goto error;
@@ -1247,7 +1247,7 @@ virConnectOpenReadOnly(const char *name)
         if (virInitialize() < 0)
             goto error;

-    DEBUG("name=%s", name);
+    VIR_DEBUG("name=%s", name);
     ret = do_open (name, NULL, VIR_CONNECT_RO);
     if (!ret)
         goto error;
@@ -1285,7 +1285,7 @@ virConnectOpenAuth(const char *name,
         if (virInitialize() < 0)
             goto error;

-    DEBUG("name=%s, auth=%p, flags=%d", NULLSTR(name), auth, flags);
+    VIR_DEBUG("name=%s, auth=%p, flags=%d", NULLSTR(name), auth, flags);
     ret = do_open (name, auth, flags);
     if (!ret)
         goto error;
@@ -1311,7 +1311,7 @@ int
 virConnectClose(virConnectPtr conn)
 {
     int ret = -1;
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -1356,7 +1356,7 @@ virConnectRef(virConnectPtr conn)
         return -1;
     }
     virMutexLock(&conn->lock);
-    DEBUG("conn=%p refs=%d", conn, conn->refs);
+    VIR_DEBUG("conn=%p refs=%d", conn, conn->refs);
     conn->refs++;
     virMutexUnlock(&conn->lock);
     return 0;
@@ -1370,7 +1370,7 @@ int
 virDrvSupportsFeature (virConnectPtr conn, int feature)
 {
     int ret;
-    DEBUG("conn=%p, feature=%d", conn, feature);
+    VIR_DEBUG("conn=%p, feature=%d", conn, feature);

     virResetLastError();

@@ -1406,7 +1406,7 @@ const char *
 virConnectGetType(virConnectPtr conn)
 {
     const char *ret;
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -1439,7 +1439,7 @@ virConnectGetType(virConnectPtr conn)
 int
 virConnectGetVersion(virConnectPtr conn, unsigned long *hvVer)
 {
-    DEBUG("conn=%p, hvVer=%p", conn, hvVer);
+    VIR_DEBUG("conn=%p, hvVer=%p", conn, hvVer);

     virResetLastError();

@@ -1483,7 +1483,7 @@ int
 virConnectGetLibVersion(virConnectPtr conn, unsigned long *libVer)
 {
     int ret = -1;
-    DEBUG("conn=%p, libVir=%p", conn, libVer);
+    VIR_DEBUG("conn=%p, libVir=%p", conn, libVer);

     virResetLastError();

@@ -1528,7 +1528,7 @@ error:
 char *
 virConnectGetHostname (virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -1571,7 +1571,7 @@ char *
 virConnectGetURI (virConnectPtr conn)
 {
     char *name;
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -1609,7 +1609,7 @@ error:
 char *
 virConnectGetSysinfo (virConnectPtr conn, unsigned int flags)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -1648,7 +1648,7 @@ int
 virConnectGetMaxVcpus(virConnectPtr conn,
                       const char *type)
 {
-    DEBUG("conn=%p, type=%s", conn, type);
+    VIR_DEBUG("conn=%p, type=%s", conn, type);

     virResetLastError();

@@ -1684,7 +1684,7 @@ error:
 int
 virConnectListDomains(virConnectPtr conn, int *ids, int maxids)
 {
-    DEBUG("conn=%p, ids=%p, maxids=%d", conn, ids, maxids);
+    VIR_DEBUG("conn=%p, ids=%p, maxids=%d", conn, ids, maxids);

     virResetLastError();

@@ -1723,7 +1723,7 @@ error:
 int
 virConnectNumOfDomains(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -1794,7 +1794,7 @@ virDomainPtr
 virDomainCreateXML(virConnectPtr conn, const char *xmlDesc,
                    unsigned int flags)
 {
-    DEBUG("conn=%p, xmlDesc=%s, flags=%d", conn, xmlDesc, flags);
+    VIR_DEBUG("conn=%p, xmlDesc=%s, flags=%d", conn, xmlDesc, flags);

     virResetLastError();

@@ -1860,7 +1860,7 @@ virDomainCreateLinux(virConnectPtr conn, const char *xmlDesc,
 virDomainPtr
 virDomainLookupByID(virConnectPtr conn, int id)
 {
-    DEBUG("conn=%p, id=%d", conn, id);
+    VIR_DEBUG("conn=%p, id=%d", conn, id);

     virResetLastError();

@@ -1905,7 +1905,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     virUUIDFormat(uuid, uuidstr);

-    DEBUG("conn=%p, uuid=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuid=%s", conn, uuidstr);

     virResetLastError();

@@ -1948,7 +1948,7 @@ virDomainPtr
 virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);

     virResetLastError();

@@ -1987,7 +1987,7 @@ error:
 virDomainPtr
 virDomainLookupByName(virConnectPtr conn, const char *name)
 {
-    DEBUG("conn=%p, name=%s", conn, name);
+    VIR_DEBUG("conn=%p, name=%s", conn, name);

     virResetLastError();

@@ -2303,7 +2303,7 @@ int
 virDomainRestore(virConnectPtr conn, const char *from)
 {
     char filepath[4096];
-    DEBUG("conn=%p, from=%s", conn, from);
+    VIR_DEBUG("conn=%p, from=%s", conn, from);

     virResetLastError();

@@ -2547,7 +2547,7 @@ error:
 const char *
 virDomainGetName(virDomainPtr domain)
 {
-    DEBUG("domain=%p", domain);
+    VIR_DEBUG("domain=%p", domain);

     virResetLastError();

@@ -3091,7 +3091,7 @@ char *virConnectDomainXMLFromNative(virConnectPtr conn,
                                     const char *nativeConfig,
                                     unsigned int flags)
 {
-    DEBUG("conn=%p, format=%s config=%s flags=%u", conn, nativeFormat, nativeConfig, flags);
+    VIR_DEBUG("conn=%p, format=%s config=%s flags=%u", conn, nativeFormat, nativeConfig, flags);

     virResetLastError();

@@ -3143,7 +3143,7 @@ char *virConnectDomainXMLToNative(virConnectPtr conn,
                                   const char *domainXml,
                                   unsigned int flags)
 {
-    DEBUG("conn=%p, format=%s xml=%s flags=%u", conn, nativeFormat, domainXml, flags);
+    VIR_DEBUG("conn=%p, format=%s xml=%s flags=%u", conn, nativeFormat, domainXml, flags);

     virResetLastError();

@@ -4011,7 +4011,7 @@ error:
 int
 virNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
 {
-    DEBUG("conn=%p, info=%p", conn, info);
+    VIR_DEBUG("conn=%p, info=%p", conn, info);

     virResetLastError();

@@ -4053,7 +4053,7 @@ error:
 char *
 virConnectGetCapabilities (virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -4068,7 +4068,7 @@ virConnectGetCapabilities (virConnectPtr conn)
         ret = conn->driver->getCapabilities (conn);
         if (!ret)
             goto error;
-        DEBUG("conn=%p ret=%s", conn, ret);
+        VIR_DEBUG("conn=%p ret=%s", conn, ret);
         return ret;
     }

@@ -4092,7 +4092,7 @@ error:
 unsigned long long
 virNodeGetFreeMemory(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -4726,7 +4726,7 @@ error:
  */
 virDomainPtr
 virDomainDefineXML(virConnectPtr conn, const char *xml) {
-    DEBUG("conn=%p, xml=%s", conn, xml);
+    VIR_DEBUG("conn=%p, xml=%s", conn, xml);

     virResetLastError();

@@ -4812,7 +4812,7 @@ error:
 int
 virConnectNumOfDefinedDomains(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -4851,7 +4851,7 @@ error:
 int
 virConnectListDefinedDomains(virConnectPtr conn, char **const names,
                              int maxnames) {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -5487,7 +5487,7 @@ error:
 int
 virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel)
 {
-    DEBUG("conn=%p secmodel=%p", conn, secmodel);
+    VIR_DEBUG("conn=%p secmodel=%p", conn, secmodel);

     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -5807,7 +5807,7 @@ int
 virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems,
                           int startCell, int maxCells)
 {
-    DEBUG("conn=%p, freeMems=%p, startCell=%d, maxCells=%d",
+    VIR_DEBUG("conn=%p, freeMems=%p, startCell=%d, maxCells=%d",
           conn, freeMems, startCell, maxCells);

     virResetLastError();
@@ -5855,7 +5855,7 @@ error:
 virConnectPtr
 virNetworkGetConnect (virNetworkPtr net)
 {
-    DEBUG("net=%p", net);
+    VIR_DEBUG("net=%p", net);

     virResetLastError();

@@ -5878,7 +5878,7 @@ virNetworkGetConnect (virNetworkPtr net)
 int
 virConnectNumOfNetworks(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -5916,7 +5916,7 @@ error:
 int
 virConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -5957,7 +5957,7 @@ error:
 int
 virConnectNumOfDefinedNetworks(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -5996,7 +5996,7 @@ int
 virConnectListDefinedNetworks(virConnectPtr conn, char **const names,
                               int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -6040,7 +6040,7 @@ error:
 virNetworkPtr
 virNetworkLookupByName(virConnectPtr conn, const char *name)
 {
-    DEBUG("conn=%p, name=%s", conn, name);
+    VIR_DEBUG("conn=%p, name=%s", conn, name);

     virResetLastError();

@@ -6085,7 +6085,7 @@ virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     virUUIDFormat(uuid, uuidstr);

-    DEBUG("conn=%p, uuid=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuid=%s", conn, uuidstr);

     virResetLastError();

@@ -6128,7 +6128,7 @@ virNetworkPtr
 virNetworkLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);

     virResetLastError();

@@ -6167,7 +6167,7 @@ error:
 virNetworkPtr
 virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc)
 {
-    DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);
+    VIR_DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);

     virResetLastError();

@@ -6212,7 +6212,7 @@ error:
 virNetworkPtr
 virNetworkDefineXML(virConnectPtr conn, const char *xml)
 {
-    DEBUG("conn=%p, xml=%s", conn, xml);
+    VIR_DEBUG("conn=%p, xml=%s", conn, xml);

     virResetLastError();

@@ -6256,7 +6256,7 @@ error:
 int
 virNetworkUndefine(virNetworkPtr network) {
     virConnectPtr conn;
-    DEBUG("network=%p", network);
+    VIR_DEBUG("network=%p", network);

     virResetLastError();

@@ -6299,7 +6299,7 @@ int
 virNetworkCreate(virNetworkPtr network)
 {
     virConnectPtr conn;
-    DEBUG("network=%p", network);
+    VIR_DEBUG("network=%p", network);

     virResetLastError();

@@ -6344,7 +6344,7 @@ int
 virNetworkDestroy(virNetworkPtr network)
 {
     virConnectPtr conn;
-    DEBUG("network=%p", network);
+    VIR_DEBUG("network=%p", network);

     virResetLastError();

@@ -6387,7 +6387,7 @@ error:
 int
 virNetworkFree(virNetworkPtr network)
 {
-    DEBUG("network=%p", network);
+    VIR_DEBUG("network=%p", network);

     virResetLastError();

@@ -6429,7 +6429,7 @@ virNetworkRef(virNetworkPtr network)
         return -1;
     }
     virMutexLock(&network->conn->lock);
-    DEBUG("network=%p refs=%d", network, network->refs);
+    VIR_DEBUG("network=%p refs=%d", network, network->refs);
     network->refs++;
     virMutexUnlock(&network->conn->lock);
     return 0;
@@ -6447,7 +6447,7 @@ virNetworkRef(virNetworkPtr network)
 const char *
 virNetworkGetName(virNetworkPtr network)
 {
-    DEBUG("network=%p", network);
+    VIR_DEBUG("network=%p", network);

     virResetLastError();

@@ -6471,7 +6471,7 @@ virNetworkGetName(virNetworkPtr network)
 int
 virNetworkGetUUID(virNetworkPtr network, unsigned char *uuid)
 {
-    DEBUG("network=%p, uuid=%p", network, uuid);
+    VIR_DEBUG("network=%p, uuid=%p", network, uuid);

     virResetLastError();

@@ -6508,7 +6508,7 @@ int
 virNetworkGetUUIDString(virNetworkPtr network, char *buf)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("network=%p, buf=%p", network, buf);
+    VIR_DEBUG("network=%p, buf=%p", network, buf);

     virResetLastError();

@@ -6548,7 +6548,7 @@ char *
 virNetworkGetXMLDesc(virNetworkPtr network, int flags)
 {
     virConnectPtr conn;
-    DEBUG("network=%p, flags=%d", network, flags);
+    VIR_DEBUG("network=%p, flags=%d", network, flags);

     virResetLastError();

@@ -6593,7 +6593,7 @@ char *
 virNetworkGetBridgeName(virNetworkPtr network)
 {
     virConnectPtr conn;
-    DEBUG("network=%p", network);
+    VIR_DEBUG("network=%p", network);

     virResetLastError();

@@ -6636,7 +6636,7 @@ virNetworkGetAutostart(virNetworkPtr network,
                        int *autostart)
 {
     virConnectPtr conn;
-    DEBUG("network=%p, autostart=%p", network, autostart);
+    VIR_DEBUG("network=%p, autostart=%p", network, autostart);

     virResetLastError();

@@ -6682,7 +6682,7 @@ virNetworkSetAutostart(virNetworkPtr network,
                        int autostart)
 {
     virConnectPtr conn;
-    DEBUG("network=%p, autostart=%d", network, autostart);
+    VIR_DEBUG("network=%p, autostart=%d", network, autostart);

     virResetLastError();

@@ -6731,7 +6731,7 @@ error:
 virConnectPtr
 virInterfaceGetConnect (virInterfacePtr iface)
 {
-    DEBUG("iface=%p", iface);
+    VIR_DEBUG("iface=%p", iface);

     virResetLastError();

@@ -6754,7 +6754,7 @@ virInterfaceGetConnect (virInterfacePtr iface)
 int
 virConnectNumOfInterfaces(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -6793,7 +6793,7 @@ error:
 int
 virConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -6834,7 +6834,7 @@ error:
 int
 virConnectNumOfDefinedInterfaces(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -6875,7 +6875,7 @@ virConnectListDefinedInterfaces(virConnectPtr conn,
                                 char **const names,
                                 int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -6918,7 +6918,7 @@ error:
 virInterfacePtr
 virInterfaceLookupByName(virConnectPtr conn, const char *name)
 {
-    DEBUG("conn=%p, name=%s", conn, name);
+    VIR_DEBUG("conn=%p, name=%s", conn, name);

     virResetLastError();

@@ -6960,7 +6960,7 @@ error:
 virInterfacePtr
 virInterfaceLookupByMACString(virConnectPtr conn, const char *macstr)
 {
-    DEBUG("conn=%p, macstr=%s", conn, macstr);
+    VIR_DEBUG("conn=%p, macstr=%s", conn, macstr);

     virResetLastError();

@@ -7001,7 +7001,7 @@ error:
 const char *
 virInterfaceGetName(virInterfacePtr iface)
 {
-    DEBUG("iface=%p", iface);
+    VIR_DEBUG("iface=%p", iface);

     virResetLastError();

@@ -7027,7 +7027,7 @@ virInterfaceGetName(virInterfacePtr iface)
 const char *
 virInterfaceGetMACString(virInterfacePtr iface)
 {
-    DEBUG("iface=%p", iface);
+    VIR_DEBUG("iface=%p", iface);

     virResetLastError();

@@ -7061,7 +7061,7 @@ char *
 virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("iface=%p, flags=%d", iface, flags);
+    VIR_DEBUG("iface=%p, flags=%d", iface, flags);

     virResetLastError();

@@ -7105,7 +7105,7 @@ error:
 virInterfacePtr
 virInterfaceDefineXML(virConnectPtr conn, const char *xml, unsigned int flags)
 {
-    DEBUG("conn=%p, xml=%s, flags=%d", conn, xml, flags);
+    VIR_DEBUG("conn=%p, xml=%s, flags=%d", conn, xml, flags);

     virResetLastError();

@@ -7150,7 +7150,7 @@ error:
 int
 virInterfaceUndefine(virInterfacePtr iface) {
     virConnectPtr conn;
-    DEBUG("iface=%p", iface);
+    VIR_DEBUG("iface=%p", iface);

     virResetLastError();

@@ -7193,7 +7193,7 @@ int
 virInterfaceCreate(virInterfacePtr iface, unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("iface=%p, flags=%d", iface, flags);
+    VIR_DEBUG("iface=%p, flags=%d", iface, flags);

     virResetLastError();

@@ -7238,7 +7238,7 @@ int
 virInterfaceDestroy(virInterfacePtr iface, unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("iface=%p, flags=%d", iface, flags);
+    VIR_DEBUG("iface=%p, flags=%d", iface, flags);

     virResetLastError();

@@ -7295,7 +7295,7 @@ virInterfaceRef(virInterfacePtr iface)
         return -1;
     }
     virMutexLock(&iface->conn->lock);
-    DEBUG("iface=%p refs=%d", iface, iface->refs);
+    VIR_DEBUG("iface=%p refs=%d", iface, iface->refs);
     iface->refs++;
     virMutexUnlock(&iface->conn->lock);
     return 0;
@@ -7313,7 +7313,7 @@ virInterfaceRef(virInterfacePtr iface)
 int
 virInterfaceFree(virInterfacePtr iface)
 {
-    DEBUG("iface=%p", iface);
+    VIR_DEBUG("iface=%p", iface);

     virResetLastError();

@@ -7347,7 +7347,7 @@ virInterfaceFree(virInterfacePtr iface)
 virConnectPtr
 virStoragePoolGetConnect (virStoragePoolPtr pool)
 {
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -7370,7 +7370,7 @@ virStoragePoolGetConnect (virStoragePoolPtr pool)
 int
 virConnectNumOfStoragePools	(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -7412,7 +7412,7 @@ virConnectListStoragePools	(virConnectPtr conn,
                              char **const names,
                              int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -7454,7 +7454,7 @@ error:
 int
 virConnectNumOfDefinedStoragePools(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -7497,7 +7497,7 @@ virConnectListDefinedStoragePools(virConnectPtr conn,
                                   char **const names,
                                   int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -7555,7 +7555,7 @@ virConnectFindStoragePoolSources(virConnectPtr conn,
                                  const char *srcSpec,
                                  unsigned int flags)
 {
-    DEBUG("conn=%p, type=%s, src=%s, flags=%u", conn, type ? type : "", srcSpec ? srcSpec : "", flags);
+    VIR_DEBUG("conn=%p, type=%s, src=%s, flags=%u", conn, type ? type : "", srcSpec ? srcSpec : "", flags);

     virResetLastError();

@@ -7603,7 +7603,7 @@ virStoragePoolPtr
 virStoragePoolLookupByName(virConnectPtr conn,
                            const char *name)
 {
-    DEBUG("conn=%p, name=%s", conn, name);
+    VIR_DEBUG("conn=%p, name=%s", conn, name);

     virResetLastError();

@@ -7646,7 +7646,7 @@ virStoragePoolPtr
 virStoragePoolLookupByUUID(virConnectPtr conn,
                            const unsigned char *uuid)
 {
-    DEBUG("conn=%p, uuid=%s", conn, uuid);
+    VIR_DEBUG("conn=%p, uuid=%s", conn, uuid);

     virResetLastError();

@@ -7690,7 +7690,7 @@ virStoragePoolLookupByUUIDString(virConnectPtr conn,
                                  const char *uuidstr)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);

     virResetLastError();

@@ -7728,7 +7728,7 @@ error:
 virStoragePoolPtr
 virStoragePoolLookupByVolume(virStorageVolPtr vol)
 {
-    DEBUG("vol=%p", vol);
+    VIR_DEBUG("vol=%p", vol);

     virResetLastError();

@@ -7770,7 +7770,7 @@ virStoragePoolCreateXML(virConnectPtr conn,
                         const char *xmlDesc,
                         unsigned int flags)
 {
-    DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);
+    VIR_DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);

     virResetLastError();

@@ -7819,7 +7819,7 @@ virStoragePoolDefineXML(virConnectPtr conn,
                         const char *xml,
                         unsigned int flags)
 {
-    DEBUG("conn=%p, xml=%s", conn, xml);
+    VIR_DEBUG("conn=%p, xml=%s", conn, xml);

     virResetLastError();

@@ -7866,7 +7866,7 @@ virStoragePoolBuild(virStoragePoolPtr pool,
                     unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p, flags=%u", pool, flags);
+    VIR_DEBUG("pool=%p, flags=%u", pool, flags);

     virResetLastError();

@@ -7909,7 +7909,7 @@ int
 virStoragePoolUndefine(virStoragePoolPtr pool)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -7954,7 +7954,7 @@ virStoragePoolCreate(virStoragePoolPtr pool,
                      unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -8001,7 +8001,7 @@ int
 virStoragePoolDestroy(virStoragePoolPtr pool)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -8048,7 +8048,7 @@ virStoragePoolDelete(virStoragePoolPtr pool,
                      unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p, flags=%u", pool, flags);
+    VIR_DEBUG("pool=%p, flags=%u", pool, flags);

     virResetLastError();

@@ -8092,7 +8092,7 @@ error:
 int
 virStoragePoolFree(virStoragePoolPtr pool)
 {
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -8136,7 +8136,7 @@ virStoragePoolRef(virStoragePoolPtr pool)
         return -1;
     }
     virMutexLock(&pool->conn->lock);
-    DEBUG("pool=%p refs=%d", pool, pool->refs);
+    VIR_DEBUG("pool=%p refs=%d", pool, pool->refs);
     pool->refs++;
     virMutexUnlock(&pool->conn->lock);
     return 0;
@@ -8158,7 +8158,7 @@ virStoragePoolRefresh(virStoragePoolPtr pool,
                       unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p flags=%u", pool, flags);
+    VIR_DEBUG("pool=%p flags=%u", pool, flags);

     virResetLastError();

@@ -8201,7 +8201,7 @@ error:
 const char*
 virStoragePoolGetName(virStoragePoolPtr pool)
 {
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -8227,7 +8227,7 @@ int
 virStoragePoolGetUUID(virStoragePoolPtr pool,
                       unsigned char *uuid)
 {
-    DEBUG("pool=%p, uuid=%p", pool, uuid);
+    VIR_DEBUG("pool=%p, uuid=%p", pool, uuid);

     virResetLastError();

@@ -8264,7 +8264,7 @@ virStoragePoolGetUUIDString(virStoragePoolPtr pool,
                             char *buf)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("pool=%p, buf=%p", pool, buf);
+    VIR_DEBUG("pool=%p, buf=%p", pool, buf);

     virResetLastError();

@@ -8305,7 +8305,7 @@ virStoragePoolGetInfo(virStoragePoolPtr pool,
                       virStoragePoolInfoPtr info)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p, info=%p", pool, info);
+    VIR_DEBUG("pool=%p, info=%p", pool, info);

     virResetLastError();

@@ -8355,7 +8355,7 @@ virStoragePoolGetXMLDesc(virStoragePoolPtr pool,
                          unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p, flags=%u", pool, flags);
+    VIR_DEBUG("pool=%p, flags=%u", pool, flags);

     virResetLastError();

@@ -8402,7 +8402,7 @@ virStoragePoolGetAutostart(virStoragePoolPtr pool,
                            int *autostart)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p, autostart=%p", pool, autostart);
+    VIR_DEBUG("pool=%p, autostart=%p", pool, autostart);

     virResetLastError();

@@ -8448,7 +8448,7 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool,
                            int autostart)
 {
     virConnectPtr conn;
-    DEBUG("pool=%p, autostart=%d", pool, autostart);
+    VIR_DEBUG("pool=%p, autostart=%d", pool, autostart);

     virResetLastError();

@@ -8492,7 +8492,7 @@ error:
 int
 virStoragePoolNumOfVolumes(virStoragePoolPtr pool)
 {
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -8534,7 +8534,7 @@ virStoragePoolListVolumes(virStoragePoolPtr pool,
                           char **const names,
                           int maxnames)
 {
-    DEBUG("pool=%p, names=%p, maxnames=%d", pool, names, maxnames);
+    VIR_DEBUG("pool=%p, names=%p, maxnames=%d", pool, names, maxnames);

     virResetLastError();

@@ -8582,7 +8582,7 @@ error:
 virConnectPtr
 virStorageVolGetConnect (virStorageVolPtr vol)
 {
-    DEBUG("vol=%p", vol);
+    VIR_DEBUG("vol=%p", vol);

     virResetLastError();

@@ -8609,7 +8609,7 @@ virStorageVolPtr
 virStorageVolLookupByName(virStoragePoolPtr pool,
                           const char *name)
 {
-    DEBUG("pool=%p, name=%s", pool, name);
+    VIR_DEBUG("pool=%p, name=%s", pool, name);

     virResetLastError();

@@ -8654,7 +8654,7 @@ virStorageVolPtr
 virStorageVolLookupByKey(virConnectPtr conn,
                          const char *key)
 {
-    DEBUG("conn=%p, key=%s", conn, key);
+    VIR_DEBUG("conn=%p, key=%s", conn, key);

     virResetLastError();

@@ -8697,7 +8697,7 @@ virStorageVolPtr
 virStorageVolLookupByPath(virConnectPtr conn,
                           const char *path)
 {
-    DEBUG("conn=%p, path=%s", conn, path);
+    VIR_DEBUG("conn=%p, path=%s", conn, path);

     virResetLastError();

@@ -8739,7 +8739,7 @@ error:
 const char*
 virStorageVolGetName(virStorageVolPtr vol)
 {
-    DEBUG("vol=%p", vol);
+    VIR_DEBUG("vol=%p", vol);

     virResetLastError();

@@ -8765,7 +8765,7 @@ virStorageVolGetName(virStorageVolPtr vol)
 const char*
 virStorageVolGetKey(virStorageVolPtr vol)
 {
-    DEBUG("vol=%p", vol);
+    VIR_DEBUG("vol=%p", vol);

     virResetLastError();

@@ -8795,7 +8795,7 @@ virStorageVolCreateXML(virStoragePoolPtr pool,
                        const char *xmldesc,
                        unsigned int flags)
 {
-    DEBUG("pool=%p, flags=%u", pool, flags);
+    VIR_DEBUG("pool=%p, flags=%u", pool, flags);

     virResetLastError();

@@ -8846,7 +8846,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool,
                            virStorageVolPtr clonevol,
                            unsigned int flags)
 {
-    DEBUG("pool=%p, flags=%u, clonevol=%p", pool, flags, clonevol);
+    VIR_DEBUG("pool=%p, flags=%u, clonevol=%p", pool, flags, clonevol);

     virResetLastError();

@@ -8899,7 +8899,7 @@ virStorageVolDelete(virStorageVolPtr vol,
                     unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("vol=%p, flags=%u", vol, flags);
+    VIR_DEBUG("vol=%p, flags=%u", vol, flags);

     virResetLastError();

@@ -8990,7 +8990,7 @@ error:
 int
 virStorageVolFree(virStorageVolPtr vol)
 {
-    DEBUG("vol=%p", vol);
+    VIR_DEBUG("vol=%p", vol);

     virResetLastError();

@@ -9033,7 +9033,7 @@ virStorageVolRef(virStorageVolPtr vol)
         return -1;
     }
     virMutexLock(&vol->conn->lock);
-    DEBUG("vol=%p refs=%d", vol, vol->refs);
+    VIR_DEBUG("vol=%p refs=%d", vol, vol->refs);
     vol->refs++;
     virMutexUnlock(&vol->conn->lock);
     return 0;
@@ -9054,7 +9054,7 @@ virStorageVolGetInfo(virStorageVolPtr vol,
                      virStorageVolInfoPtr info)
 {
     virConnectPtr conn;
-    DEBUG("vol=%p, info=%p", vol, info);
+    VIR_DEBUG("vol=%p, info=%p", vol, info);

     virResetLastError();

@@ -9103,7 +9103,7 @@ virStorageVolGetXMLDesc(virStorageVolPtr vol,
                         unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("vol=%p, flags=%u", vol, flags);
+    VIR_DEBUG("vol=%p, flags=%u", vol, flags);

     virResetLastError();

@@ -9151,7 +9151,7 @@ char *
 virStorageVolGetPath(virStorageVolPtr vol)
 {
     virConnectPtr conn;
-    DEBUG("vol=%p", vol);
+    VIR_DEBUG("vol=%p", vol);

     virResetLastError();

@@ -9195,7 +9195,7 @@ error:
 int
 virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags)
 {
-    DEBUG("conn=%p, cap=%s, flags=%d", conn, NULLSTR(cap), flags);
+    VIR_DEBUG("conn=%p, cap=%s, flags=%d", conn, NULLSTR(cap), flags);

     virResetLastError();

@@ -9246,7 +9246,7 @@ virNodeListDevices(virConnectPtr conn,
                    char **const names, int maxnames,
                    unsigned int flags)
 {
-    DEBUG("conn=%p, cap=%s, names=%p, maxnames=%d, flags=%d",
+    VIR_DEBUG("conn=%p, cap=%s, names=%p, maxnames=%d, flags=%d",
           conn, cap, names, maxnames, flags);

     virResetLastError();
@@ -9288,7 +9288,7 @@ error:
  */
 virNodeDevicePtr virNodeDeviceLookupByName(virConnectPtr conn, const char *name)
 {
-    DEBUG("conn=%p, name=%p", conn, name);
+    VIR_DEBUG("conn=%p, name=%p", conn, name);

     virResetLastError();

@@ -9331,7 +9331,7 @@ error:
  */
 char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9367,7 +9367,7 @@ error:
  */
 const char *virNodeDeviceGetName(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) {
         virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__);
@@ -9389,7 +9389,7 @@ const char *virNodeDeviceGetName(virNodeDevicePtr dev)
  */
 const char *virNodeDeviceGetParent(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9421,7 +9421,7 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev)
  */
 int virNodeDeviceNumOfCaps(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9460,7 +9460,7 @@ int virNodeDeviceListCaps(virNodeDevicePtr dev,
                           char **const names,
                           int maxnames)
 {
-    DEBUG("dev=%p, conn=%p, names=%p, maxnames=%d",
+    VIR_DEBUG("dev=%p, conn=%p, names=%p, maxnames=%d",
           dev, dev ? dev->conn : NULL, names, maxnames);

     virResetLastError();
@@ -9498,7 +9498,7 @@ error:
  */
 int virNodeDeviceFree(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9541,7 +9541,7 @@ virNodeDeviceRef(virNodeDevicePtr dev)
         return -1;
     }
     virMutexLock(&dev->conn->lock);
-    DEBUG("dev=%p refs=%d", dev, dev->refs);
+    VIR_DEBUG("dev=%p refs=%d", dev, dev->refs);
     dev->refs++;
     virMutexUnlock(&dev->conn->lock);
     return 0;
@@ -9569,7 +9569,7 @@ virNodeDeviceRef(virNodeDevicePtr dev)
 int
 virNodeDeviceDettach(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9612,7 +9612,7 @@ error:
 int
 virNodeDeviceReAttach(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9657,7 +9657,7 @@ error:
 int
 virNodeDeviceReset(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
+    VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

     virResetLastError();

@@ -9747,7 +9747,7 @@ error:
 int
 virNodeDeviceDestroy(virNodeDevicePtr dev)
 {
-    DEBUG("dev=%p", dev);
+    VIR_DEBUG("dev=%p", dev);

     virResetLastError();

@@ -9813,7 +9813,7 @@ virConnectDomainEventRegister(virConnectPtr conn,
                               void *opaque,
                               virFreeCallback freecb)
 {
-    DEBUG("conn=%p, cb=%p, opaque=%p, freecb=%p", conn, cb, opaque, freecb);
+    VIR_DEBUG("conn=%p, cb=%p, opaque=%p, freecb=%p", conn, cb, opaque, freecb);
     virResetLastError();

     if (!VIR_IS_CONNECT(conn)) {
@@ -9858,7 +9858,7 @@ int
 virConnectDomainEventDeregister(virConnectPtr conn,
                                 virConnectDomainEventCallback cb)
 {
-    DEBUG("conn=%p, cb=%p", conn, cb);
+    VIR_DEBUG("conn=%p, cb=%p", conn, cb);

     virResetLastError();

@@ -9900,7 +9900,7 @@ error:
 virConnectPtr
 virSecretGetConnect (virSecretPtr secret)
 {
-    DEBUG("secret=%p", secret);
+    VIR_DEBUG("secret=%p", secret);

     virResetLastError();

@@ -10007,7 +10007,7 @@ error:
 virSecretPtr
 virSecretLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 {
-    DEBUG("conn=%p, uuid=%s", conn, uuid);
+    VIR_DEBUG("conn=%p, uuid=%s", conn, uuid);

     virResetLastError();

@@ -10052,7 +10052,7 @@ virSecretPtr
 virSecretLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);

     virResetLastError();

@@ -10097,7 +10097,7 @@ virSecretLookupByUsage(virConnectPtr conn,
                        int usageType,
                        const char *usageID)
 {
-    DEBUG("conn=%p, usageType=%d usageID=%s", conn, usageType, NULLSTR(usageID));
+    VIR_DEBUG("conn=%p, usageType=%d usageID=%s", conn, usageType, NULLSTR(usageID));

     virResetLastError();

@@ -10227,7 +10227,7 @@ int
 virSecretGetUUIDString(virSecretPtr secret, char *buf)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("secret=%p, buf=%p", secret, buf);
+    VIR_DEBUG("secret=%p, buf=%p", secret, buf);

     virResetLastError();

@@ -10268,7 +10268,7 @@ error:
 int
 virSecretGetUsageType(virSecretPtr secret)
 {
-    DEBUG("secret=%p", secret);
+    VIR_DEBUG("secret=%p", secret);

     virResetLastError();

@@ -10299,7 +10299,7 @@ virSecretGetUsageType(virSecretPtr secret)
 const char *
 virSecretGetUsageID(virSecretPtr secret)
 {
-    DEBUG("secret=%p", secret);
+    VIR_DEBUG("secret=%p", secret);

     virResetLastError();

@@ -10530,7 +10530,7 @@ virSecretRef(virSecretPtr secret)
         return -1;
     }
     virMutexLock(&secret->conn->lock);
-    DEBUG("secret=%p refs=%d", secret, secret->refs);
+    VIR_DEBUG("secret=%p refs=%d", secret, secret->refs);
     secret->refs++;
     virMutexUnlock(&secret->conn->lock);
     return 0;
@@ -10547,7 +10547,7 @@ virSecretRef(virSecretPtr secret)
 int
 virSecretFree(virSecretPtr secret)
 {
-    DEBUG("secret=%p", secret);
+    VIR_DEBUG("secret=%p", secret);

     virResetLastError();

@@ -10589,7 +10589,7 @@ virStreamNew(virConnectPtr conn,
 {
     virStreamPtr st;

-    DEBUG("conn=%p, flags=%u", conn, flags);
+    VIR_DEBUG("conn=%p, flags=%u", conn, flags);

     virResetLastError();

@@ -10627,7 +10627,7 @@ virStreamRef(virStreamPtr stream)
         return -1;
     }
     virMutexLock(&stream->conn->lock);
-    DEBUG("stream=%p refs=%d", stream, stream->refs);
+    VIR_DEBUG("stream=%p refs=%d", stream, stream->refs);
     stream->refs++;
     virMutexUnlock(&stream->conn->lock);
     return 0;
@@ -10702,7 +10702,7 @@ int virStreamSend(virStreamPtr stream,
                   const char *data,
                   size_t nbytes)
 {
-    DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes);
+    VIR_DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes);

     virResetLastError();

@@ -10797,7 +10797,7 @@ int virStreamRecv(virStreamPtr stream,
                   char *data,
                   size_t nbytes)
 {
-    DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes);
+    VIR_DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes);

     virResetLastError();

@@ -10873,7 +10873,7 @@ int virStreamSendAll(virStreamPtr stream,
     char *bytes = NULL;
     int want = 1024*64;
     int ret = -1;
-    DEBUG("stream=%p, handler=%p, opaque=%p", stream, handler, opaque);
+    VIR_DEBUG("stream=%p, handler=%p, opaque=%p", stream, handler, opaque);

     virResetLastError();

@@ -10970,7 +10970,7 @@ int virStreamRecvAll(virStreamPtr stream,
     char *bytes = NULL;
     int want = 1024*64;
     int ret = -1;
-    DEBUG("stream=%p, handler=%p, opaque=%p", stream, handler, opaque);
+    VIR_DEBUG("stream=%p, handler=%p, opaque=%p", stream, handler, opaque);

     virResetLastError();

@@ -11042,7 +11042,7 @@ int virStreamEventAddCallback(virStreamPtr stream,
                               void *opaque,
                               virFreeCallback ff)
 {
-    DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", stream, events, cb, opaque, ff);
+    VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", stream, events, cb, opaque, ff);

     virResetLastError();

@@ -11084,7 +11084,7 @@ error:
 int virStreamEventUpdateCallback(virStreamPtr stream,
                                  int events)
 {
-    DEBUG("stream=%p, events=%d", stream, events);
+    VIR_DEBUG("stream=%p, events=%d", stream, events);

     virResetLastError();

@@ -11120,7 +11120,7 @@ error:
  */
 int virStreamEventRemoveCallback(virStreamPtr stream)
 {
-    DEBUG("stream=%p", stream);
+    VIR_DEBUG("stream=%p", stream);

     virResetLastError();

@@ -11163,7 +11163,7 @@ error:
  */
 int virStreamFinish(virStreamPtr stream)
 {
-    DEBUG("stream=%p", stream);
+    VIR_DEBUG("stream=%p", stream);

     virResetLastError();

@@ -11204,7 +11204,7 @@ error:
  */
 int virStreamAbort(virStreamPtr stream)
 {
-    DEBUG("stream=%p", stream);
+    VIR_DEBUG("stream=%p", stream);

     virResetLastError();

@@ -11246,7 +11246,7 @@ error:
  */
 int virStreamFree(virStreamPtr stream)
 {
-    DEBUG("stream=%p", stream);
+    VIR_DEBUG("stream=%p", stream);

     virResetLastError();

@@ -11276,7 +11276,7 @@ int virStreamFree(virStreamPtr stream)
  */
 int virDomainIsActive(virDomainPtr dom)
 {
-    DEBUG("dom=%p", dom);
+    VIR_DEBUG("dom=%p", dom);

     virResetLastError();

@@ -11376,7 +11376,7 @@ error:
  */
 int virNetworkIsActive(virNetworkPtr net)
 {
-    DEBUG("net=%p", net);
+    VIR_DEBUG("net=%p", net);

     virResetLastError();

@@ -11411,7 +11411,7 @@ error:
  */
 int virNetworkIsPersistent(virNetworkPtr net)
 {
-    DEBUG("net=%p", net);
+    VIR_DEBUG("net=%p", net);

     virResetLastError();

@@ -11445,7 +11445,7 @@ error:
  */
 int virStoragePoolIsActive(virStoragePoolPtr pool)
 {
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -11480,7 +11480,7 @@ error:
  */
 int virStoragePoolIsPersistent(virStoragePoolPtr pool)
 {
-    DEBUG("pool=%p", pool);
+    VIR_DEBUG("pool=%p", pool);

     virResetLastError();

@@ -11516,7 +11516,7 @@ error:
 int
 virConnectNumOfNWFilters(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -11555,7 +11555,7 @@ error:
 int
 virConnectListNWFilters(virConnectPtr conn, char **const names, int maxnames)
 {
-    DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
+    VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);

     virResetLastError();

@@ -11599,7 +11599,7 @@ error:
 virNWFilterPtr
 virNWFilterLookupByName(virConnectPtr conn, const char *name)
 {
-    DEBUG("conn=%p, name=%s", conn, name);
+    VIR_DEBUG("conn=%p, name=%s", conn, name);

     virResetLastError();

@@ -11641,7 +11641,7 @@ error:
 virNWFilterPtr
 virNWFilterLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 {
-    DEBUG("conn=%p, uuid=%s", conn, uuid);
+    VIR_DEBUG("conn=%p, uuid=%s", conn, uuid);

     virResetLastError();

@@ -11684,7 +11684,7 @@ virNWFilterPtr
 virNWFilterLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);
+    VIR_DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);

     virResetLastError();

@@ -11722,7 +11722,7 @@ error:
 int
 virNWFilterFree(virNWFilterPtr nwfilter)
 {
-    DEBUG("nwfilter=%p", nwfilter);
+    VIR_DEBUG("nwfilter=%p", nwfilter);

     virResetLastError();

@@ -11750,7 +11750,7 @@ virNWFilterFree(virNWFilterPtr nwfilter)
 const char *
 virNWFilterGetName(virNWFilterPtr nwfilter)
 {
-    DEBUG("nwfilter=%p", nwfilter);
+    VIR_DEBUG("nwfilter=%p", nwfilter);

     virResetLastError();

@@ -11774,7 +11774,7 @@ virNWFilterGetName(virNWFilterPtr nwfilter)
 int
 virNWFilterGetUUID(virNWFilterPtr nwfilter, unsigned char *uuid)
 {
-    DEBUG("nwfilter=%p, uuid=%p", nwfilter, uuid);
+    VIR_DEBUG("nwfilter=%p, uuid=%p", nwfilter, uuid);

     virResetLastError();

@@ -11811,7 +11811,7 @@ int
 virNWFilterGetUUIDString(virNWFilterPtr nwfilter, char *buf)
 {
     unsigned char uuid[VIR_UUID_BUFLEN];
-    DEBUG("nwfilter=%p, buf=%p", nwfilter, buf);
+    VIR_DEBUG("nwfilter=%p, buf=%p", nwfilter, buf);

     virResetLastError();

@@ -11850,7 +11850,7 @@ error:
 virNWFilterPtr
 virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc)
 {
-    DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);
+    VIR_DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);

     virResetLastError();

@@ -11898,7 +11898,7 @@ int
 virNWFilterUndefine(virNWFilterPtr nwfilter)
 {
     virConnectPtr conn;
-    DEBUG("nwfilter=%p", nwfilter);
+    VIR_DEBUG("nwfilter=%p", nwfilter);

     virResetLastError();

@@ -11945,7 +11945,7 @@ char *
 virNWFilterGetXMLDesc(virNWFilterPtr nwfilter, int flags)
 {
     virConnectPtr conn;
-    DEBUG("nwfilter=%p, flags=%d", nwfilter, flags);
+    VIR_DEBUG("nwfilter=%p, flags=%d", nwfilter, flags);

     virResetLastError();

@@ -12003,7 +12003,7 @@ virNWFilterRef(virNWFilterPtr nwfilter)
         return -1;
     }
     virMutexLock(&nwfilter->conn->lock);
-    DEBUG("nwfilter=%p refs=%d", nwfilter, nwfilter->refs);
+    VIR_DEBUG("nwfilter=%p refs=%d", nwfilter, nwfilter->refs);
     nwfilter->refs++;
     virMutexUnlock(&nwfilter->conn->lock);
     return 0;
@@ -12020,7 +12020,7 @@ virNWFilterRef(virNWFilterPtr nwfilter)
  */
 int virInterfaceIsActive(virInterfacePtr iface)
 {
-    DEBUG("iface=%p", iface);
+    VIR_DEBUG("iface=%p", iface);

     virResetLastError();

@@ -12054,7 +12054,7 @@ error:
  */
 int virConnectIsEncrypted(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -12091,7 +12091,7 @@ error:
  */
 int virConnectIsSecure(virConnectPtr conn)
 {
-    DEBUG("conn=%p", conn);
+    VIR_DEBUG("conn=%p", conn);

     virResetLastError();

@@ -12451,7 +12451,7 @@ int
 virConnectDomainEventDeregisterAny(virConnectPtr conn,
                                    int callbackID)
 {
-    DEBUG("conn=%p, callbackID=%d", conn, callbackID);
+    VIR_DEBUG("conn=%p, callbackID=%d", conn, callbackID);

     virResetLastError();

@@ -12681,7 +12681,7 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
                             unsigned int flags)
 {
     virConnectPtr conn;
-    DEBUG("snapshot=%p, flags=%d", snapshot, flags);
+    VIR_DEBUG("snapshot=%p, flags=%d", snapshot, flags);

     virResetLastError();

@@ -12950,7 +12950,7 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
 {
     virConnectPtr conn;

-    DEBUG("snapshot=%p, flags=%u", snapshot, flags);
+    VIR_DEBUG("snapshot=%p, flags=%u", snapshot, flags);

     virResetLastError();

@@ -12996,7 +12996,7 @@ virDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
 {
     virConnectPtr conn;

-    DEBUG("snapshot=%p, flags=%u", snapshot, flags);
+    VIR_DEBUG("snapshot=%p, flags=%u", snapshot, flags);

     virResetLastError();

@@ -13034,7 +13034,7 @@ error:
 int
 virDomainSnapshotFree(virDomainSnapshotPtr snapshot)
 {
-    DEBUG("snapshot=%p", snapshot);
+    VIR_DEBUG("snapshot=%p", snapshot);

     virResetLastError();

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index a735eb7..d973984 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -227,7 +227,7 @@ static int lxcContainerWaitForContinue(int control)
     }
     VIR_FORCE_CLOSE(control);

-    DEBUG0("Received container continue message");
+    VIR_DEBUG0("Received container continue message");

     return 0;
 }
@@ -258,12 +258,12 @@ static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
             goto error_out;
         }

-        DEBUG("Renaming %s to %s", veths[i], newname);
+        VIR_DEBUG("Renaming %s to %s", veths[i], newname);
         rc = setInterfaceName(veths[i], newname);
         if (rc < 0)
             goto error_out;

-        DEBUG("Enabling %s", newname);
+        VIR_DEBUG("Enabling %s", newname);
         rc = vethInterfaceUpOrDown(newname, 1);
         if (rc < 0)
             goto error_out;
@@ -854,18 +854,18 @@ int lxcContainerStart(virDomainDefPtr def,
     flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD;

     if (userns_supported()) {
-        DEBUG0("Enable user namespaces");
+        VIR_DEBUG0("Enable user namespaces");
         flags |= CLONE_NEWUSER;
     }

     if (def->nets != NULL) {
-        DEBUG0("Enable network namespaces");
+        VIR_DEBUG0("Enable network namespaces");
         flags |= CLONE_NEWNET;
     }

     pid = clone(lxcContainerChild, stacktop, flags, &args);
     VIR_FREE(stack);
-    DEBUG("clone() completed, new container PID is %d", pid);
+    VIR_DEBUG("clone() completed, new container PID is %d", pid);

     if (pid < 0) {
         virReportSystemError(errno, "%s",
@@ -897,7 +897,7 @@ int lxcContainerAvailable(int features)
         flags |= CLONE_NEWNET;

     if (VIR_ALLOC_N(stack, getpagesize() * 4) < 0) {
-        DEBUG0("Unable to allocate stack");
+        VIR_DEBUG0("Unable to allocate stack");
         return -1;
     }

@@ -907,7 +907,7 @@ int lxcContainerAvailable(int features)
     VIR_FREE(stack);
     if (cpid < 0) {
         char ebuf[1024];
-        DEBUG("clone call returned %s, container support is not enabled",
+        VIR_DEBUG("clone call returned %s, container support is not enabled",
               virStrerror(errno, ebuf, sizeof ebuf));
         return -1;
     } else {
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 0db6673..b742a33 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -446,7 +446,7 @@ static int lxcControllerMain(int monitor,
                         ++numActive;
                     }
                 } else if (epollEvent.events & EPOLLHUP) {
-                    DEBUG("EPOLLHUP from fd %d", epollEvent.data.fd);
+                    VIR_DEBUG("EPOLLHUP from fd %d", epollEvent.data.fd);
                     continue;
                 } else {
                     lxcError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 0f78579..a17b0b6 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -979,7 +979,7 @@ static int lxcVmCleanup(lxc_driver_t *driver,
                              vm->pid, waitRc);
         rc = -1;
     } else if (WIFEXITED(childStatus)) {
-        DEBUG("container exited with rc: %d", WEXITSTATUS(childStatus));
+        VIR_DEBUG("container exited with rc: %d", WEXITSTATUS(childStatus));
         rc = -1;
     }

@@ -1086,18 +1086,18 @@ static int lxcSetupInterfaces(virConnectPtr conn,
             break;
         }

-        DEBUG("bridge: %s", bridge);
+        VIR_DEBUG("bridge: %s", bridge);
         if (NULL == bridge) {
             lxcError(VIR_ERR_INTERNAL_ERROR,
                      "%s", _("Failed to get bridge for interface"));
             goto error_exit;
         }

-        DEBUG0("calling vethCreate()");
+        VIR_DEBUG0("calling vethCreate()");
         parentVeth = def->nets[i]->ifname;
         if (vethCreate(&parentVeth, &containerVeth) < 0)
             goto error_exit;
-        DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth);
+        VIR_DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth);

         if (NULL == def->nets[i]->ifname) {
             def->nets[i]->ifname = parentVeth;
diff --git a/src/lxc/veth.c b/src/lxc/veth.c
index 14cfaa2..78e011e 100644
--- a/src/lxc/veth.c
+++ b/src/lxc/veth.c
@@ -99,13 +99,13 @@ int vethCreate(char** veth1, char** veth2)
     int vethDev = 0;
     bool veth1_alloc = false;

-    DEBUG("veth1: %s veth2: %s", NULLSTR(*veth1), NULLSTR(*veth2));
+    VIR_DEBUG("veth1: %s veth2: %s", NULLSTR(*veth1), NULLSTR(*veth2));

     if (*veth1 == NULL) {
         vethDev = getFreeVethName(veth1, vethDev);
         if (vethDev < 0)
             return vethDev;
-        DEBUG("Assigned veth1: %s", *veth1);
+        VIR_DEBUG("Assigned veth1: %s", *veth1);
         veth1_alloc = true;
     }
     argv[3] = *veth1;
@@ -118,11 +118,11 @@ int vethCreate(char** veth1, char** veth2)
                 VIR_FREE(*veth1);
             return vethDev;
         }
-        DEBUG("Assigned veth2: %s", *veth2);
+        VIR_DEBUG("Assigned veth2: %s", *veth2);
     }
     argv[8] = *veth2;

-    DEBUG("veth1: %s veth2: %s", *veth1, *veth2);
+    VIR_DEBUG("veth1: %s veth2: %s", *veth1, *veth2);
     rc = virRun(argv, &cmdResult);

     if (rc != 0 ||
@@ -156,7 +156,7 @@ int vethDelete(const char *veth)
     const char *argv[] = {"ip", "link", "del", veth, NULL};
     int cmdResult = 0;

-    DEBUG("veth: %s", veth);
+    VIR_DEBUG("veth: %s", veth);

     rc = virRun(argv, &cmdResult);

diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 547e5ca..3af2bcf 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -483,7 +483,7 @@ static void dev_create(const char *udi)
     return;

  failure:
-    DEBUG("FAILED TO ADD dev %s", name);
+    VIR_DEBUG("FAILED TO ADD dev %s", name);
 cleanup:
     VIR_FREE(privData);
     virNodeDeviceDefFree(def);
@@ -503,7 +503,7 @@ static void dev_refresh(const char *udi)
          */
         virNodeDeviceObjRemove(&driverState->devs, dev);
     } else
-        DEBUG("no device named %s", name);
+        VIR_DEBUG("no device named %s", name);
     nodeDeviceUnlock(driverState);

     if (dev) {
@@ -514,7 +514,7 @@ static void dev_refresh(const char *udi)
 static void device_added(LibHalContext *ctx ATTRIBUTE_UNUSED,
                          const char *udi)
 {
-    DEBUG0(hal_name(udi));
+    VIR_DEBUG0(hal_name(udi));
     dev_create(udi);
 }

@@ -527,11 +527,11 @@ static void device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED,

     nodeDeviceLock(driverState);
     dev = virNodeDeviceFindByName(&driverState->devs,name);
-    DEBUG0(name);
+    VIR_DEBUG0(name);
     if (dev)
         virNodeDeviceObjRemove(&driverState->devs, dev);
     else
-        DEBUG("no device named %s", name);
+        VIR_DEBUG("no device named %s", name);
     nodeDeviceUnlock(driverState);
 }

@@ -545,12 +545,12 @@ static void device_cap_added(LibHalContext *ctx,
     nodeDeviceLock(driverState);
     dev = virNodeDeviceFindByName(&driverState->devs,name);
     nodeDeviceUnlock(driverState);
-    DEBUG("%s %s", cap, name);
+    VIR_DEBUG("%s %s", cap, name);
     if (dev) {
         (void)gather_capability(ctx, udi, cap, &dev->def->caps);
         virNodeDeviceObjUnlock(dev);
     } else {
-        DEBUG("no device named %s", name);
+        VIR_DEBUG("no device named %s", name);
     }
 }

@@ -560,7 +560,7 @@ static void device_cap_lost(LibHalContext *ctx ATTRIBUTE_UNUSED,
                             const char *cap)
 {
     const char *name = hal_name(udi);
-    DEBUG("%s %s", cap, name);
+    VIR_DEBUG("%s %s", cap, name);

     dev_refresh(udi);
 }
@@ -573,7 +573,7 @@ static void device_prop_modified(LibHalContext *ctx ATTRIBUTE_UNUSED,
                                  dbus_bool_t is_added ATTRIBUTE_UNUSED)
 {
     const char *name = hal_name(udi);
-    DEBUG("%s %s", name, key);
+    VIR_DEBUG("%s %s", name, key);

     dev_refresh(udi);
 }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 82a2210..21bb77d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1949,7 +1949,7 @@ qemudInitCpuAffinity(virDomainObjPtr vm)
     unsigned char *cpumap;
     int cpumaplen;

-    DEBUG0("Setting CPU affinity");
+    VIR_DEBUG0("Setting CPU affinity");

     if (nodeGetInfo(NULL, &nodeinfo) < 0)
         return -1;
@@ -2636,7 +2636,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
     hookData.vm = vm;
     hookData.driver = driver;

-    DEBUG0("Beginning VM startup process");
+    VIR_DEBUG0("Beginning VM startup process");

     if (virDomainObjIsActive(vm)) {
         qemuReportError(VIR_ERR_OPERATION_INVALID,
@@ -2648,18 +2648,18 @@ static int qemudStartVMDaemon(virConnectPtr conn,
      * runtime state to vm->def that won't be persisted. This let's us
      * report implicit runtime defaults in the XML, like vnc listen/socket
      */
-    DEBUG0("Setting current domain def as transient");
+    VIR_DEBUG0("Setting current domain def as transient");
     if (virDomainObjSetDefTransient(driver->caps, vm, true) < 0)
         goto cleanup;

     vm->def->id = driver->nextvmid++;

     /* Must be run before security labelling */
-    DEBUG0("Preparing host devices");
+    VIR_DEBUG0("Preparing host devices");
     if (qemuPrepareHostDevices(driver, vm->def) < 0)
         goto cleanup;

-    DEBUG0("Preparing chr devices");
+    VIR_DEBUG0("Preparing chr devices");
     if (virDomainChrDefForeach(vm->def,
                                true,
                                qemuPrepareChardevDevice,
@@ -2668,14 +2668,14 @@ static int qemudStartVMDaemon(virConnectPtr conn,

     /* If you are using a SecurityDriver with dynamic labelling,
        then generate a security label for isolation */
-    DEBUG0("Generating domain security label (if required)");
+    VIR_DEBUG0("Generating domain security label (if required)");
     if (virSecurityManagerGenLabel(driver->securityManager, vm) < 0) {
         qemuDomainSecurityLabelAudit(vm, false);
         goto cleanup;
     }
     qemuDomainSecurityLabelAudit(vm, true);

-    DEBUG0("Generating setting domain security labels (if required)");
+    VIR_DEBUG0("Generating setting domain security labels (if required)");
     if (virSecurityManagerSetAllLabel(driver->securityManager,
                                       vm, stdin_path) < 0)
         goto cleanup;
@@ -2686,7 +2686,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
          */
         struct stat stdin_sb;

-        DEBUG0("setting security label on pipe used for migration");
+        VIR_DEBUG0("setting security label on pipe used for migration");

         if (fstat(stdin_fd, &stdin_sb) < 0) {
             virReportSystemError(errno,
@@ -2700,7 +2700,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,

     /* Ensure no historical cgroup for this VM is lying around bogus
      * settings */
-    DEBUG0("Ensuring no historical cgroup is lying around");
+    VIR_DEBUG0("Ensuring no historical cgroup is lying around");
     qemuRemoveCgroup(driver, vm, 1);

     if (vm->def->ngraphics == 1) {
@@ -2746,17 +2746,17 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         goto cleanup;
     }

-    DEBUG0("Creating domain log file");
+    VIR_DEBUG0("Creating domain log file");
     if ((logfile = qemudLogFD(driver, vm->def->name, false)) < 0)
         goto cleanup;

-    DEBUG0("Determining emulator version");
+    VIR_DEBUG0("Determining emulator version");
     if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto cleanup;

-    DEBUG0("Setting up domain cgroup (if required)");
+    VIR_DEBUG0("Setting up domain cgroup (if required)");
     if (qemuSetupCgroup(driver, vm) < 0)
         goto cleanup;

@@ -2765,7 +2765,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         goto cleanup;
     }

-    DEBUG0("Preparing monitor state");
+    VIR_DEBUG0("Preparing monitor state");
     if (qemuPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0)
         goto cleanup;

@@ -2800,7 +2800,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
      * use in hotplug
      */
     if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
-        DEBUG0("Assigning domain PCI addresses");
+        VIR_DEBUG0("Assigning domain PCI addresses");
         /* Populate cache with current addresses */
         if (priv->pciaddrs) {
             qemuDomainPCIAddressSetFree(priv->pciaddrs);
@@ -2819,7 +2819,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         priv->persistentAddrs = 0;
     }

-    DEBUG0("Building emulator command line");
+    VIR_DEBUG0("Building emulator command line");
     if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig,
                                      priv->monJSON != 0, qemuCmdFlags,
                                      migrateFrom, stdin_fd,
@@ -2916,27 +2916,27 @@ static int qemudStartVMDaemon(virConnectPtr conn,
     if (ret == -1) /* The VM failed to start */
         goto cleanup;

-    DEBUG0("Waiting for monitor to show up");
+    VIR_DEBUG0("Waiting for monitor to show up");
     if (qemudWaitForMonitor(driver, vm, pos) < 0)
         goto cleanup;

-    DEBUG0("Detecting VCPU PIDs");
+    VIR_DEBUG0("Detecting VCPU PIDs");
     if (qemuDetectVcpuPIDs(driver, vm) < 0)
         goto cleanup;

-    DEBUG0("Setting any required VM passwords");
+    VIR_DEBUG0("Setting any required VM passwords");
     if (qemuInitPasswords(conn, driver, vm, qemuCmdFlags) < 0)
         goto cleanup;

     /* If we have -device, then addresses are assigned explicitly.
      * If not, then we have to detect dynamic ones here */
     if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
-        DEBUG0("Determining domain device PCI addresses");
+        VIR_DEBUG0("Determining domain device PCI addresses");
         if (qemuInitPCIAddresses(driver, vm) < 0)
             goto cleanup;
     }

-    DEBUG0("Setting initial memory amount");
+    VIR_DEBUG0("Setting initial memory amount");
     qemuDomainObjEnterMonitorWithDriver(driver, vm);
     if (qemuMonitorSetBalloon(priv->mon, vm->def->mem.cur_balloon) < 0) {
         qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -2945,7 +2945,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
     qemuDomainObjExitMonitorWithDriver(driver, vm);

     if (!start_paused) {
-        DEBUG0("Starting domain CPUs");
+        VIR_DEBUG0("Starting domain CPUs");
         /* Allow the CPUS to start executing */
         if (doStartCPUs(driver, vm, conn) < 0) {
             if (virGetLastError() == NULL)
@@ -2956,7 +2956,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
     }


-    DEBUG0("Writing domain status to disk");
+    VIR_DEBUG0("Writing domain status to disk");
     if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
         goto cleanup;

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index e3d0a0f..dfb1aad 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -903,7 +903,7 @@ int qemuMonitorEmitGraphics(qemuMonitorPtr mon,
 int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -924,7 +924,7 @@ qemuMonitorStartCPUs(qemuMonitorPtr mon,
                      virConnectPtr conn)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -944,7 +944,7 @@ int
 qemuMonitorStopCPUs(qemuMonitorPtr mon)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -963,7 +963,7 @@ qemuMonitorStopCPUs(qemuMonitorPtr mon)
 int qemuMonitorSystemPowerdown(qemuMonitorPtr mon)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -983,7 +983,7 @@ int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
                           int **pids)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1002,7 +1002,7 @@ int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
                               unsigned long *currmem)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1023,7 +1023,7 @@ int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
                               unsigned int nr_stats)
 {
     int ret;
-    DEBUG("mon=%p stats=%p nstats=%u", mon, stats, nr_stats);
+    VIR_DEBUG("mon=%p stats=%p nstats=%u", mon, stats, nr_stats);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1048,7 +1048,7 @@ int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon,
                                  long long *errs)
 {
     int ret;
-    DEBUG("mon=%p dev=%s", mon, devname);
+    VIR_DEBUG("mon=%p dev=%s", mon, devname);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1074,7 +1074,7 @@ int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
                               unsigned long long *extent)
 {
     int ret;
-    DEBUG("mon=%p, fd=%d, devname=%p",
+    VIR_DEBUG("mon=%p, fd=%d, devname=%p",
           mon, mon->fd, devname);

     if (mon->json)
@@ -1090,7 +1090,7 @@ int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
                               const char *password)
 {
     int ret;
-    DEBUG("mon=%p, password=%p",
+    VIR_DEBUG("mon=%p, password=%p",
           mon, password);

     if (!mon) {
@@ -1136,7 +1136,7 @@ int qemuMonitorSetPassword(qemuMonitorPtr mon,
     if (!protocol)
         return -1;

-    DEBUG("mon=%p, protocol=%s, password=%p, action_if_connected=%s",
+    VIR_DEBUG("mon=%p, protocol=%s, password=%p, action_if_connected=%s",
           mon, protocol, password, action_if_connected);

     if (!mon) {
@@ -1168,7 +1168,7 @@ int qemuMonitorExpirePassword(qemuMonitorPtr mon,
     if (!protocol)
         return -1;

-    DEBUG("mon=%p, protocol=%s, expire_time=%s",
+    VIR_DEBUG("mon=%p, protocol=%s, expire_time=%s",
           mon, protocol, expire_time);

     if (!mon) {
@@ -1191,7 +1191,7 @@ int qemuMonitorSetBalloon(qemuMonitorPtr mon,
                           unsigned long newmem)
 {
     int ret;
-    DEBUG("mon=%p newmem=%lu", mon, newmem);
+    VIR_DEBUG("mon=%p newmem=%lu", mon, newmem);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1210,7 +1210,7 @@ int qemuMonitorSetBalloon(qemuMonitorPtr mon,
 int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, int online)
 {
     int ret;
-    DEBUG("mon=%p cpu=%d online=%d", mon, cpu, online);
+    VIR_DEBUG("mon=%p cpu=%d online=%d", mon, cpu, online);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1231,7 +1231,7 @@ int qemuMonitorEjectMedia(qemuMonitorPtr mon,
                           bool force)
 {
     int ret;
-    DEBUG("mon=%p devname=%s force=%d", mon, devname, force);
+    VIR_DEBUG("mon=%p devname=%s force=%d", mon, devname, force);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1253,7 +1253,7 @@ int qemuMonitorChangeMedia(qemuMonitorPtr mon,
                            const char *format)
 {
     int ret;
-    DEBUG("mon=%p devname=%s newmedia=%s format=%s",
+    VIR_DEBUG("mon=%p devname=%s newmedia=%s format=%s",
           mon, devname, newmedia, format);

     if (!mon) {
@@ -1276,7 +1276,7 @@ int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
                                  const char *path)
 {
     int ret;
-    DEBUG("mon=%p offset=%llu length=%zu path=%s",
+    VIR_DEBUG("mon=%p offset=%llu length=%zu path=%s",
           mon, offset, length, path);

     if (!mon) {
@@ -1298,7 +1298,7 @@ int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon,
                                   const char *path)
 {
     int ret;
-    DEBUG("mon=%p offset=%llu length=%zu path=%s",
+    VIR_DEBUG("mon=%p offset=%llu length=%zu path=%s",
           mon, offset, length, path);

     if (!mon) {
@@ -1319,7 +1319,7 @@ int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon,
                                  unsigned long bandwidth)
 {
     int ret;
-    DEBUG("mon=%p bandwidth=%lu", mon, bandwidth);
+    VIR_DEBUG("mon=%p bandwidth=%lu", mon, bandwidth);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1339,7 +1339,7 @@ int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
                                     unsigned long long downtime)
 {
     int ret;
-    DEBUG("mon=%p downtime=%llu", mon, downtime);
+    VIR_DEBUG("mon=%p downtime=%llu", mon, downtime);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1362,7 +1362,7 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
                                   unsigned long long *total)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1390,7 +1390,7 @@ int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
                              int port)
 {
     int ret;
-    DEBUG("mon=%p hostname=%s port=%d flags=%u",
+    VIR_DEBUG("mon=%p hostname=%s port=%d flags=%u",
           mon, hostname, port, flags);

     if (!mon) {
@@ -1412,7 +1412,7 @@ int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
                                 const char * const *argv)
 {
     int ret;
-    DEBUG("mon=%p argv=%p flags=%u",
+    VIR_DEBUG("mon=%p argv=%p flags=%u",
           mon, argv, flags);

     if (!mon) {
@@ -1435,7 +1435,7 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
                              unsigned long long offset)
 {
     int ret;
-    DEBUG("mon=%p argv=%p target=%s offset=%llu flags=%u",
+    VIR_DEBUG("mon=%p argv=%p target=%s offset=%llu flags=%u",
           mon, argv, target, offset, flags);

     if (!mon) {
@@ -1463,7 +1463,7 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
                              const char *unixfile)
 {
     int ret;
-    DEBUG("mon=%p, unixfile=%s flags=%u",
+    VIR_DEBUG("mon=%p, unixfile=%s flags=%u",
           mon, unixfile, flags);

     if (!mon) {
@@ -1482,7 +1482,7 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon)
 {
     int ret;
-    DEBUG("mon=%p", mon);
+    VIR_DEBUG("mon=%p", mon);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1501,7 +1501,7 @@ int qemuMonitorAddUSBDisk(qemuMonitorPtr mon,
                           const char *path)
 {
     int ret;
-    DEBUG("mon=%p path=%s", mon, path);
+    VIR_DEBUG("mon=%p path=%s", mon, path);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1522,7 +1522,7 @@ int qemuMonitorAddUSBDeviceExact(qemuMonitorPtr mon,
                                  int dev)
 {
     int ret;
-    DEBUG("mon=%p bus=%d dev=%d", mon, bus, dev);
+    VIR_DEBUG("mon=%p bus=%d dev=%d", mon, bus, dev);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1542,7 +1542,7 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
                                  int product)
 {
     int ret;
-    DEBUG("mon=%p vendor=%d product=%d",
+    VIR_DEBUG("mon=%p vendor=%d product=%d",
           mon, vendor, product);

     if (!mon) {
@@ -1564,7 +1564,7 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
                                 virDomainDevicePCIAddress *guestAddr)
 {
     int ret;
-    DEBUG("mon=%p domain=%d bus=%d slot=%d function=%d",
+    VIR_DEBUG("mon=%p domain=%d bus=%d slot=%d function=%d",
           mon,
           hostAddr->domain, hostAddr->bus, hostAddr->slot, hostAddr->function);

@@ -1588,7 +1588,7 @@ int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
                           virDomainDevicePCIAddress *guestAddr)
 {
     int ret;
-    DEBUG("mon=%p path=%s bus=%s",
+    VIR_DEBUG("mon=%p path=%s bus=%s",
           mon, path, bus);

     if (!mon) {
@@ -1610,7 +1610,7 @@ int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
                              virDomainDevicePCIAddress *guestAddr)
 {
     int ret;
-    DEBUG("mon=%p nicstr=%s", mon, nicstr);
+    VIR_DEBUG("mon=%p nicstr=%s", mon, nicstr);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1630,7 +1630,7 @@ int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
                                virDomainDevicePCIAddress *guestAddr)
 {
     int ret;
-    DEBUG("mon=%p domain=%d bus=%d slot=%d function=%d",
+    VIR_DEBUG("mon=%p domain=%d bus=%d slot=%d function=%d",
           mon, guestAddr->domain, guestAddr->bus,
           guestAddr->slot, guestAddr->function);

@@ -1653,7 +1653,7 @@ int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
                               int fd)
 {
     int ret;
-    DEBUG("mon=%p, fdname=%s fd=%d",
+    VIR_DEBUG("mon=%p, fdname=%s fd=%d",
           mon, fdname, fd);

     if (!mon) {
@@ -1674,7 +1674,7 @@ int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
                                const char *fdname)
 {
     int ret;
-    DEBUG("mon=%p fdname=%s",
+    VIR_DEBUG("mon=%p fdname=%s",
           mon, fdname);

     if (!mon) {
@@ -1695,7 +1695,7 @@ int qemuMonitorAddHostNetwork(qemuMonitorPtr mon,
                               const char *netstr)
 {
     int ret;
-    DEBUG("mon=%p netstr=%s",
+    VIR_DEBUG("mon=%p netstr=%s",
           mon, netstr);

     if (!mon) {
@@ -1717,7 +1717,7 @@ int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
                                  const char *netname)
 {
     int ret;
-    DEBUG("mon=%p netname=%s",
+    VIR_DEBUG("mon=%p netname=%s",
           mon, netname);

     if (!mon) {
@@ -1738,7 +1738,7 @@ int qemuMonitorAddNetdev(qemuMonitorPtr mon,
                          const char *netdevstr)
 {
     int ret;
-    DEBUG("mon=%p netdevstr=%s",
+    VIR_DEBUG("mon=%p netdevstr=%s",
           mon, netdevstr);

     if (!mon) {
@@ -1759,7 +1759,7 @@ int qemuMonitorRemoveNetdev(qemuMonitorPtr mon,
                             const char *alias)
 {
     int ret;
-    DEBUG("mon=%p alias=%s",
+    VIR_DEBUG("mon=%p alias=%s",
           mon, alias);

     if (!mon) {
@@ -1780,7 +1780,7 @@ int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
                            virHashTablePtr paths)
 {
     int ret;
-    DEBUG("mon=%p",
+    VIR_DEBUG("mon=%p",
           mon);

     if (!mon) {
@@ -1801,7 +1801,7 @@ int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                        const char *bus,
                                        virDomainDevicePCIAddress *guestAddr)
 {
-    DEBUG("mon=%p type=%s", mon, bus);
+    VIR_DEBUG("mon=%p type=%s", mon, bus);
     int ret;

     if (!mon) {
@@ -1824,7 +1824,7 @@ int qemuMonitorAttachDrive(qemuMonitorPtr mon,
                            virDomainDevicePCIAddress *controllerAddr,
                            virDomainDeviceDriveAddress *driveAddr)
 {
-    DEBUG("mon=%p drivestr=%s domain=%d bus=%d slot=%d function=%d",
+    VIR_DEBUG("mon=%p drivestr=%s domain=%d bus=%d slot=%d function=%d",
           mon, drivestr,
           controllerAddr->domain, controllerAddr->bus,
           controllerAddr->slot, controllerAddr->function);
@@ -1847,7 +1847,7 @@ int qemuMonitorAttachDrive(qemuMonitorPtr mon,
 int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon,
                                   qemuMonitorPCIAddress **addrs)
 {
-    DEBUG("mon=%p addrs=%p", mon, addrs);
+    VIR_DEBUG("mon=%p addrs=%p", mon, addrs);
     int ret;

     if (!mon) {
@@ -1866,7 +1866,7 @@ int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon,
 int qemuMonitorDriveDel(qemuMonitorPtr mon,
                         const char *drivestr)
 {
-    DEBUG("mon=%p drivestr=%s", mon, drivestr);
+    VIR_DEBUG("mon=%p drivestr=%s", mon, drivestr);
     int ret;

     if (!mon) {
@@ -1885,7 +1885,7 @@ int qemuMonitorDriveDel(qemuMonitorPtr mon,
 int qemuMonitorDelDevice(qemuMonitorPtr mon,
                          const char *devalias)
 {
-    DEBUG("mon=%p devalias=%s", mon, devalias);
+    VIR_DEBUG("mon=%p devalias=%s", mon, devalias);
     int ret;

     if (!mon) {
@@ -1905,7 +1905,7 @@ int qemuMonitorDelDevice(qemuMonitorPtr mon,
 int qemuMonitorAddDevice(qemuMonitorPtr mon,
                          const char *devicestr)
 {
-    DEBUG("mon=%p device=%s", mon, devicestr);
+    VIR_DEBUG("mon=%p device=%s", mon, devicestr);
     int ret;

     if (!mon) {
@@ -1924,7 +1924,7 @@ int qemuMonitorAddDevice(qemuMonitorPtr mon,
 int qemuMonitorAddDrive(qemuMonitorPtr mon,
                         const char *drivestr)
 {
-    DEBUG("mon=%p drive=%s", mon, drivestr);
+    VIR_DEBUG("mon=%p drive=%s", mon, drivestr);
     int ret;

     if (!mon) {
@@ -1945,7 +1945,7 @@ int qemuMonitorSetDrivePassphrase(qemuMonitorPtr mon,
                                   const char *alias,
                                   const char *passphrase)
 {
-    DEBUG("mon=%p alias=%s passphrase=%p(value hidden)", mon, alias, passphrase);
+    VIR_DEBUG("mon=%p alias=%s passphrase=%p(value hidden)", mon, alias, passphrase);
     int ret;

     if (!mon) {
@@ -1965,7 +1965,7 @@ int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name)
 {
     int ret;

-    DEBUG("mon=%p, name=%s",mon,name);
+    VIR_DEBUG("mon=%p, name=%s",mon,name);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1984,7 +1984,7 @@ int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name)
 {
     int ret;

-    DEBUG("mon=%p, name=%s",mon,name);
+    VIR_DEBUG("mon=%p, name=%s",mon,name);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -2003,7 +2003,7 @@ int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name)
 {
     int ret;

-    DEBUG("mon=%p, name=%s",mon,name);
+    VIR_DEBUG("mon=%p, name=%s",mon,name);

     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -2025,7 +2025,7 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
 {
     int ret;

-    DEBUG("mon=%p, cmd=%s, reply=%p, hmp=%d", mon, cmd, reply, hmp);
+    VIR_DEBUG("mon=%p, cmd=%s, reply=%p, hmp=%d", mon, cmd, reply, hmp);

     if (mon->json)
         ret = qemuMonitorJSONArbitraryCommand(mon, cmd, reply, hmp);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d5e8d37..e6903a1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2326,7 +2326,7 @@ int qemuMonitorJSONDriveDel(qemuMonitorPtr mon,
     virJSONValuePtr cmd;
     virJSONValuePtr reply = NULL;

-    DEBUG("JSONDriveDel drivestr=%s", drivestr);
+    VIR_DEBUG("JSONDriveDel drivestr=%s", drivestr);
     cmd = qemuMonitorJSONMakeCommand("drive_del",
                                      "s:id", drivestr,
                                      NULL);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 6d0ba4c..9acf65f 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -445,7 +445,7 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
         if (VIR_REALLOC_N(cpupids, ncpupids+1) < 0)
             goto error;

-        DEBUG("vcpu=%d pid=%d", vcpu, tid);
+        VIR_DEBUG("vcpu=%d pid=%d", vcpu, tid);
         cpupids[ncpupids++] = tid;
         lastVcpu = vcpu;

@@ -480,7 +480,7 @@ static int parseMemoryStat(char **text, unsigned int tag,
     if (STRPREFIX (*text, search)) {
         *text += strlen(search);
         if (virStrToLong_ull (*text, &dummy, 10, &value)) {
-            DEBUG ("error reading %s: %s", search, *text);
+            VIR_DEBUG ("error reading %s: %s", search, *text);
             return 0;
         }

@@ -671,21 +671,21 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
                 if (STRPREFIX (p, "rd_bytes=")) {
                     p += 9;
                     if (virStrToLong_ll (p, &dummy, 10, rd_bytes) == -1)
-                        DEBUG ("error reading rd_bytes: %s", p);
+                        VIR_DEBUG ("error reading rd_bytes: %s", p);
                 } else if (STRPREFIX (p, "wr_bytes=")) {
                     p += 9;
                     if (virStrToLong_ll (p, &dummy, 10, wr_bytes) == -1)
-                        DEBUG ("error reading wr_bytes: %s", p);
+                        VIR_DEBUG ("error reading wr_bytes: %s", p);
                 } else if (STRPREFIX (p, "rd_operations=")) {
                     p += 14;
                     if (virStrToLong_ll (p, &dummy, 10, rd_req) == -1)
-                        DEBUG ("error reading rd_req: %s", p);
+                        VIR_DEBUG ("error reading rd_req: %s", p);
                 } else if (STRPREFIX (p, "wr_operations=")) {
                     p += 14;
                     if (virStrToLong_ll (p, &dummy, 10, wr_req) == -1)
-                        DEBUG ("error reading wr_req: %s", p);
+                        VIR_DEBUG ("error reading wr_req: %s", p);
                 } else
-                    DEBUG ("unknown block stat near %s", p);
+                    VIR_DEBUG ("unknown block stat near %s", p);

                 /* Skip to next label. */
                 p = strchr (p, ' ');
@@ -2355,7 +2355,7 @@ int qemuMonitorTextDelDevice(qemuMonitorPtr mon,
         goto cleanup;
     }

-    DEBUG("TextDelDevice devalias=%s", devalias);
+    VIR_DEBUG("TextDelDevice devalias=%s", devalias);
     if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
         qemuReportError(VIR_ERR_OPERATION_FAILED,
                         _("cannot detach %s device"), devalias);
@@ -2471,7 +2471,7 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
     char *reply = NULL;
     char *safedev;
     int ret = -1;
-    DEBUG("TextDriveDel drivestr=%s", drivestr);
+    VIR_DEBUG("TextDriveDel drivestr=%s", drivestr);

     if (!(safedev = qemuMonitorEscapeArg(drivestr))) {
         virReportOOMError();
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 4ca0d3b..0be9c56 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -515,7 +515,7 @@ doRemoteOpen (virConnectPtr conn,
                 if (!pkipath) goto out_of_memory;
                 var->ignore = 1;
             } else {
-                DEBUG("passing through variable '%s' ('%s') to remote end",
+                VIR_DEBUG("passing through variable '%s' ('%s') to remote end",
                       var->name, var->value);
             }
         }
@@ -571,7 +571,7 @@ doRemoteOpen (virConnectPtr conn,
         goto failed;
     }

-    DEBUG("proceeding with name = %s", name);
+    VIR_DEBUG("proceeding with name = %s", name);

     /* For ext transport, command is required. */
     if (transport == trans_ext && !command) {
@@ -894,7 +894,7 @@ doRemoteOpen (virConnectPtr conn,
             goto failed;
         }

-        DEBUG("Auto-probed URI is %s", uriret.uri);
+        VIR_DEBUG("Auto-probed URI is %s", uriret.uri);
         conn->uri = xmlParseURI(uriret.uri);
         VIR_FREE(uriret.uri);
         if (!conn->uri) {
@@ -913,21 +913,21 @@ doRemoteOpen (virConnectPtr conn,
         goto failed;
     }

-    DEBUG0("Adding Handler for remote events");
+    VIR_DEBUG0("Adding Handler for remote events");
     /* Set up a callback to listen on the socket data */
     if ((priv->watch = virEventAddHandle(priv->sock,
                                          VIR_EVENT_HANDLE_READABLE,
                                          remoteDomainEventFired,
                                          conn, NULL)) < 0) {
-        DEBUG0("virEventAddHandle failed: No addHandleImpl defined."
+        VIR_DEBUG0("virEventAddHandle failed: No addHandleImpl defined."
                " continuing without events.");
     } else {

-        DEBUG0("Adding Timeout for remote event queue flushing");
+        VIR_DEBUG0("Adding Timeout for remote event queue flushing");
         if ( (priv->eventFlushTimer = virEventAddTimeout(-1,
                                                          remoteDomainEventQueueFlush,
                                                          conn, NULL)) < 0) {
-            DEBUG0("virEventAddTimeout failed: No addTimeoutImpl defined. "
+            VIR_DEBUG0("virEventAddTimeout failed: No addTimeoutImpl defined. "
                     "continuing without events.");
             virEventRemoveHandle(priv->watch);
             priv->watch = -1;
@@ -1076,7 +1076,7 @@ remoteOpen (virConnectPtr conn,
         (STREQ(conn->uri->path, "/session") ||
          STRPREFIX(conn->uri->scheme, "test+")) &&
         getuid() > 0) {
-        DEBUG0("Auto-spawn user daemon instance");
+        VIR_DEBUG0("Auto-spawn user daemon instance");
         rflags |= VIR_DRV_OPEN_REMOTE_USER;
         if (!autostart ||
             STRNEQ(autostart, "0"))
@@ -1090,10 +1090,10 @@ remoteOpen (virConnectPtr conn,
      * to the UNIX socket anyway.
      */
     if (!conn->uri) {
-        DEBUG0("Auto-probe remote URI");
+        VIR_DEBUG0("Auto-probe remote URI");
 #ifndef __sun
         if (getuid() > 0) {
-            DEBUG0("Auto-spawn user daemon instance");
+            VIR_DEBUG0("Auto-spawn user daemon instance");
             rflags |= VIR_DRV_OPEN_REMOTE_USER;
             if (!autostart ||
                 STRNEQ(autostart, "0"))
@@ -1142,7 +1142,7 @@ check_cert_file(const char *type, const char *file)


 static void remote_debug_gnutls_log(int level, const char* str) {
-    DEBUG("%d %s", level, str);
+    VIR_DEBUG("%d %s", level, str);
 }

 static int
@@ -1252,7 +1252,7 @@ initialize_gnutls(char *pkipath, int flags)
         goto error;

     /* Set the trusted CA cert. */
-    DEBUG("loading CA file %s", libvirt_cacert);
+    VIR_DEBUG("loading CA file %s", libvirt_cacert);
     err =
         gnutls_certificate_set_x509_trust_file (x509_cred, libvirt_cacert,
                                                 GNUTLS_X509_FMT_PEM);
@@ -1264,7 +1264,7 @@ initialize_gnutls(char *pkipath, int flags)
     }

     /* Set the client certificate and private key. */
-    DEBUG("loading client cert and key from files %s and %s",
+    VIR_DEBUG("loading client cert and key from files %s and %s",
           libvirt_clientcert, libvirt_clientkey);
     err =
         gnutls_certificate_set_x509_key_file (x509_cred,
@@ -1390,7 +1390,7 @@ negotiate_gnutls_on_connection (virConnectPtr conn,

     /* Verify certificate. */
     if (verify_certificate (conn, priv, session) == -1) {
-        DEBUG0("failed to verify peer's certificate");
+        VIR_DEBUG0("failed to verify peer's certificate");
         if (!no_verify) return NULL;
     }

@@ -7240,7 +7240,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
     int ret = -1;
     const char *mechlist;

-    DEBUG0("Client initialize SASL authentication");
+    VIR_DEBUG0("Client initialize SASL authentication");
     /* Sets up the SASL library as a whole */
     err = sasl_client_init(NULL);
     if (err != SASL_OK) {
@@ -7305,7 +7305,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
         }
         ssf *= 8; /* key size is bytes, sasl wants bits */

-        DEBUG("Setting external SSF %d", ssf);
+        VIR_DEBUG("Setting external SSF %d", ssf);
         err = sasl_setprop(saslconn, SASL_SSF_EXTERNAL, &ssf);
         if (err != SASL_OK) {
             remoteError(VIR_ERR_INTERNAL_ERROR,
@@ -7353,7 +7353,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
     }
  restart:
     /* Start the auth negotiation on the client end first */
-    DEBUG("Client start negotiation mechlist '%s'", mechlist);
+    VIR_DEBUG("Client start negotiation mechlist '%s'", mechlist);
     err = sasl_client_start(saslconn,
                             mechlist,
                             &interact,
@@ -7408,7 +7408,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
     sargs.data.data_val = (char*)clientout;
     sargs.data.data_len = clientoutlen;
     sargs.mech = (char*)mech;
-    DEBUG("Server start negotiation with mech %s. Data %d bytes %p", mech, clientoutlen, clientout);
+    VIR_DEBUG("Server start negotiation with mech %s. Data %d bytes %p", mech, clientoutlen, clientout);

     /* Now send the initial auth data to the server */
     memset (&sret, 0, sizeof sret);
@@ -7421,7 +7421,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
     /* NB, distinction of NULL vs "" is *critical* in SASL */
     serverin = sret.nil ? NULL : sret.data.data_val;
     serverinlen = sret.data.data_len;
-    DEBUG("Client step result complete: %d. Data %d bytes %p",
+    VIR_DEBUG("Client step result complete: %d. Data %d bytes %p",
           complete, serverinlen, serverin);

     /* Loop-the-loop...
@@ -7468,7 +7468,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
         }

         VIR_FREE(serverin);
-        DEBUG("Client step result %d. Data %d bytes %p", err, clientoutlen, clientout);
+        VIR_DEBUG("Client step result %d. Data %d bytes %p", err, clientoutlen, clientout);

         /* Previous server call showed completion & we're now locally complete too */
         if (complete && err == SASL_OK)
@@ -7480,7 +7480,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
         pargs.nil = clientout ? 0 : 1;
         pargs.data.data_val = (char*)clientout;
         pargs.data.data_len = clientoutlen;
-        DEBUG("Server step with %d bytes %p", clientoutlen, clientout);
+        VIR_DEBUG("Server step with %d bytes %p", clientoutlen, clientout);

         memset (&pret, 0, sizeof pret);
         if (call (conn, priv, in_open, REMOTE_PROC_AUTH_SASL_STEP,
@@ -7493,7 +7493,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
         serverin = pret.nil ? NULL : pret.data.data_val;
         serverinlen = pret.data.data_len;

-        DEBUG("Client step result complete: %d. Data %d bytes %p",
+        VIR_DEBUG("Client step result complete: %d. Data %d bytes %p",
               complete, serverinlen, serverin);

         /* This server call shows complete, and earlier client step was OK */
@@ -7513,7 +7513,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
             goto cleanup;
         }
         ssf = *(const int *)val;
-        DEBUG("SASL SSF value %d", ssf);
+        VIR_DEBUG("SASL SSF value %d", ssf);
         if (ssf < 56) { /* 56 == DES level, good for Kerberos */
             remoteError(VIR_ERR_AUTH_FAILED,
                         _("negotiation SSF %d was not strong enough"), ssf);
@@ -7522,7 +7522,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
         priv->is_secure = 1;
     }

-    DEBUG0("SASL authentication complete");
+    VIR_DEBUG0("SASL authentication complete");
     priv->saslconn = saslconn;
     ret = 0;

@@ -7548,7 +7548,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
                   virConnectAuthPtr auth ATTRIBUTE_UNUSED)
 {
     remote_auth_polkit_ret ret;
-    DEBUG0("Client initialize PolicyKit-1 authentication");
+    VIR_DEBUG0("Client initialize PolicyKit-1 authentication");

     memset (&ret, 0, sizeof ret);
     if (call (conn, priv, in_open, REMOTE_PROC_AUTH_POLKIT,
@@ -7557,7 +7557,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
         return -1; /* virError already set by call */
     }

-    DEBUG0("PolicyKit-1 authentication complete");
+    VIR_DEBUG0("PolicyKit-1 authentication complete");
     return 0;
 }
 # elif HAVE_POLKIT0
@@ -7577,7 +7577,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
         NULL,
         0,
     };
-    DEBUG0("Client initialize PolicyKit-0 authentication");
+    VIR_DEBUG0("Client initialize PolicyKit-0 authentication");

     if (auth && auth->cb) {
         /* Check if the necessary credential type for PolicyKit is supported */
@@ -7587,7 +7587,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
         }

         if (allowcb) {
-            DEBUG0("Client run callback for PolicyKit authentication");
+            VIR_DEBUG0("Client run callback for PolicyKit authentication");
             /* Run the authentication callback */
             if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
                 remoteError(VIR_ERR_AUTH_FAILED, "%s",
@@ -7595,10 +7595,10 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
                 return -1;
             }
         } else {
-            DEBUG0("Client auth callback does not support PolicyKit");
+            VIR_DEBUG0("Client auth callback does not support PolicyKit");
         }
     } else {
-        DEBUG0("No auth callback provided");
+        VIR_DEBUG0("No auth callback provided");
     }

     memset (&ret, 0, sizeof ret);
@@ -7608,7 +7608,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
         return -1; /* virError already set by call */
     }

-    DEBUG0("PolicyKit-0 authentication complete");
+    VIR_DEBUG0("PolicyKit-0 authentication complete");
     return 0;
 }
 # endif /* HAVE_POLKIT0 */
@@ -8330,7 +8330,7 @@ remoteStreamPacket(virStreamPtr st,
                    const char *data,
                    size_t nbytes)
 {
-    DEBUG("st=%p status=%d data=%p nbytes=%zu", st, status, data, nbytes);
+    VIR_DEBUG("st=%p status=%d data=%p nbytes=%zu", st, status, data, nbytes);
     struct private_data *priv = st->conn->privateData;
     struct private_stream_data *privst = st->privateData;
     XDR xdr;
@@ -8475,7 +8475,7 @@ remoteStreamSend(virStreamPtr st,
                  const char *data,
                  size_t nbytes)
 {
-    DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
+    VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
     struct private_data *priv = st->conn->privateData;
     int rv = -1;

@@ -8504,7 +8504,7 @@ remoteStreamRecv(virStreamPtr st,
                  char *data,
                  size_t nbytes)
 {
-    DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
+    VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
     struct private_data *priv = st->conn->privateData;
     struct private_stream_data *privst = st->privateData;
     int rv = -1;
@@ -8519,7 +8519,7 @@ remoteStreamRecv(virStreamPtr st,
         int ret;

         if (st->flags & VIR_STREAM_NONBLOCK) {
-            DEBUG0("Non-blocking mode and no data available");
+            VIR_DEBUG0("Non-blocking mode and no data available");
             rv = -2;
             goto cleanup;
         }
@@ -8549,7 +8549,7 @@ remoteStreamRecv(virStreamPtr st,
             goto cleanup;
     }

-    DEBUG("After IO %d", privst->incomingOffset);
+    VIR_DEBUG("After IO %d", privst->incomingOffset);
     if (privst->incomingOffset) {
         int want = privst->incomingOffset;
         if (want > nbytes)
@@ -8569,7 +8569,7 @@ remoteStreamRecv(virStreamPtr st,

     remoteStreamEventTimerUpdate(privst);

-    DEBUG("Done %d", rv);
+    VIR_DEBUG("Done %d", rv);

 cleanup:
     if (rv == -1)
@@ -9818,7 +9818,7 @@ remoteIODecodeMessageLength(struct private_data *priv) {
     /* Extend our declared buffer length and carry
        on reading the header + payload */
     priv->bufferLength += len;
-    DEBUG("Got length, now need %d total (%d more)", priv->bufferLength, len);
+    VIR_DEBUG("Got length, now need %d total (%d more)", priv->bufferLength, len);
     return 0;
 }

@@ -9977,10 +9977,10 @@ processCallDispatchMessage(virConnectPtr conn, struct private_data *priv,
     /* An async message has come in while we were waiting for the
      * response. Process it to pull it off the wire, and try again
      */
-    DEBUG0("Encountered an event while waiting for a response");
+    VIR_DEBUG0("Encountered an event while waiting for a response");

     if (in_open) {
-        DEBUG("Ignoring bogus event %d received while in open", hdr->proc);
+        VIR_DEBUG("Ignoring bogus event %d received while in open", hdr->proc);
         return -1;
     }

@@ -10014,7 +10014,7 @@ processCallDispatchMessage(virConnectPtr conn, struct private_data *priv,
         break;

     default:
-        DEBUG("Unexpected event proc %d", hdr->proc);
+        VIR_DEBUG("Unexpected event proc %d", hdr->proc);
         break;
     }

@@ -10023,7 +10023,7 @@ processCallDispatchMessage(virConnectPtr conn, struct private_data *priv,

     if (virDomainEventQueuePush(priv->domainEvents,
                                 event) < 0) {
-        DEBUG0("Error adding event to queue");
+        VIR_DEBUG0("Error adding event to queue");
         virDomainEventFree(event);
     }
     virEventUpdateTimeout(priv->eventFlushTimer, 0);
@@ -10271,7 +10271,7 @@ remoteIOEventLoop(virConnectPtr conn,

         if (fds[1].revents) {
             ssize_t s;
-            DEBUG0("Woken up from poll by other thread");
+            VIR_DEBUG0("Woken up from poll by other thread");
             s = saferead(priv->wakeupReadFD, &ignore, sizeof(ignore));
             if (s < 0) {
                 virReportSystemError(errno, "%s",
@@ -10322,7 +10322,7 @@ remoteIOEventLoop(virConnectPtr conn,
                  * we release our mutex a short while
                  * later...
                  */
-                DEBUG("Waking up sleep %d %p %p", tmp->proc_nr, tmp, priv->waitDispatch);
+                VIR_DEBUG("Waking up sleep %d %p %p", tmp->proc_nr, tmp, priv->waitDispatch);
                 virCondSignal(&tmp->cond);
             }
             prev = tmp;
@@ -10336,11 +10336,11 @@ remoteIOEventLoop(virConnectPtr conn,
              * remove us
              */
             priv->waitDispatch = thiscall->next;
-            DEBUG("Giving up the buck %d %p %p", thiscall->proc_nr, thiscall, priv->waitDispatch);
+            VIR_DEBUG("Giving up the buck %d %p %p", thiscall->proc_nr, thiscall, priv->waitDispatch);
             /* See if someone else is still waiting
              * and if so, then pass the buck ! */
             if (priv->waitDispatch) {
-                DEBUG("Passing the buck to %d %p", priv->waitDispatch->proc_nr, priv->waitDispatch);
+                VIR_DEBUG("Passing the buck to %d %p", priv->waitDispatch->proc_nr, priv->waitDispatch);
                 virCondSignal(&priv->waitDispatch->cond);
             }
             return 0;
@@ -10357,11 +10357,11 @@ remoteIOEventLoop(virConnectPtr conn,

 error:
     priv->waitDispatch = thiscall->next;
-    DEBUG("Giving up the buck due to I/O error %d %p %p", thiscall->proc_nr, thiscall, priv->waitDispatch);
+    VIR_DEBUG("Giving up the buck due to I/O error %d %p %p", thiscall->proc_nr, thiscall, priv->waitDispatch);
     /* See if someone else is still waiting
      * and if so, then pass the buck ! */
     if (priv->waitDispatch) {
-        DEBUG("Passing the buck to %d %p", priv->waitDispatch->proc_nr, priv->waitDispatch);
+        VIR_DEBUG("Passing the buck to %d %p", priv->waitDispatch->proc_nr, priv->waitDispatch);
         virCondSignal(&priv->waitDispatch->cond);
     }
     return -1;
@@ -10408,7 +10408,7 @@ remoteIO(virConnectPtr conn,
 {
     int rv;

-    DEBUG("Do proc=%d serial=%d length=%d wait=%p",
+    VIR_DEBUG("Do proc=%d serial=%d length=%d wait=%p",
           thiscall->proc_nr, thiscall->serial,
           thiscall->bufferLength, priv->waitDispatch);

@@ -10439,7 +10439,7 @@ remoteIO(virConnectPtr conn,
             return -1;
         }

-        DEBUG("Going to sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
+        VIR_DEBUG("Going to sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
         /* Go to sleep while other thread is working... */
         if (virCondWait(&thiscall->cond, &priv->lock) < 0) {
             if (priv->waitDispatch == thiscall) {
@@ -10458,7 +10458,7 @@ remoteIO(virConnectPtr conn,
             return -1;
         }

-        DEBUG("Wokeup from sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
+        VIR_DEBUG("Wokeup from sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
         /* Two reasons we can be woken up
          *  1. Other thread has got our reply ready for us
          *  2. Other thread is all done, and it is our turn to
@@ -10482,7 +10482,7 @@ remoteIO(virConnectPtr conn,
         priv->waitDispatch = thiscall;
     }

-    DEBUG("We have the buck %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
+    VIR_DEBUG("We have the buck %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
     /*
      * The buck stops here!
      *
@@ -10509,7 +10509,7 @@ remoteIO(virConnectPtr conn,
         return -1;

 cleanup:
-    DEBUG("All done with our call %d %p %p", thiscall->proc_nr,
+    VIR_DEBUG("All done with our call %d %p %p", thiscall->proc_nr,
           priv->waitDispatch, thiscall);
     if (thiscall->mode == REMOTE_MODE_ERROR) {
         /* Interop for virErrorNumber glitch in 0.8.0, if server is
@@ -10641,10 +10641,10 @@ remoteDomainEventFired(int watch,
     if (priv->waitDispatch)
         goto done;

-    DEBUG("Event fired %d %d %d %X", watch, fd, event, event);
+    VIR_DEBUG("Event fired %d %d %d %X", watch, fd, event, event);

     if (event & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR)) {
-         DEBUG("%s : VIR_EVENT_HANDLE_HANGUP or "
+         VIR_DEBUG("%s : VIR_EVENT_HANDLE_HANGUP or "
                "VIR_EVENT_HANDLE_ERROR encountered", __FUNCTION__);
          virEventRemoveHandle(watch);
          priv->watch = -1;
@@ -10658,7 +10658,7 @@ remoteDomainEventFired(int watch,
     }

     if (remoteIOHandleInput(conn, priv, 0) < 0)
-        DEBUG0("Something went wrong during async message processing");
+        VIR_DEBUG0("Something went wrong during async message processing");

 done:
     remoteDriverUnlock(priv);
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 52353a3..1c1a037 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -615,7 +615,7 @@ virSecurityDACSetProcessLabel(virSecurityManagerPtr mgr,
 {
     virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);

-    DEBUG("Dropping privileges of VM to %d:%d", priv->user, priv->group);
+    VIR_DEBUG("Dropping privileges of VM to %d:%d", priv->user, priv->group);

     if (virSetUIDGID(priv->user, priv->group) < 0)
         return -1;
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index c7ade6b..ac421c3 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -474,7 +474,7 @@ virStorageBackendDiskPartBoundries(virStoragePoolObjPtr pool,
     unsigned long long cylinderSize = dev->geometry.heads *
                                       dev->geometry.sectors * SECTOR_SIZE;

-    DEBUG("find free area: allocation %llu, cyl size %llu", allocation,
+    VIR_DEBUG("find free area: allocation %llu, cyl size %llu", allocation,
           cylinderSize);
     int partType = virStorageBackendDiskPartTypeToCreate(pool);

@@ -528,7 +528,7 @@ virStorageBackendDiskPartBoundries(virStoragePoolObjPtr pool,
         return -1;
     }

-    DEBUG("aligned alloc %llu", alignedAllocation);
+    VIR_DEBUG("aligned alloc %llu", alignedAllocation);
     *start = dev->freeExtents[smallestExtent].start;

     if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
@@ -544,7 +544,7 @@ virStorageBackendDiskPartBoundries(virStoragePoolObjPtr pool,

     /* counting in byte, we want the last byte of the current sector */
     *end -= 1;
-    DEBUG("final aligned start %llu, end %llu", *start, *end);
+    VIR_DEBUG("final aligned start %llu, end %llu", *start, *end);
     return 0;
 }

@@ -658,7 +658,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,

     devname = basename(devpath);
     srcname = basename(pool->def->source.devices[0].path);
-    DEBUG("devname=%s, srcname=%s", devname, srcname);
+    VIR_DEBUG("devname=%s, srcname=%s", devname, srcname);

     if (!STRPREFIX(devname, srcname)) {
         virStorageReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1937da0..b168570 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1164,7 +1164,7 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,

         if ((privconn->domainEventTimer =
              virEventAddTimeout(-1, testDomainEventFlush, privconn, NULL)) < 0)
-            DEBUG0("virEventAddTimeout failed: No addTimeoutImpl defined. "
+            VIR_DEBUG0("virEventAddTimeout failed: No addTimeoutImpl defined. "
                    "continuing without events.");
         testDriverUnlock(privconn);
     }
diff --git a/src/util/logging.h b/src/util/logging.h
index 574f68d..2e2734e 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -1,7 +1,7 @@
 /*
  * logging.h: internal logging and debugging
  *
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2008, 2011 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
@@ -28,7 +28,7 @@
 /*
  * If configured with --enable-debug=yes then library calls
  * are printed to stderr for debugging or to an appropriate channel
- * defined at runtime of from the libvirt daemon configuration file
+ * defined at runtime from the libvirt daemon configuration file
  */
 # ifdef ENABLE_DEBUG
 #  define VIR_DEBUG_INT(category, f, l, fmt,...)                             \
@@ -62,12 +62,6 @@
 # define VIR_ERROR0(msg)                                                     \
         VIR_ERROR_INT("file." __FILE__, __func__, __LINE__, "%s", msg)

-/* Legacy compat */
-# define DEBUG(fmt,...)                                                  \
-        VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-# define DEBUG0(msg)                                                     \
-        VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
-
 /*
  * To be made public
  */
diff --git a/src/util/util.c b/src/util/util.c
index 6161be6..ca64bf9 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -846,7 +846,7 @@ virRunWithHook(const char *const*argv,
         virReportOOMError();
         goto error;
     }
-    DEBUG0(argv_str);
+    VIR_DEBUG0(argv_str);

     if ((execret = __virExec(argv, NULL, NULL,
                              &childpid, -1, &outfd, &errfd,
@@ -862,9 +862,9 @@ virRunWithHook(const char *const*argv,
     }

     if (outbuf)
-        DEBUG("Command stdout: %s", outbuf);
+        VIR_DEBUG("Command stdout: %s", outbuf);
     if (errbuf)
-        DEBUG("Command stderr: %s", errbuf);
+        VIR_DEBUG("Command stderr: %s", errbuf);

     while ((waitret = waitpid(childpid, &exitstatus, 0) == -1) &&
             errno == EINTR);
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index f647eb9..9526ee4 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -87,7 +87,7 @@ int vboxRegister(void) {

     /* Init the glue and get the API version. */
     if (VBoxCGlueInit(&uVersion) == 0) {
-        DEBUG("VBoxCGlueInit found API version: %d.%d.%d (%u)",
+        VIR_DEBUG("VBoxCGlueInit found API version: %d.%d.%d (%u)",
               uVersion / 1000000,
               uVersion % 1000000 / 1000,
               uVersion % 1000,
@@ -98,36 +98,36 @@ int vboxRegister(void) {
          * number 51, thus the version ranges in the if statements below.
          */
         if (uVersion >= 2001052 && uVersion < 2002051) {
-            DEBUG0("VirtualBox API version: 2.2");
+            VIR_DEBUG0("VirtualBox API version: 2.2");
             driver        = &vbox22Driver;
             networkDriver = &vbox22NetworkDriver;
             storageDriver = &vbox22StorageDriver;
         } else if (uVersion >= 2002051 && uVersion < 3000051) {
-            DEBUG0("VirtualBox API version: 3.0");
+            VIR_DEBUG0("VirtualBox API version: 3.0");
             driver        = &vbox30Driver;
             networkDriver = &vbox30NetworkDriver;
             storageDriver = &vbox30StorageDriver;
         } else if (uVersion >= 3000051 && uVersion < 3001051) {
-            DEBUG0("VirtualBox API version: 3.1");
+            VIR_DEBUG0("VirtualBox API version: 3.1");
             driver        = &vbox31Driver;
             networkDriver = &vbox31NetworkDriver;
             storageDriver = &vbox31StorageDriver;
         } else if (uVersion >= 3001051 && uVersion < 3002051) {
-            DEBUG0("VirtualBox API version: 3.2");
+            VIR_DEBUG0("VirtualBox API version: 3.2");
             driver        = &vbox32Driver;
             networkDriver = &vbox32NetworkDriver;
             storageDriver = &vbox32StorageDriver;
         } else if (uVersion >= 3002051 && uVersion < 4000051) {
-            DEBUG0("VirtualBox API version: 4.0");
+            VIR_DEBUG0("VirtualBox API version: 4.0");
             driver        = &vbox40Driver;
             networkDriver = &vbox40NetworkDriver;
             storageDriver = &vbox40StorageDriver;
         } else {
-            DEBUG0("Unsupport VirtualBox API version");
+            VIR_DEBUG0("Unsupport VirtualBox API version");
         }

     } else {
-        DEBUG0("VBoxCGlueInit failed, using dummy driver");
+        VIR_DEBUG0("VBoxCGlueInit failed, using dummy driver");
     }

     if (virRegisterDriver(driver) < 0)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index cf3cbc6..1c4e46f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -143,14 +143,14 @@ if (strUtf16) {\
 \
     g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);\
     if (strUtf8) {\
-        DEBUG("%s: %s", msg, strUtf8);\
+        VIR_DEBUG("%s: %s", msg, strUtf8);\
         g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8);\
     }\
 }

 #define DEBUGUUID(msg, iid) \
 {\
-    DEBUG (msg ": {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",\
+    VIR_DEBUG (msg ": {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",\
           (unsigned)(iid)->m0,\
           (unsigned)(iid)->m1,\
           (unsigned)(iid)->m2,\
@@ -617,7 +617,7 @@ static char *vboxGenerateMediumName(PRUint32  storageBus,

     name = virIndexToDiskName(total, prefix);

-    DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, "
+    VIR_DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, "
           "devicePort=%d deviceSlot=%d, maxPortPerInst=%u maxSlotPerPort=%u",
           NULLSTR(name), total, storageBus, deviceInst, devicePort,
           deviceSlot, maxPortPerInst, maxSlotPerPort);
@@ -677,7 +677,7 @@ static bool vboxGetDeviceDetails(const char *deviceName,
     *devicePort = (total % (maxPortPerInst * maxSlotPerPort)) / maxSlotPerPort;
     *deviceSlot = (total % (maxPortPerInst * maxSlotPerPort)) % maxSlotPerPort;

-    DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, "
+    VIR_DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, "
           "devicePort=%d deviceSlot=%d, maxPortPerInst=%u maxSlotPerPort=%u",
           deviceName, total, storageBus, *deviceInst, *devicePort,
           *deviceSlot, maxPortPerInst, maxSlotPerPort);
@@ -1027,14 +1027,14 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn,
 #endif /* !(VBOX_API_VERSION == 2002) */

     conn->privateData = data;
-    DEBUG0("in vboxOpen");
+    VIR_DEBUG0("in vboxOpen");

     return VIR_DRV_OPEN_SUCCESS;
 }

 static int vboxClose(virConnectPtr conn) {
     vboxGlobalData *data = conn->privateData;
-    DEBUG("%s: in vboxClose",conn->driver->name);
+    VIR_DEBUG("%s: in vboxClose",conn->driver->name);

     vboxUninitialize(data);
     conn->privateData = NULL;
@@ -1044,7 +1044,7 @@ static int vboxClose(virConnectPtr conn) {

 static int vboxGetVersion(virConnectPtr conn, unsigned long *version) {
     vboxGlobalData *data = conn->privateData;
-    DEBUG("%s: in vboxGetVersion",conn->driver->name);
+    VIR_DEBUG("%s: in vboxGetVersion",conn->driver->name);

     vboxDriverLock(data);
     *version = data->version;
@@ -3560,22 +3560,22 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data,
     PRUint32 maxBootPosition            = 0;
     int i = 0;

-    DEBUG("def->os.type             %s", def->os.type);
-    DEBUG("def->os.arch             %s", def->os.arch);
-    DEBUG("def->os.machine          %s", def->os.machine);
-    DEBUG("def->os.nBootDevs        %d", def->os.nBootDevs);
-    DEBUG("def->os.bootDevs[0]      %d", def->os.bootDevs[0]);
-    DEBUG("def->os.bootDevs[1]      %d", def->os.bootDevs[1]);
-    DEBUG("def->os.bootDevs[2]      %d", def->os.bootDevs[2]);
-    DEBUG("def->os.bootDevs[3]      %d", def->os.bootDevs[3]);
-    DEBUG("def->os.init             %s", def->os.init);
-    DEBUG("def->os.kernel           %s", def->os.kernel);
-    DEBUG("def->os.initrd           %s", def->os.initrd);
-    DEBUG("def->os.cmdline          %s", def->os.cmdline);
-    DEBUG("def->os.root             %s", def->os.root);
-    DEBUG("def->os.loader           %s", def->os.loader);
-    DEBUG("def->os.bootloader       %s", def->os.bootloader);
-    DEBUG("def->os.bootloaderArgs   %s", def->os.bootloaderArgs);
+    VIR_DEBUG("def->os.type             %s", def->os.type);
+    VIR_DEBUG("def->os.arch             %s", def->os.arch);
+    VIR_DEBUG("def->os.machine          %s", def->os.machine);
+    VIR_DEBUG("def->os.nBootDevs        %d", def->os.nBootDevs);
+    VIR_DEBUG("def->os.bootDevs[0]      %d", def->os.bootDevs[0]);
+    VIR_DEBUG("def->os.bootDevs[1]      %d", def->os.bootDevs[1]);
+    VIR_DEBUG("def->os.bootDevs[2]      %d", def->os.bootDevs[2]);
+    VIR_DEBUG("def->os.bootDevs[3]      %d", def->os.bootDevs[3]);
+    VIR_DEBUG("def->os.init             %s", def->os.init);
+    VIR_DEBUG("def->os.kernel           %s", def->os.kernel);
+    VIR_DEBUG("def->os.initrd           %s", def->os.initrd);
+    VIR_DEBUG("def->os.cmdline          %s", def->os.cmdline);
+    VIR_DEBUG("def->os.root             %s", def->os.root);
+    VIR_DEBUG("def->os.loader           %s", def->os.loader);
+    VIR_DEBUG("def->os.bootloader       %s", def->os.bootloader);
+    VIR_DEBUG("def->os.bootloaderArgs   %s", def->os.bootloaderArgs);

     data->vboxObj->vtbl->GetSystemProperties(data->vboxObj, &systemProperties);
     if (systemProperties) {
@@ -3617,17 +3617,17 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
         return;

     for (i = 0; i < def->ndisks; i++) {
-        DEBUG("disk(%d) type:       %d", i, def->disks[i]->type);
-        DEBUG("disk(%d) device:     %d", i, def->disks[i]->device);
-        DEBUG("disk(%d) bus:        %d", i, def->disks[i]->bus);
-        DEBUG("disk(%d) src:        %s", i, def->disks[i]->src);
-        DEBUG("disk(%d) dst:        %s", i, def->disks[i]->dst);
-        DEBUG("disk(%d) driverName: %s", i, def->disks[i]->driverName);
-        DEBUG("disk(%d) driverType: %s", i, def->disks[i]->driverType);
-        DEBUG("disk(%d) cachemode:  %d", i, def->disks[i]->cachemode);
-        DEBUG("disk(%d) readonly:   %s", i, (def->disks[i]->readonly
+        VIR_DEBUG("disk(%d) type:       %d", i, def->disks[i]->type);
+        VIR_DEBUG("disk(%d) device:     %d", i, def->disks[i]->device);
+        VIR_DEBUG("disk(%d) bus:        %d", i, def->disks[i]->bus);
+        VIR_DEBUG("disk(%d) src:        %s", i, def->disks[i]->src);
+        VIR_DEBUG("disk(%d) dst:        %s", i, def->disks[i]->dst);
+        VIR_DEBUG("disk(%d) driverName: %s", i, def->disks[i]->driverName);
+        VIR_DEBUG("disk(%d) driverType: %s", i, def->disks[i]->driverType);
+        VIR_DEBUG("disk(%d) cachemode:  %d", i, def->disks[i]->cachemode);
+        VIR_DEBUG("disk(%d) readonly:   %s", i, (def->disks[i]->readonly
                                              ? "True" : "False"));
-        DEBUG("disk(%d) shared:     %s", i, (def->disks[i]->shared
+        VIR_DEBUG("disk(%d) shared:     %s", i, (def->disks[i]->shared
                                              ? "True" : "False"));

         if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
@@ -3734,15 +3734,15 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                         if (def->disks[i]->readonly) {
                             hardDisk->vtbl->SetType(hardDisk,
                                                     HardDiskType_Immutable);
-                            DEBUG0("setting harddisk to readonly");
+                            VIR_DEBUG0("setting harddisk to readonly");
                         } else if (!def->disks[i]->readonly) {
                             hardDisk->vtbl->SetType(hardDisk,
                                                     HardDiskType_Normal);
-                            DEBUG0("setting harddisk type to normal");
+                            VIR_DEBUG0("setting harddisk type to normal");
                         }
                         if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_IDE) {
                             if (STREQ(def->disks[i]->dst, "hdc")) {
-                                DEBUG0("Not connecting harddisk to hdc as hdc"
+                                VIR_DEBUG0("Not connecting harddisk to hdc as hdc"
                                        " is taken by CD/DVD Drive");
                             } else {
                                 PRInt32 channel          = 0;
@@ -3896,17 +3896,17 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
     }

     for (i = 0; i < def->ndisks && !error; i++) {
-        DEBUG("disk(%d) type:       %d", i, def->disks[i]->type);
-        DEBUG("disk(%d) device:     %d", i, def->disks[i]->device);
-        DEBUG("disk(%d) bus:        %d", i, def->disks[i]->bus);
-        DEBUG("disk(%d) src:        %s", i, def->disks[i]->src);
-        DEBUG("disk(%d) dst:        %s", i, def->disks[i]->dst);
-        DEBUG("disk(%d) driverName: %s", i, def->disks[i]->driverName);
-        DEBUG("disk(%d) driverType: %s", i, def->disks[i]->driverType);
-        DEBUG("disk(%d) cachemode:  %d", i, def->disks[i]->cachemode);
-        DEBUG("disk(%d) readonly:   %s", i, (def->disks[i]->readonly
+        VIR_DEBUG("disk(%d) type:       %d", i, def->disks[i]->type);
+        VIR_DEBUG("disk(%d) device:     %d", i, def->disks[i]->device);
+        VIR_DEBUG("disk(%d) bus:        %d", i, def->disks[i]->bus);
+        VIR_DEBUG("disk(%d) src:        %s", i, def->disks[i]->src);
+        VIR_DEBUG("disk(%d) dst:        %s", i, def->disks[i]->dst);
+        VIR_DEBUG("disk(%d) driverName: %s", i, def->disks[i]->driverName);
+        VIR_DEBUG("disk(%d) driverType: %s", i, def->disks[i]->driverType);
+        VIR_DEBUG("disk(%d) cachemode:  %d", i, def->disks[i]->cachemode);
+        VIR_DEBUG("disk(%d) readonly:   %s", i, (def->disks[i]->readonly
                                              ? "True" : "False"));
-        DEBUG("disk(%d) shared:     %s", i, (def->disks[i]->shared
+        VIR_DEBUG("disk(%d) shared:     %s", i, (def->disks[i]->shared
                                              ? "True" : "False"));

         if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_FILE &&
@@ -4017,10 +4017,10 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
             if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
                 if (def->disks[i]->readonly) {
                     medium->vtbl->SetType(medium, MediumType_Immutable);
-                    DEBUG0("setting harddisk to immutable");
+                    VIR_DEBUG0("setting harddisk to immutable");
                 } else if (!def->disks[i]->readonly) {
                     medium->vtbl->SetType(medium, MediumType_Normal);
-                    DEBUG0("setting harddisk type to normal");
+                    VIR_DEBUG0("setting harddisk type to normal");
                 }
             }

@@ -4129,8 +4129,8 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
         systemProperties = NULL;
     }

-    DEBUG("Number of Network Cards to be connected: %d", def->nnets);
-    DEBUG("Number of Network Cards available: %d", networkAdapterCount);
+    VIR_DEBUG("Number of Network Cards to be connected: %d", def->nnets);
+    VIR_DEBUG("Number of Network Cards available: %d", networkAdapterCount);

     for (i = 0; (i < def->nnets) && (i < networkAdapterCount); i++) {
         INetworkAdapter *adapter = NULL;
@@ -4149,20 +4149,20 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                  def->nets[i]->mac[5]);
         macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';

-        DEBUG("NIC(%d): Type:   %d", i, def->nets[i]->type);
-        DEBUG("NIC(%d): Model:  %s", i, def->nets[i]->model);
-        DEBUG("NIC(%d): Mac:    %s", i, macaddr);
-        DEBUG("NIC(%d): ifname: %s", i, def->nets[i]->ifname);
+        VIR_DEBUG("NIC(%d): Type:   %d", i, def->nets[i]->type);
+        VIR_DEBUG("NIC(%d): Model:  %s", i, def->nets[i]->model);
+        VIR_DEBUG("NIC(%d): Mac:    %s", i, macaddr);
+        VIR_DEBUG("NIC(%d): ifname: %s", i, def->nets[i]->ifname);
         if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
-            DEBUG("NIC(%d): name:    %s", i, def->nets[i]->data.network.name);
+            VIR_DEBUG("NIC(%d): name:    %s", i, def->nets[i]->data.network.name);
         } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_INTERNAL) {
-            DEBUG("NIC(%d): name:   %s", i, def->nets[i]->data.internal.name);
+            VIR_DEBUG("NIC(%d): name:   %s", i, def->nets[i]->data.internal.name);
         } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_USER) {
-            DEBUG("NIC(%d): NAT.", i);
+            VIR_DEBUG("NIC(%d): NAT.", i);
         } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
-            DEBUG("NIC(%d): brname: %s", i, def->nets[i]->data.bridge.brname);
-            DEBUG("NIC(%d): script: %s", i, def->nets[i]->data.bridge.script);
-            DEBUG("NIC(%d): ipaddr: %s", i, def->nets[i]->data.bridge.ipaddr);
+            VIR_DEBUG("NIC(%d): brname: %s", i, def->nets[i]->data.bridge.brname);
+            VIR_DEBUG("NIC(%d): script: %s", i, def->nets[i]->data.bridge.script);
+            VIR_DEBUG("NIC(%d): ipaddr: %s", i, def->nets[i]->data.bridge.ipaddr);
         }

         machine->vtbl->GetNetworkAdapter(machine, i, &adapter);
@@ -4263,13 +4263,13 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
         systemProperties = NULL;
     }

-    DEBUG("Number of Serial Ports to be connected: %d", def->nserials);
-    DEBUG("Number of Serial Ports available: %d", serialPortCount);
+    VIR_DEBUG("Number of Serial Ports to be connected: %d", def->nserials);
+    VIR_DEBUG("Number of Serial Ports available: %d", serialPortCount);
     for (i = 0; (i < def->nserials) && (i < serialPortCount); i++) {
         ISerialPort *serialPort = NULL;

-        DEBUG("SerialPort(%d): Type: %d", i, def->serials[i]->source.type);
-        DEBUG("SerialPort(%d): target.port: %d", i,
+        VIR_DEBUG("SerialPort(%d): Type: %d", i, def->serials[i]->source.type);
+        VIR_DEBUG("SerialPort(%d): target.port: %d", i,
               def->serials[i]->target.port);

         machine->vtbl->GetSerialPort(machine, i, &serialPort);
@@ -4296,12 +4296,12 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
             if (def->serials[i]->target.port == 0) {
                 serialPort->vtbl->SetIRQ(serialPort, 4);
                 serialPort->vtbl->SetIOBase(serialPort, 1016);
-                DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
+                VIR_DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
                       i, 4, 1016, def->serials[i]->source.data.file.path);
             } else if (def->serials[i]->target.port == 1) {
                 serialPort->vtbl->SetIRQ(serialPort, 3);
                 serialPort->vtbl->SetIOBase(serialPort, 760);
-                DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
+                VIR_DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
                       i, 3, 760, def->serials[i]->source.data.file.path);
             }

@@ -4342,13 +4342,13 @@ vboxAttachParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
         systemProperties = NULL;
     }

-    DEBUG("Number of Parallel Ports to be connected: %d", def->nparallels);
-    DEBUG("Number of Parallel Ports available: %d", parallelPortCount);
+    VIR_DEBUG("Number of Parallel Ports to be connected: %d", def->nparallels);
+    VIR_DEBUG("Number of Parallel Ports available: %d", parallelPortCount);
     for (i = 0; (i < def->nparallels) && (i < parallelPortCount); i++) {
         IParallelPort *parallelPort = NULL;

-        DEBUG("ParallelPort(%d): Type: %d", i, def->parallels[i]->source.type);
-        DEBUG("ParallelPort(%d): target.port: %d", i,
+        VIR_DEBUG("ParallelPort(%d): Type: %d", i, def->parallels[i]->source.type);
+        VIR_DEBUG("ParallelPort(%d): target.port: %d", i,
               def->parallels[i]->target.port);

         machine->vtbl->GetParallelPort(machine, i, &parallelPort);
@@ -4370,12 +4370,12 @@ vboxAttachParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                 if (i == 0) {
                     parallelPort->vtbl->SetIRQ(parallelPort, 7);
                     parallelPort->vtbl->SetIOBase(parallelPort, 888);
-                    DEBUG(" parallePort-%d irq: %d, iobase 0x%x, path: %s",
+                    VIR_DEBUG(" parallePort-%d irq: %d, iobase 0x%x, path: %s",
                           i, 7, 888, def->parallels[i]->source.data.file.path);
                 } else if (i == 1) {
                     parallelPort->vtbl->SetIRQ(parallelPort, 5);
                     parallelPort->vtbl->SetIOBase(parallelPort, 632);
-                    DEBUG(" parallePort-%d irq: %d, iobase 0x%x, path: %s",
+                    VIR_DEBUG(" parallePort-%d irq: %d, iobase 0x%x, path: %s",
                           i, 5, 632, def->parallels[i]->source.data.file.path);
                 }
             }
@@ -4446,20 +4446,20 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
 #endif /* VBOX_API_VERSION >= 4000 */
             if (VRDxServer) {
                 VRDxServer->vtbl->SetEnabled(VRDxServer, PR_TRUE);
-                DEBUG0("VRDP Support turned ON.");
+                VIR_DEBUG0("VRDP Support turned ON.");

 #if VBOX_API_VERSION < 3001
                 if (def->graphics[i]->data.rdp.port) {
                     VRDxServer->vtbl->SetPort(VRDxServer,
                                               def->graphics[i]->data.rdp.port);
-                    DEBUG("VRDP Port changed to: %d",
+                    VIR_DEBUG("VRDP Port changed to: %d",
                           def->graphics[i]->data.rdp.port);
                 } else if (def->graphics[i]->data.rdp.autoport) {
                     /* Setting the port to 0 will reset its value to
                      * the default one which is 3389 currently
                      */
                     VRDxServer->vtbl->SetPort(VRDxServer, 0);
-                    DEBUG0("VRDP Port changed to default, which is 3389 currently");
+                    VIR_DEBUG0("VRDP Port changed to default, which is 3389 currently");
                 }
 #elif VBOX_API_VERSION < 4000 /* 3001 <= VBOX_API_VERSION < 4000 */
                 PRUnichar *portUtf16 = NULL;
@@ -4480,13 +4480,13 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                 if (def->graphics[i]->data.rdp.replaceUser) {
                     VRDxServer->vtbl->SetReuseSingleConnection(VRDxServer,
                                                                PR_TRUE);
-                    DEBUG0("VRDP set to reuse single connection");
+                    VIR_DEBUG0("VRDP set to reuse single connection");
                 }

                 if (def->graphics[i]->data.rdp.multiUser) {
                     VRDxServer->vtbl->SetAllowMultiConnection(VRDxServer,
                                                               PR_TRUE);
-                    DEBUG0("VRDP set to allow multiple connection");
+                    VIR_DEBUG0("VRDP set to allow multiple connection");
                 }

                 if (def->graphics[i]->data.rdp.listenAddr) {
@@ -4506,7 +4506,7 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                                                       netAddressUtf16);
                     VBOX_UTF16_FREE(netAddressKey);
 #endif /* VBOX_API_VERSION >= 4000 */
-                    DEBUG("VRDP listen address is set to: %s",
+                    VIR_DEBUG("VRDP listen address is set to: %s",
                           def->graphics[i]->data.rdp.listenAddr);

                     VBOX_UTF16_FREE(netAddressUtf16);
@@ -4639,7 +4639,7 @@ vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                 VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
                 if (def->hostdevs[i]->source.subsys.u.usb.vendor ||
                     def->hostdevs[i]->source.subsys.u.usb.product) {
-                    DEBUG("USB Device detected, VendorId:0x%x, ProductId:0x%x",
+                    VIR_DEBUG("USB Device detected, VendorId:0x%x, ProductId:0x%x",
                           def->hostdevs[i]->source.subsys.u.usb.vendor,
                           def->hostdevs[i]->source.subsys.u.usb.product);
                     isUSB = true;
@@ -6322,7 +6322,7 @@ vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis,
     g_pVBoxGlobalData->domainEventDispatching = 1;
     vboxDriverLock(g_pVBoxGlobalData);

-    DEBUG("IVirtualBoxCallback: %p, State: %d", pThis, state);
+    VIR_DEBUG("IVirtualBoxCallback: %p, State: %d", pThis, state);
     DEBUGPRUnichar("machineId", machineId);

     if (machineId) {
@@ -6389,7 +6389,7 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnMachineDataChange(IVirtualBoxCallback *pThis,
                                 PRUnichar *machineId)
 {
-    DEBUG("IVirtualBoxCallback: %p", pThis);
+    VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
     DEBUGPRUnichar("machineId", machineId);

     return NS_OK;
@@ -6402,7 +6402,7 @@ vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis,
                                  PRUnichar **error ATTRIBUTE_UNUSED,
                                  PRBool *allowChange)
 {
-    DEBUG("IVirtualBoxCallback: %p, allowChange: %s", pThis, *allowChange ? "true" : "false");
+    VIR_DEBUG("IVirtualBoxCallback: %p, allowChange: %s", pThis, *allowChange ? "true" : "false");
     DEBUGPRUnichar("machineId", machineId);
     DEBUGPRUnichar("key", key);
     DEBUGPRUnichar("value", value);
@@ -6414,7 +6414,7 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnExtraDataChange(IVirtualBoxCallback *pThis, PRUnichar *machineId,
                               PRUnichar *key, PRUnichar *value)
 {
-    DEBUG("IVirtualBoxCallback: %p", pThis);
+    VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
     DEBUGPRUnichar("machineId", machineId);
     DEBUGPRUnichar("key", key);
     DEBUGPRUnichar("value", value);
@@ -6427,8 +6427,8 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis, PRUnichar *mediaId,
                               PRUint32 mediaType, PRBool registered)
 {
-    DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
-    DEBUG("mediaType: %d", mediaType);
+    VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
+    VIR_DEBUG("mediaType: %d", mediaType);
     DEBUGPRUnichar("mediaId", mediaId);

     return NS_OK;
@@ -6447,7 +6447,7 @@ vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis,
     g_pVBoxGlobalData->domainEventDispatching = 1;
     vboxDriverLock(g_pVBoxGlobalData);

-    DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
+    VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
     DEBUGPRUnichar("machineId", machineId);

     if (machineId) {
@@ -6499,7 +6499,7 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnSessionStateChange(IVirtualBoxCallback *pThis,
                                  PRUnichar *machineId, PRUint32 state)
 {
-    DEBUG("IVirtualBoxCallback: %p, state: %d", pThis, state);
+    VIR_DEBUG("IVirtualBoxCallback: %p, state: %d", pThis, state);
     DEBUGPRUnichar("machineId", machineId);

     return NS_OK;
@@ -6509,7 +6509,7 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnSnapshotTaken(IVirtualBoxCallback *pThis, PRUnichar *machineId,
                             PRUnichar *snapshotId)
 {
-    DEBUG("IVirtualBoxCallback: %p", pThis);
+    VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
     DEBUGPRUnichar("machineId", machineId);
     DEBUGPRUnichar("snapshotId", snapshotId);

@@ -6520,7 +6520,7 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnSnapshotDiscarded(IVirtualBoxCallback *pThis, PRUnichar *machineId,
                                 PRUnichar *snapshotId)
 {
-    DEBUG("IVirtualBoxCallback: %p", pThis);
+    VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
     DEBUGPRUnichar("machineId", machineId);
     DEBUGPRUnichar("snapshotId", snapshotId);

@@ -6531,7 +6531,7 @@ static nsresult PR_COM_METHOD
 vboxCallbackOnSnapshotChange(IVirtualBoxCallback *pThis, PRUnichar *machineId,
                              PRUnichar *snapshotId)
 {
-    DEBUG("IVirtualBoxCallback: %p", pThis);
+    VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
     DEBUGPRUnichar("machineId", machineId);
     DEBUGPRUnichar("snapshotId", snapshotId);

@@ -6543,7 +6543,7 @@ vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis,
                                   PRUnichar *machineId, PRUnichar *name,
                                   PRUnichar *value, PRUnichar *flags)
 {
-    DEBUG("IVirtualBoxCallback: %p", pThis);
+    VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
     DEBUGPRUnichar("machineId", machineId);
     DEBUGPRUnichar("name", name);
     DEBUGPRUnichar("value", value);
@@ -6559,7 +6559,7 @@ vboxCallbackAddRef(nsISupports *pThis)

     c = ++g_pVBoxGlobalData->vboxCallBackRefCount;

-    DEBUG("pThis: %p, vboxCallback AddRef: %d", pThis, c);
+    VIR_DEBUG("pThis: %p, vboxCallback AddRef: %d", pThis, c);

     return c;
 }
@@ -6576,7 +6576,7 @@ vboxCallbackRelease(nsISupports *pThis)
         VIR_FREE(pThis);
     }

-    DEBUG("pThis: %p, vboxCallback Release: %d", pThis, c);
+    VIR_DEBUG("pThis: %p, vboxCallback Release: %d", pThis, c);

     return c;
 }
@@ -6594,13 +6594,13 @@ vboxCallbackQueryInterface(nsISupports *pThis, const nsID *iid, void **resultp)
         g_pVBoxGlobalData->vboxCallBackRefCount++;
         *resultp = that;

-        DEBUG("pThis: %p, vboxCallback QueryInterface: %d", pThis, g_pVBoxGlobalData->vboxCallBackRefCount);
+        VIR_DEBUG("pThis: %p, vboxCallback QueryInterface: %d", pThis, g_pVBoxGlobalData->vboxCallBackRefCount);

         return NS_OK;
     }


-    DEBUG("pThis: %p, vboxCallback QueryInterface didn't find a matching interface", pThis);
+    VIR_DEBUG("pThis: %p, vboxCallback QueryInterface didn't find a matching interface", pThis);
     DEBUGUUID("The UUID Callback Interface expects", iid);
     DEBUGUUID("The UUID Callback Interface got", &ivirtualboxCallbackUUID);
     return NS_NOINTERFACE;
@@ -6708,7 +6708,7 @@ static int vboxDomainEventRegister (virConnectPtr conn,

             ret = virDomainEventCallbackListAdd(conn, data->domainEventCallbacks,
                                                 callback, opaque, freecb);
-            DEBUG("virDomainEventCallbackListAdd (ret = %d) ( conn: %p, "
+            VIR_DEBUG("virDomainEventCallbackListAdd (ret = %d) ( conn: %p, "
                   "data->domainEventCallbacks: %p, callback: %p, opaque: %p, "
                   "freecb: %p )", ret, conn, data->domainEventCallbacks, callback,
                   opaque, freecb);
@@ -6809,7 +6809,7 @@ static int vboxDomainEventRegisterAny(virConnectPtr conn,
             ret = virDomainEventCallbackListAddID(conn, data->domainEventCallbacks,
                                                   dom, eventID,
                                                   callback, opaque, freecb);
-            DEBUG("virDomainEventCallbackListAddID (ret = %d) ( conn: %p, "
+            VIR_DEBUG("virDomainEventCallbackListAddID (ret = %d) ( conn: %p, "
                   "data->domainEventCallbacks: %p, callback: %p, opaque: %p, "
                   "freecb: %p )", ret, conn, data->domainEventCallbacks, callback,
                   opaque, freecb);
@@ -6881,7 +6881,7 @@ static virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn,
         (data->vboxSession == NULL))
         goto cleanup;

-    DEBUG0("network initialized");
+    VIR_DEBUG0("network initialized");
     /* conn->networkPrivateData = some network specific data */
     return VIR_DRV_OPEN_SUCCESS;

@@ -6890,7 +6890,7 @@ cleanup:
 }

 static int vboxNetworkClose(virConnectPtr conn) {
-    DEBUG0("network uninitialized");
+    VIR_DEBUG0("network uninitialized");
     conn->networkPrivateData = NULL;
     return 0;
 }
@@ -6924,7 +6924,7 @@ static int vboxNumOfNetworks(virConnectPtr conn) {

     VBOX_RELEASE(host);

-    DEBUG("numActive: %d", ret);
+    VIR_DEBUG("numActive: %d", ret);
     return ret;
 }

@@ -6955,7 +6955,7 @@ static int vboxListNetworks(virConnectPtr conn, char **const names, int nnames)
                     networkInterface->vtbl->GetName(networkInterface, &nameUtf16);
                     VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8);

-                    DEBUG("nnames[%d]: %s", ret, nameUtf8);
+                    VIR_DEBUG("nnames[%d]: %s", ret, nameUtf8);
                     names[ret] = strdup(nameUtf8);
                     if (names[ret] == NULL) {
                         virReportOOMError();
@@ -7006,7 +7006,7 @@ static int vboxNumOfDefinedNetworks(virConnectPtr conn) {

     VBOX_RELEASE(host);

-    DEBUG("numActive: %d", ret);
+    VIR_DEBUG("numActive: %d", ret);
     return ret;
 }

@@ -7037,7 +7037,7 @@ static int vboxListDefinedNetworks(virConnectPtr conn, char **const names, int n
                     networkInterface->vtbl->GetName(networkInterface, &nameUtf16);
                     VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8);

-                    DEBUG("nnames[%d]: %s", ret, nameUtf8);
+                    VIR_DEBUG("nnames[%d]: %s", ret, nameUtf8);
                     names[ret] = strdup(nameUtf8);
                     if (names[ret] == NULL) {
                         virReportOOMError();
@@ -7087,7 +7087,7 @@ vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)

             ret = virGetNetwork(conn, nameUtf8, uuid);

-            DEBUG("Network Name: %s", nameUtf8);
+            VIR_DEBUG("Network Name: %s", nameUtf8);
             DEBUGIID("Network UUID", iid.value);

             VBOX_UTF8_FREE(nameUtf8);
@@ -7124,7 +7124,7 @@ static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *nam
             networkInterface->vtbl->GetId(networkInterface, &iid.value);
             vboxIIDToUUID(&iid, uuid);
             ret = virGetNetwork(conn, name, uuid);
-            DEBUG("Network Name: %s", name);
+            VIR_DEBUG("Network Name: %s", name);

             DEBUGIID("Network UUID", iid.value);
             vboxIIDUnalloc(&iid);
@@ -7232,7 +7232,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
                 data->vboxObj->vtbl->CreateDHCPServer(data->vboxObj,
                                                       networkNameUtf16,
                                                       &dhcpServer);
-                DEBUG0("couldn't find dhcp server so creating one");
+                VIR_DEBUG0("couldn't find dhcp server so creating one");
             }
             if (dhcpServer) {
                 PRUnichar *ipAddressUtf16     = NULL;
@@ -7692,7 +7692,7 @@ static virDrvOpenStatus vboxStorageOpen (virConnectPtr conn,
         (data->vboxSession == NULL))
         goto cleanup;

-    DEBUG0("vbox storage initialized");
+    VIR_DEBUG0("vbox storage initialized");
     /* conn->storagePrivateData = some storage specific data */
     return VIR_DRV_OPEN_SUCCESS;

@@ -7701,7 +7701,7 @@ cleanup:
 }

 static int vboxStorageClose (virConnectPtr conn) {
-    DEBUG0("vbox storage uninitialized");
+    VIR_DEBUG0("vbox storage uninitialized");
     conn->storagePrivateData = NULL;
     return 0;
 }
@@ -7807,7 +7807,7 @@ static int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names
                     VBOX_UTF16_FREE(nameUtf16);

                     if (nameUtf8) {
-                        DEBUG("nnames[%d]: %s", numActive, nameUtf8);
+                        VIR_DEBUG("nnames[%d]: %s", numActive, nameUtf8);
                         names[numActive] = strdup(nameUtf8);
                         if (names[numActive] == NULL) {
                             virReportOOMError();
@@ -7874,10 +7874,10 @@ static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const

                             ret = virGetStorageVol(pool->conn, pool->name, name, key);

-                            DEBUG("virStorageVolPtr: %p", ret);
-                            DEBUG("Storage Volume Name: %s", name);
-                            DEBUG("Storage Volume key : %s", key);
-                            DEBUG("Storage Volume Pool: %s", pool->name);
+                            VIR_DEBUG("virStorageVolPtr: %p", ret);
+                            VIR_DEBUG("Storage Volume Name: %s", name);
+                            VIR_DEBUG("Storage Volume key : %s", key);
+                            VIR_DEBUG("Storage Volume Pool: %s", pool->name);
                         }

                         vboxIIDUnalloc(&hddIID);
@@ -7934,15 +7934,15 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char
             if (hddNameUtf8) {
                 if (vboxStorageNumOfPools(conn) == 1) {
                     ret = virGetStorageVol(conn, "default-pool", hddNameUtf8, key);
-                    DEBUG("Storage Volume Pool: %s", "default-pool");
+                    VIR_DEBUG("Storage Volume Pool: %s", "default-pool");
                 } else {
                     /* TODO: currently only one default pool and thus
                      * nothing here, change it when pools are supported
                      */
                 }

-                DEBUG("Storage Volume Name: %s", key);
-                DEBUG("Storage Volume key : %s", hddNameUtf8);
+                VIR_DEBUG("Storage Volume Name: %s", key);
+                VIR_DEBUG("Storage Volume key : %s", hddNameUtf8);

                 VBOX_UTF8_FREE(hddNameUtf8);
                 VBOX_UTF16_FREE(hddNameUtf16);
@@ -8007,9 +8007,9 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const cha
                     if (vboxStorageNumOfPools(conn) == 1)
                         ret = virGetStorageVol(conn, "default-pool", hddNameUtf8, key);

-                    DEBUG("Storage Volume Pool: %s", "default-pool");
-                    DEBUG("Storage Volume Name: %s", hddNameUtf8);
-                    DEBUG("Storage Volume key : %s", key);
+                    VIR_DEBUG("Storage Volume Pool: %s", "default-pool");
+                    VIR_DEBUG("Storage Volume Name: %s", hddNameUtf8);
+                    VIR_DEBUG("Storage Volume key : %s", key);
                 }

                 vboxIIDUnalloc(&hddIID);
@@ -8241,12 +8241,12 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
 #endif /* VBOX_API_VERSION >= 3001 */
                                             if (NS_SUCCEEDED(rc)) {
                                                 rc = machine->vtbl->SaveSettings(machine);
-                                                DEBUG0("saving machine settings");
+                                                VIR_DEBUG0("saving machine settings");
                                             }

                                             if (NS_SUCCEEDED(rc)) {
                                                 deregister++;
-                                                DEBUG("deregistering hdd:%d", deregister);
+                                                VIR_DEBUG("deregistering hdd:%d", deregister);
                                             }

                                             if (controller)
@@ -8341,10 +8341,10 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info

             ret = 0;

-            DEBUG("Storage Volume Name: %s", vol->name);
-            DEBUG("Storage Volume Type: %s", info->type == VIR_STORAGE_VOL_BLOCK ? "Block" : "File");
-            DEBUG("Storage Volume Capacity: %llu", info->capacity);
-            DEBUG("Storage Volume Allocation: %llu", info->allocation);
+            VIR_DEBUG("Storage Volume Name: %s", vol->name);
+            VIR_DEBUG("Storage Volume Type: %s", info->type == VIR_STORAGE_VOL_BLOCK ? "Block" : "File");
+            VIR_DEBUG("Storage Volume Capacity: %llu", info->capacity);
+            VIR_DEBUG("Storage Volume Allocation: %llu", info->allocation);
         }

         VBOX_MEDIUM_RELEASE(hardDisk);
@@ -8435,7 +8435,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
                 VBOX_UTF16_TO_UTF8(hddFormatUtf16, &hddFormatUtf8);
                 if (hddFormatUtf8) {

-                    DEBUG("Storage Volume Format: %s", hddFormatUtf8);
+                    VIR_DEBUG("Storage Volume Format: %s", hddFormatUtf8);

                     if (STRCASEEQ("vmdk", hddFormatUtf8))
                         def.target.format = VIR_STORAGE_FILE_VMDK;
@@ -8505,9 +8505,9 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
                 if (!ret)
                     virReportOOMError();

-                DEBUG("Storage Volume Name: %s", vol->name);
-                DEBUG("Storage Volume Path: %s", hddLocationUtf8);
-                DEBUG("Storage Volume Pool: %s", vol->pool);
+                VIR_DEBUG("Storage Volume Name: %s", vol->name);
+                VIR_DEBUG("Storage Volume Path: %s", hddLocationUtf8);
+                VIR_DEBUG("Storage Volume Pool: %s", vol->pool);

                 VBOX_UTF8_FREE(hddLocationUtf8);
             }
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index b14c8db..f6d281e 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -323,35 +323,35 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)

     /* Hypervisor is only run with privilege & required to succeed */
     if (xenHavePrivilege()) {
-        DEBUG0("Trying hypervisor sub-driver");
+        VIR_DEBUG0("Trying hypervisor sub-driver");
         if (drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->open(conn, auth, flags) ==
             VIR_DRV_OPEN_SUCCESS) {
-            DEBUG0("Activated hypervisor sub-driver");
+            VIR_DEBUG0("Activated hypervisor sub-driver");
             priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] = 1;
         }
     }

     /* XenD is required to succeed if privileged */
-    DEBUG0("Trying XenD sub-driver");
+    VIR_DEBUG0("Trying XenD sub-driver");
     if (drivers[XEN_UNIFIED_XEND_OFFSET]->open(conn, auth, flags) ==
         VIR_DRV_OPEN_SUCCESS) {
-        DEBUG0("Activated XenD sub-driver");
+        VIR_DEBUG0("Activated XenD sub-driver");
         priv->opened[XEN_UNIFIED_XEND_OFFSET] = 1;

         /* XenD is active, so try the xm & xs drivers too, both requird to
          * succeed if root, optional otherwise */
         if (priv->xendConfigVersion <= 2) {
-            DEBUG0("Trying XM sub-driver");
+            VIR_DEBUG0("Trying XM sub-driver");
             if (drivers[XEN_UNIFIED_XM_OFFSET]->open(conn, auth, flags) ==
                 VIR_DRV_OPEN_SUCCESS) {
-                DEBUG0("Activated XM sub-driver");
+                VIR_DEBUG0("Activated XM sub-driver");
                 priv->opened[XEN_UNIFIED_XM_OFFSET] = 1;
             }
         }
-        DEBUG0("Trying XS sub-driver");
+        VIR_DEBUG0("Trying XS sub-driver");
         if (drivers[XEN_UNIFIED_XS_OFFSET]->open(conn, auth, flags) ==
             VIR_DRV_OPEN_SUCCESS) {
-            DEBUG0("Activated XS sub-driver");
+            VIR_DEBUG0("Activated XS sub-driver");
             priv->opened[XEN_UNIFIED_XS_OFFSET] = 1;
         } else {
             if (xenHavePrivilege())
@@ -361,7 +361,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
         if (xenHavePrivilege()) {
             goto fail; /* XenD is mandatory when privileged */
         } else {
-            DEBUG0("Handing off for remote driver");
+            VIR_DEBUG0("Handing off for remote driver");
             ret = VIR_DRV_OPEN_DECLINED; /* Let remote_driver try instead */
             goto clean;
         }
@@ -370,16 +370,16 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
     xenNumaInit(conn);

     if (!(priv->caps = xenHypervisorMakeCapabilities(conn))) {
-        DEBUG0("Failed to make capabilities");
+        VIR_DEBUG0("Failed to make capabilities");
         goto fail;
     }

 #if WITH_XEN_INOTIFY
     if (xenHavePrivilege()) {
-        DEBUG0("Trying Xen inotify sub-driver");
+        VIR_DEBUG0("Trying Xen inotify sub-driver");
         if (drivers[XEN_UNIFIED_INOTIFY_OFFSET]->open(conn, auth, flags) ==
             VIR_DRV_OPEN_SUCCESS) {
-            DEBUG0("Activated Xen inotify sub-driver");
+            VIR_DEBUG0("Activated Xen inotify sub-driver");
             priv->opened[XEN_UNIFIED_INOTIFY_OFFSET] = 1;
         }
     }
@@ -390,7 +390,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
 fail:
     ret = VIR_DRV_OPEN_ERROR;
 clean:
-    DEBUG0("Failed to activate a mandatory sub-driver");
+    VIR_DEBUG0("Failed to activate a mandatory sub-driver");
     for (i = 0 ; i < XEN_UNIFIED_NR_DRIVERS ; i++)
         if (priv->opened[i]) drivers[i]->close(conn);
     virMutexDestroy(&priv->lock);
@@ -2163,7 +2163,7 @@ xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list,
     for (n=0; n < list->count; n++) {
         if (STREQ(list->doms[n]->name, name) &&
             !memcmp(list->doms[n]->uuid, uuid, VIR_UUID_BUFLEN)) {
-            DEBUG0("WARNING: dom already tracked");
+            VIR_DEBUG0("WARNING: dom already tracked");
             return -1;
         }
     }
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 4a0924f..9cb8e8c 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -1989,7 +1989,7 @@ xenHypervisorInit(void)
     ret = ioctl(fd, cmd, (unsigned long) &hc);

     if ((ret != -1) && (ret != 0)) {
-        DEBUG("Using new hypervisor call: %X", ret);
+        VIR_DEBUG("Using new hypervisor call: %X", ret);
         hv_version = ret;
         xen_ioctl_hypercall_cmd = cmd;
         goto detect_v2;
@@ -2005,7 +2005,7 @@ xenHypervisorInit(void)
     cmd = _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t));
     ret = ioctl(fd, cmd, (unsigned long) &v0_hc);
     if ((ret != -1) && (ret != 0)) {
-        DEBUG("Using old hypervisor call: %X", ret);
+        VIR_DEBUG("Using old hypervisor call: %X", ret);
         hv_version = ret;
         xen_ioctl_hypercall_cmd = cmd;
         hypervisor_version = 0;
@@ -2042,13 +2042,13 @@ xenHypervisorInit(void)
         /* RHEL 5.0 */
         dom_interface_version = 3; /* XEN_DOMCTL_INTERFACE_VERSION */
         if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
-            DEBUG0("Using hypervisor call v2, sys ver2 dom ver3");
+            VIR_DEBUG0("Using hypervisor call v2, sys ver2 dom ver3");
             goto done;
         }
         /* Fedora 7 */
         dom_interface_version = 4; /* XEN_DOMCTL_INTERFACE_VERSION */
         if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
-            DEBUG0("Using hypervisor call v2, sys ver2 dom ver4");
+            VIR_DEBUG0("Using hypervisor call v2, sys ver2 dom ver4");
             goto done;
         }
     }
@@ -2058,7 +2058,7 @@ xenHypervisorInit(void)
         /* xen-3.1 */
         dom_interface_version = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
         if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
-            DEBUG0("Using hypervisor call v2, sys ver3 dom ver5");
+            VIR_DEBUG0("Using hypervisor call v2, sys ver3 dom ver5");
             goto done;
         }
     }
@@ -2068,7 +2068,7 @@ xenHypervisorInit(void)
         /* Fedora 8 */
         dom_interface_version = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
         if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
-            DEBUG0("Using hypervisor call v2, sys ver4 dom ver5");
+            VIR_DEBUG0("Using hypervisor call v2, sys ver4 dom ver5");
             goto done;
         }
     }
@@ -2078,7 +2078,7 @@ xenHypervisorInit(void)
         /* Xen 3.2, Fedora 9 */
         dom_interface_version = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
         if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
-            DEBUG0("Using hypervisor call v2, sys ver6 dom ver5");
+            VIR_DEBUG0("Using hypervisor call v2, sys ver6 dom ver5");
             goto done;
         }
     }
@@ -2087,14 +2087,14 @@ xenHypervisorInit(void)
     sys_interface_version = 7; /* XEN_SYSCTL_INTERFACE_VERSION */
     if (virXen_getdomaininfo(fd, 0, &info) == 1) {
         dom_interface_version = 6; /* XEN_DOMCTL_INTERFACE_VERSION */
-        DEBUG0("Using hypervisor call v2, sys ver7 dom ver6");
+        VIR_DEBUG0("Using hypervisor call v2, sys ver7 dom ver6");
         goto done;
     }

     hypervisor_version = 1;
     sys_interface_version = -1;
     if (virXen_getdomaininfo(fd, 0, &info) == 1) {
-        DEBUG0("Using hypervisor call v1");
+        VIR_DEBUG0("Using hypervisor call v1");
         goto done;
     }

@@ -2102,7 +2102,7 @@ xenHypervisorInit(void)
      * we failed to make the getdomaininfolist hypercall
      */

-    DEBUG0("Failed to find any Xen hypervisor method");
+    VIR_DEBUG0("Failed to find any Xen hypervisor method");
     hypervisor_version = -1;
     virXenError(VIR_ERR_XEN_CALL, " ioctl %lu",
                 (unsigned long)IOCTL_PRIVCMD_HYPERCALL);
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 1067769..7d4ba4c 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -97,7 +97,7 @@ xenInotifyXenCacheLookup(virConnectPtr conn,
     xenXMConfCachePtr entry;

     if (!(entry = virHashLookup(priv->configCache, filename))) {
-        DEBUG("No config found for %s", filename);
+        VIR_DEBUG("No config found for %s", filename);
         return -1;
     }

@@ -105,7 +105,7 @@ xenInotifyXenCacheLookup(virConnectPtr conn,
     memcpy(uuid, entry->def->uuid, VIR_UUID_BUFLEN);

     if (!*name) {
-        DEBUG0("Error getting dom from def");
+        VIR_DEBUG0("Error getting dom from def");
         virReportOOMError();
         return -1;
     }
@@ -135,7 +135,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename,
     /* call directly into xend here, as driver may not yet
        be set during open while we are building our
        initial list of domains */
-    DEBUG("Looking for dom with uuid: %s", uuid_str);
+    VIR_DEBUG("Looking for dom with uuid: %s", uuid_str);
     /* XXX Should not have to go via a virDomainPtr obj instance */
     if(!(dom = xenDaemonLookupByUUID(conn, rawuuid))) {
         /* If we are here, the domain has gone away.
@@ -149,7 +149,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename,
                     return -1;
                 }
                 memcpy(uuid, priv->configInfoList->doms[i]->uuid, VIR_UUID_BUFLEN);
-                DEBUG0("Found dom on list");
+                VIR_DEBUG0("Found dom on list");
                 return 0;
             }
         }
@@ -288,7 +288,7 @@ xenInotifyEvent(int watch ATTRIBUTE_UNUSED,
     virConnectPtr conn = data;
     xenUnifiedPrivatePtr priv = NULL;

-    DEBUG0("got inotify event");
+    VIR_DEBUG0("got inotify event");

     if( conn && conn->privateData ) {
         priv = conn->privateData;
@@ -437,7 +437,7 @@ xenInotifyOpen(virConnectPtr conn,
         return -1;
     }

-    DEBUG("Adding a watch on %s", priv->configDir);
+    VIR_DEBUG("Adding a watch on %s", priv->configDir);
     if (inotify_add_watch(priv->inotifyFD,
                           priv->configDir,
                           IN_CREATE |
@@ -449,18 +449,18 @@ xenInotifyOpen(virConnectPtr conn,
         return -1;
     }

-    DEBUG0("Building initial config cache");
+    VIR_DEBUG0("Building initial config cache");
     if (priv->useXenConfigCache &&
         xenXMConfigCacheRefresh (conn) < 0) {
-        DEBUG("Failed to enable XM config cache %s", conn->err.message);
+        VIR_DEBUG("Failed to enable XM config cache %s", conn->err.message);
         return -1;
     }

-    DEBUG0("Registering with event loop");
+    VIR_DEBUG0("Registering with event loop");
     /* Add the handle for monitoring */
     if ((priv->inotifyWatch = virEventAddHandle(priv->inotifyFD, VIR_EVENT_HANDLE_READABLE,
                                                 xenInotifyEvent, conn, NULL)) < 0) {
-        DEBUG0("Failed to add inotify handle, disabling events");
+        VIR_DEBUG0("Failed to add inotify handle, disabling events");
     }

     return 0;
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index bc23595..da8269d 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -522,7 +522,7 @@ xend_op_ext(virConnectPtr xend, const char *path, const char *key, va_list ap)
     }

     content = virBufferContentAndReset(&buf);
-    DEBUG("xend op: %s\n", content);
+    VIR_DEBUG("xend op: %s\n", content);
     ret = http2unix(xend_post(xend, path, content));
     VIR_FREE(content);

@@ -4603,7 +4603,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
         }
     }

-    DEBUG("hostname = %s, port = %s", hostname, port);
+    VIR_DEBUG("hostname = %s, port = %s", hostname, port);

     /* Make the call.
      * NB:  xend will fail the operation if any parameters are
@@ -4626,7 +4626,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
     if (ret == 0 && undefined_source)
         xenDaemonDomainUndefine (domain);

-    DEBUG0("migration done");
+    VIR_DEBUG0("migration done");

     return ret;
 }
@@ -5805,7 +5805,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
     char *bufout;
     int hvm = 0, i;

-    DEBUG0("Formatting domain sexpr");
+    VIR_DEBUG0("Formatting domain sexpr");

     virBufferAddLit(&buf, "(vm ");
     virBufferEscapeSexpr(&buf, "(name '%s')", def->name);
@@ -6058,7 +6058,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
     }

     bufout = virBufferContentAndReset(&buf);
-    DEBUG("Formatted sexpr: \n%s", bufout);
+    VIR_DEBUG("Formatted sexpr: \n%s", bufout);
     return bufout;

 error:
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 865805c..242a7de 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -363,13 +363,13 @@ xenXMConfigCacheRemoveFile(virConnectPtr conn,

     entry = virHashLookup(priv->configCache, filename);
     if (!entry) {
-        DEBUG("No config entry for %s", filename);
+        VIR_DEBUG("No config entry for %s", filename);
         return 0;
     }

     virHashRemoveEntry(priv->nameConfigMap, entry->def->name, NULL);
     virHashRemoveEntry(priv->configCache, filename, xenXMConfigFree);
-    DEBUG("Removed %s %s", entry->def->name, filename);
+    VIR_DEBUG("Removed %s %s", entry->def->name, filename);
     return 0;
 }

@@ -387,7 +387,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
     int newborn = 0;
     time_t now = time(NULL);

-    DEBUG("Adding file %s", filename);
+    VIR_DEBUG("Adding file %s", filename);

     /* Get modified time */
     if ((stat(filename, &st) < 0)) {
@@ -400,7 +400,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
     /* Ignore zero length files, because inotify fires before
        any content has actually been created */
     if (st.st_size == 0) {
-        DEBUG("Ignoring zero length file %s", filename);
+        VIR_DEBUG("Ignoring zero length file %s", filename);
         return -1;
     }

@@ -436,7 +436,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
     entry->refreshedAt = now;

     if (!(entry->def = xenXMConfigReadFile(conn, entry->filename))) {
-        DEBUG("Failed to read %s", entry->filename);
+        VIR_DEBUG("Failed to read %s", entry->filename);
         if (!newborn)
             virHashRemoveEntry(priv->configCache, filename, NULL);
         VIR_FREE(entry);
@@ -465,7 +465,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
             VIR_FREE(entry);
         }
     }
-    DEBUG("Added config %s %s", entry->def->name, filename);
+    VIR_DEBUG("Added config %s %s", entry->def->name, filename);

     return 0;
 }
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 7fff560..d9aad1f 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -327,7 +327,7 @@ xenStoreOpen(virConnectPtr conn,
                                            xenStoreWatchEvent,
                                            conn,
                                            NULL)) < 0)
-        DEBUG0("Failed to add event handle, disabling events");
+        VIR_DEBUG0("Failed to add event handle, disabling events");

     return 0;
 }
@@ -353,12 +353,12 @@ xenStoreClose(virConnectPtr conn)
     priv = (xenUnifiedPrivatePtr) conn->privateData;

     if (xenStoreRemoveWatch(conn, "@introduceDomain", "introduceDomain") < 0) {
-        DEBUG0("Warning, could not remove @introduceDomain watch");
+        VIR_DEBUG0("Warning, could not remove @introduceDomain watch");
         /* not fatal */
     }

     if (xenStoreRemoveWatch(conn, "@releaseDomain", "releaseDomain") < 0) {
-        DEBUG0("Warning, could not remove @releaseDomain watch");
+        VIR_DEBUG0("Warning, could not remove @releaseDomain watch");
         /* not fatal */
     }

@@ -1196,7 +1196,7 @@ int xenStoreRemoveWatch(virConnectPtr conn,
                        list->watches[i]->path,
                        list->watches[i]->token))
             {
-                DEBUG0("WARNING: Could not remove watch");
+                VIR_DEBUG0("WARNING: Could not remove watch");
                 /* Not fatal, continue */
             }

@@ -1351,7 +1351,7 @@ retry:
     VIR_FREE(new_domids);

     if (missing && retries--) {
-        DEBUG0("Some domains were missing, trying again");
+        VIR_DEBUG0("Some domains were missing, trying again");
         usleep(100 * 1000);
         goto retry;
     }
@@ -1426,7 +1426,7 @@ retry:
     VIR_FREE(new_domids);

     if (!removed && retries--) {
-        DEBUG0("No domains removed, retrying");
+        VIR_DEBUG0("No domains removed, retrying");
         usleep(100 * 1000);
         goto retry;
     }
-- 
1.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]