]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
maint: print flags in hex during debug
authorEric Blake <eblake@redhat.com>
Fri, 8 Jul 2011 15:18:48 +0000 (09:18 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 13 Jul 2011 13:47:45 +0000 (07:47 -0600)
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
src/fdstream.c
src/libvirt-qemu.c
src/locking/lock_driver_nop.c
src/locking/lock_driver_sanlock.c
src/locking/lock_manager.c
src/qemu/qemu_migration.c
src/qemu/qemu_monitor.c
src/rpc/virnetserverclient.c

diff --git a/cfg.mk b/cfg.mk
index aed9720f037c1c305554c40823f3a79aa53a23e9..ffaca85a760edf572deb1ce914d13debf568fd3a 100644 (file)
--- 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='\<mode=%[0-9.]*[diux]'                               \
+       halt='debug mode_t values with %o'                              \
+         $(_sc_search_regexp)
+       @prohibit='\<flags=%[0-9.]*l*[diou]'                            \
+       halt='debug flag values with %x'                                \
+         $(_sc_search_regexp)
+
 # Avoid functions that can lead to double-close bugs.
 sc_prohibit_close:
        @prohibit='([^>.]|^)\<[fp]?close *\('                           \
@@ -627,6 +636,8 @@ exclude_file_name_regexp--sc_avoid_write = \
 
 exclude_file_name_regexp--sc_bindtextdomain = ^(tests|examples)/
 
+exclude_file_name_regexp--sc_flags_debug = ^docs/
+
 exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
   ^src/rpc/gendispatch\.pl$$
 
index 54f8198aa0c34d590d8ecbdb4c1ec6db271daad1..c9fe2f33bf0d646fce654e1223dc3f596212e52c 100644 (file)
@@ -516,7 +516,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
     int errfd = -1;
     pid_t pid = 0;
 
-    VIR_DEBUG("st=%p path=%s flags=%d offset=%llu length=%llu mode=%d delete=%d",
+    VIR_DEBUG("st=%p path=%s flags=%x offset=%llu length=%llu mode=%o delete=%d",
               st, path, flags, offset, length, mode, delete);
 
     if (flags & O_CREAT)
index b9aa2dc9fdcd00b12d5abeaddf12e5af19f75818..9481e019445b51b73b547d251f03cf50ee5d5d26 100644 (file)
@@ -2,7 +2,7 @@
  * libvirt-qemu.c: Interfaces for the libvirt library to handle qemu-specific
  *                 APIs.
  *
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010-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
@@ -42,7 +42,8 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
 {
     virConnectPtr conn;
 
-    VIR_DEBUG("domain=%p, cmd=%s, result=%p, flags=%u", domain, cmd, result, flags);
+    VIR_DEBUG("domain=%p, cmd=%s, result=%p, flags=%x",
+              domain, cmd, result, flags);
 
     virResetLastError();
 
@@ -113,7 +114,7 @@ virDomainQemuAttach(virConnectPtr conn,
                     unsigned pid,
                     unsigned int flags)
 {
-    VIR_DEBUG("conn=%p, pid=%u, flags=%u", conn, pid, flags);
+    VIR_DEBUG("conn=%p, pid=%u, flags=%x", conn, pid, flags);
 
     virResetLastError();
 
index 0fab54c6e25710595ea86bfcad4429436b2a1510..0dcd7941d88e9614da79e5110f6e99e78dc89429 100644 (file)
@@ -31,7 +31,8 @@ static int virLockManagerNopInit(unsigned int version,
                                  const char *configFile,
                                  unsigned int flags)
 {
-    VIR_DEBUG("version=%u configFile=%s flags=%u", version, NULLSTR(configFile), flags);
+    VIR_DEBUG("version=%u configFile=%s flags=%x",
+              version, NULLSTR(configFile), flags);
 
     return 0;
 }
index 29d4176b5569f4991706cf28097cddcefb624345..87e78155b49fb395f443ae29adeebc3b01041c1d 100644 (file)
@@ -265,7 +265,8 @@ static int virLockManagerSanlockInit(unsigned int version,
                                      const char *configFile,
                                      unsigned int flags)
 {
-    VIR_DEBUG("version=%u configFile=%s flags=%u", version, NULLSTR(configFile), flags);
+    VIR_DEBUG("version=%u configFile=%s flags=%x",
+              version, NULLSTR(configFile), flags);
     virCheckFlags(0, -1);
 
     if (driver)
index 4ee7f4456a7122e96407ae00ed48b06ee4c0d4fe..d27cf8fd921fa187e1eef92d010f7d8bd39e5c3d 100644 (file)
@@ -286,7 +286,7 @@ virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin,
                                     unsigned int flags)
 {
     virLockManagerPtr lock;
-    VIR_DEBUG("plugin=%p type=%u nparams=%zu params=%p flags=%u",
+    VIR_DEBUG("plugin=%p type=%u nparams=%zu params=%p flags=%x",
               plugin, type, nparams, params, flags);
     virLockManagerLogParams(nparams, params);
 
@@ -315,7 +315,7 @@ int virLockManagerAddResource(virLockManagerPtr lock,
                               virLockManagerParamPtr params,
                               unsigned int flags)
 {
-    VIR_DEBUG("lock=%p type=%u name=%s nparams=%zu params=%p flags=%u",
+    VIR_DEBUG("lock=%p type=%u name=%s nparams=%zu params=%p flags=%x",
               lock, type, name, nparams, params, flags);
     virLockManagerLogParams(nparams, params);
 
@@ -332,7 +332,8 @@ int virLockManagerAcquire(virLockManagerPtr lock,
                           unsigned int flags,
                           int *fd)
 {
-    VIR_DEBUG("lock=%p state='%s' flags=%u fd=%p", lock, NULLSTR(state), flags, fd);
+    VIR_DEBUG("lock=%p state='%s' flags=%x fd=%p",
+              lock, NULLSTR(state), flags, fd);
 
     CHECK_MANAGER(drvAcquire, -1);
 
@@ -347,7 +348,7 @@ int virLockManagerRelease(virLockManagerPtr lock,
                           char **state,
                           unsigned int flags)
 {
-    VIR_DEBUG("lock=%p state=%p flags=%u", lock, state, flags);
+    VIR_DEBUG("lock=%p state=%p flags=%x", lock, state, flags);
 
     CHECK_MANAGER(drvRelease, -1);
 
@@ -359,7 +360,7 @@ int virLockManagerInquire(virLockManagerPtr lock,
                           char **state,
                           unsigned int flags)
 {
-    VIR_DEBUG("lock=%p state=%p flags=%u", lock, state, flags);
+    VIR_DEBUG("lock=%p state=%p flags=%x", lock, state, flags);
 
     CHECK_MANAGER(drvInquire, -1);
 
index 524465d487b448631f87c870c346b6f3b66c997a..b735d2789e63c3aecd11fb32fc28efbb2befacb6 100644 (file)
@@ -1380,7 +1380,7 @@ static int doNativeMigrate(struct qemud_driver *driver,
     unsigned int background_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
     qemuMigrationCookiePtr mig = NULL;
     VIR_DEBUG("driver=%p, vm=%p, uri=%s, cookiein=%s, cookieinlen=%d, "
-              "cookieout=%p, cookieoutlen=%p, flags=%u, dname=%s, resource=%lu",
+              "cookieout=%p, cookieoutlen=%p, flags=%x, dname=%s, resource=%lu",
               driver, vm, uri, NULLSTR(cookiein), cookieinlen,
               cookieout, cookieoutlen, flags, NULLSTR(dname), resource);
 
@@ -1600,7 +1600,7 @@ static int doTunnelMigrate(struct qemud_driver *driver,
     qemuMigrationCookiePtr mig = NULL;
     qemuMigrationIOThreadPtr iothread = NULL;
     VIR_DEBUG("driver=%p, vm=%p, st=%p, cookiein=%s, cookieinlen=%d, "
-              "cookieout=%p, cookieoutlen=%p, flags=%lu, resource=%lu",
+              "cookieout=%p, cookieoutlen=%p, flags=%lx, resource=%lu",
               driver, vm, st, NULLSTR(cookiein), cookieinlen,
               cookieout, cookieoutlen, flags, resource);
 
@@ -1829,7 +1829,7 @@ static int doPeer2PeerMigrate2(struct qemud_driver *driver,
     int cancelled;
     virStreamPtr st = NULL;
     VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, "
-              "flags=%lu, dname=%s, resource=%lu",
+              "flags=%lx, dname=%s, resource=%lu",
               driver, sconn, dconn, vm, NULLSTR(dconnuri),
               flags, NULLSTR(dname), resource);
 
@@ -1972,7 +1972,7 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
     int cancelled;
     virStreamPtr st = NULL;
     VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, xmlin=%s, "
-              "dconnuri=%s, uri=%s, flags=%lu, dname=%s, resource=%lu",
+              "dconnuri=%s, uri=%s, flags=%lx, dname=%s, resource=%lu",
               driver, sconn, dconn, vm, NULLSTR(xmlin),
               NULLSTR(dconnuri), NULLSTR(uri), flags,
               NULLSTR(dname), resource);
@@ -2142,7 +2142,7 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
     virConnectPtr dconn = NULL;
     bool p2p;
     VIR_DEBUG("driver=%p, sconn=%p, vm=%p, xmlin=%s, dconnuri=%s, "
-              "uri=%s, flags=%lu, dname=%s, resource=%lu",
+              "uri=%s, flags=%lx, dname=%s, resource=%lu",
               driver, sconn, vm, NULLSTR(xmlin), NULLSTR(dconnuri),
               NULLSTR(uri), flags, NULLSTR(dname), resource);
 
@@ -2221,7 +2221,7 @@ int qemuMigrationPerform(struct qemud_driver *driver,
     qemuDomainObjPrivatePtr priv = vm->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);
 
index e593642f505b61ef70acbafd133f07921b145793..cff7220fb48dab8855af0846b5041776adf55856 100644 (file)
@@ -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) {
index 742c3a4bbabdd7f4c77b6cfdf5deb40226cc17f0..341981f46f6280b8084d40106e53e6b2d281e353 100644 (file)
@@ -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;
 }