From 06dbfa6d21b82e17c60e13da668ce53640a06f5f Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 8 Jul 2011 09:18:48 -0600 Subject: [PATCH] maint: print flags in hex during debug Continuation of commit 313ac7fd, and enforce things with a syntax check. Technically, virNetServerClientCalculateHandleMode is not printing a mode_t, but rather a collection of VIR_EVENT_HANDLE_* bits; however, these bits are < 8, so there is no different in the output, and that was the easiest way to silence the new syntax check. * cfg.mk (sc_flags_debug): New syntax check. (exclude_file_name_regexp--sc_flags_debug): Add exemptions. * src/fdstream.c (virFDStreamOpenFileInternal): Print flags in hex, mode_t in octal. * src/libvirt-qemu.c (virDomainQemuMonitorCommand) (virDomainQemuAttach): Likewise. * src/locking/lock_driver_nop.c (virLockManagerNopInit): Likewise. * src/locking/lock_driver_sanlock.c (virLockManagerSanlockInit): Likewise. * src/locking/lock_manager.c: Likewise. * src/qemu/qemu_migration.c: Likewise. * src/qemu/qemu_monitor.c: Likewise. * src/rpc/virnetserverclient.c (virNetServerClientCalculateHandleMode): Print mode with %o. --- cfg.mk | 11 +++++++++++ src/fdstream.c | 2 +- src/libvirt-qemu.c | 7 ++++--- src/locking/lock_driver_nop.c | 3 ++- src/locking/lock_driver_sanlock.c | 3 ++- src/locking/lock_manager.c | 11 ++++++----- src/qemu/qemu_migration.c | 16 ++++++++-------- src/qemu/qemu_monitor.c | 10 +++++----- src/rpc/virnetserverclient.c | 2 +- 9 files changed, 40 insertions(+), 25 deletions(-) diff --git a/cfg.mk b/cfg.mk index aed9720f03..ffaca85a76 100644 --- a/cfg.mk +++ b/cfg.mk @@ -269,6 +269,15 @@ sc_avoid_write: halt='consider using safewrite instead of write' \ $(_sc_search_regexp) +# In debug statements, print flags as bitmask and mode_t as octal. +sc_flags_debug: + @prohibit='\privateData; VIR_DEBUG("driver=%p, conn=%p, vm=%p, xmlin=%s, dconnuri=%s, " "uri=%s, cookiein=%s, cookieinlen=%d, cookieout=%p, " - "cookieoutlen=%p, flags=%lu, dname=%s, resource=%lu, v3proto=%d", + "cookieoutlen=%p, flags=%lx, dname=%s, resource=%lu, v3proto=%d", driver, conn, vm, NULLSTR(xmlin), NULLSTR(dconnuri), NULLSTR(uri), NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, NULLSTR(dname), @@ -2387,7 +2387,7 @@ qemuMigrationFinish(struct qemud_driver *driver, qemuDomainObjPrivatePtr priv = NULL; qemuMigrationCookiePtr mig = NULL; VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, " - "cookieout=%p, cookieoutlen=%p, flags=%lu, retcode=%d", + "cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d", driver, dconn, vm, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, retcode); virErrorPtr orig_err = NULL; @@ -2571,7 +2571,7 @@ int qemuMigrationConfirm(struct qemud_driver *driver, virDomainEventPtr event = NULL; int rv = -1; VIR_DEBUG("driver=%p, conn=%p, vm=%p, cookiein=%s, cookieinlen=%d, " - "flags=%u, retcode=%d", + "flags=%x, retcode=%d", driver, conn, vm, NULLSTR(cookiein), cookieinlen, flags, retcode); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e593642f50..cff7220fb4 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1534,7 +1534,7 @@ int qemuMonitorMigrateToFd(qemuMonitorPtr mon, int fd) { int ret; - VIR_DEBUG("mon=%p fd=%d flags=%u", + VIR_DEBUG("mon=%p fd=%d flags=%x", mon, fd, flags); if (!mon) { @@ -1567,7 +1567,7 @@ int qemuMonitorMigrateToHost(qemuMonitorPtr mon, { int ret; char *uri = NULL; - VIR_DEBUG("mon=%p hostname=%s port=%d flags=%u", + VIR_DEBUG("mon=%p hostname=%s port=%d flags=%x", mon, hostname, port, flags); if (!mon) { @@ -1599,7 +1599,7 @@ int qemuMonitorMigrateToCommand(qemuMonitorPtr mon, char *argstr; char *dest = NULL; int ret = -1; - VIR_DEBUG("mon=%p argv=%p flags=%u", + VIR_DEBUG("mon=%p argv=%p flags=%x", mon, argv, flags); if (!mon) { @@ -1640,7 +1640,7 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon, char *dest = NULL; int ret = -1; char *safe_target = NULL; - VIR_DEBUG("mon=%p argv=%p target=%s offset=%llu flags=%u", + VIR_DEBUG("mon=%p argv=%p target=%s offset=%llu flags=%x", mon, argv, target, offset, flags); if (!mon) { @@ -1703,7 +1703,7 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon, { char *dest = NULL; int ret = -1; - VIR_DEBUG("mon=%p, unixfile=%s flags=%u", + VIR_DEBUG("mon=%p, unixfile=%s flags=%x", mon, unixfile, flags); if (!mon) { diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 742c3a4bba..341981f46f 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -156,7 +156,7 @@ virNetServerClientCalculateHandleMode(virNetServerClientPtr client) { if (client->tx) mode |= VIR_EVENT_HANDLE_WRITABLE; } - VIR_DEBUG("mode=%d", mode); + VIR_DEBUG("mode=%o", mode); return mode; }