]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: fix previous patch
authorJiri Denemark <jdenemar@redhat.com>
Thu, 14 Jul 2011 11:58:02 +0000 (13:58 +0200)
committerEric Blake <eblake@redhat.com>
Thu, 14 Jul 2011 13:14:05 +0000 (07:14 -0600)
The last patch breaks make check for two reasons. First, it reverses the
condition but leaves default level unchanged, so instead of not printing
anything but errors before the patch it now prints all debug messages by
default. Second, you forgot to change -d5 option passed to virsh in
tests/virsh-optparse to -d0; the script wants to see all debug messages.

tests/virsh-optparse
tools/virsh.c

index 092e80d6879f9e66ce8712258f51f08c755439b8..7b3a25d1daf62ecbe4d5a84b9a303df58a15c082 100755 (executable)
@@ -64,7 +64,7 @@ for args in \
     '--count 2 test' \
     '--count=2 test' \
 ; do
-  virsh -d5 -c $test_url setvcpus $args >out 2>>err || fail=1
+  virsh -d0 -c $test_url setvcpus $args >out 2>>err || fail=1
   LC_ALL=C sort out | compare - exp-out || fail=1
 done
 test -s err && fail=1
index 563497e53011cca35a97f5c61218666c45661c0a..bd6fea7cd29f08c650a90d59ae76953d4ee72afc 100644 (file)
@@ -98,6 +98,8 @@ typedef enum {
     VSH_ERR_ERROR
 } vshErrorLevel;
 
+#define VSH_DEBUG_DEFAULT VSH_ERR_ERROR
+
 /*
  * virsh command line grammar:
  *
@@ -13410,15 +13412,17 @@ vshInit(vshControl *ctl)
     if (ctl->conn)
         return false;
 
-    if (ctl->debug == -1) {
+    if (ctl->debug == VSH_DEBUG_DEFAULT) {
         /* log level not set from commandline, check env variable */
         debugEnv = getenv("VIRSH_DEBUG");
         if (debugEnv) {
-            if (virStrToLong_i(debugEnv, NULL, 10, &ctl->debug) < 0 ||
-                ctl->debug < VSH_ERR_DEBUG || ctl->debug > VSH_ERR_ERROR) {
+            int debug;
+            if (virStrToLong_i(debugEnv, NULL, 10, &debug) < 0 ||
+                debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) {
                 vshError(ctl, "%s",
                          _("VIRSH_DEBUG not set with a valid numeric value"));
-                ctl->debug = VSH_ERR_DEBUG;
+            } else {
+                ctl->debug = debug;
             }
         }
     }
@@ -14106,7 +14110,7 @@ main(int argc, char **argv)
     memset(ctl, 0, sizeof(vshControl));
     ctl->imode = true;          /* default is interactive mode */
     ctl->log_fd = -1;           /* Initialize log file descriptor */
-    ctl->debug = -1;            /* Initialize log level */
+    ctl->debug = VSH_DEBUG_DEFAULT;
 
     if (!setlocale(LC_ALL, "")) {
         perror("setlocale");