Re: [Patch 2/3]virsh: Make "DEBUG" loglevel the superset

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

 



On 07/14/2011 05:28 PM, Jiri Denemark wrote:
On Thu, Jun 30, 2011 at 13:52:32 +0530, Supriya Kannery wrote:

      va_start(ap, format);
      if (virVasprintf(&str, format, ap)<  0) {
          /* Skip debug messages on low memory */


This breaks make check for two reasons. First, it reverses the condition but
leaves default level unchanged, so instead of not printint 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.


Jiri,
   Thanks! for reviewing this patchset.

I missed to look at make check. Will take this as a learning while preparing future patches.

In other words, the following patch needs to be squashed in.

Jirka

diff --git a/tests/virsh-optparse b/tests/virsh-optparse
index 092e80d..7b3a25d 100755
--- a/tests/virsh-optparse
+++ b/tests/virsh-optparse
@@ -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
diff --git a/tools/virsh.c b/tools/virsh.c
index dda86cb..6d356d2 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -98,6 +98,8 @@ typedef enum {
      VSH_ERR_ERROR
  } vshErrorLevel;

+#define VSH_DEBUG_DEFAULT VSH_ERR_ERROR
+
  /*
   * virsh command line grammar:
   *
@@ -13406,15 +13408,17 @@ vshInit(vshControl *ctl)
      if (ctl->conn)
          return false;

-    if (ctl->debug == -1) {
+    if (ctl->debug == VSH_DEBUG_DEFAULT) {

ctl->debug was initialized to -1, so that, if it is already set from commandline, there is no need to read ENV. My intention was to keep the order as cmdline > ENV and avoid overwriting of cmd loglevel by ENV.

If we initialize ctl->debug to VSH_DEBUG_DEFAULT, incase from commandline, user set -d as VSH_ERR_ERROR (or VSH_DEBUG_DEFAULT), then unnecessarily ctl->debug will be overwritten by ENV.

@@ -14102,7 +14106,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");

--
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]