Re: [libvirt] respect debug level for domain log file

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

 



On Thu, Apr 16, 2009 at 01:29:08PM +0100, Daniel P. Berrange wrote:
> On Thu, Apr 16, 2009 at 02:17:29PM +0200, Guido G?nther wrote:
> > Hi,
> > currently every monitor command is dumped into the domain logfiles, this
> > can lead to huge logs[1]. Since we're not going through the normal
> > logging facilites to get per domain logfiles we should at least resepct
> > the default priority.
> 
> IMHO this should just be removed. We already have ability to log all
> monitor commands via the normal logging mechanism, so we no longer have a
> need to write them out to the domain logs. We should leave the domain logs
> just for QEMU's stdout/err as we originally had them. 
I'm all for it since this makes reparsing the log output safer too.

Attached patch remove the monitor output from the domain log file. To
compensate it prefixes the debug replies with the vm name so it's easier
to find out what's wrong on a crowded system.
Cheers,
 -- Guido
>From fb747f192be033bdab8cd63221e4bcd4d418ba1a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx@xxxxxxxxxxx>
Date: Thu, 16 Apr 2009 15:33:46 +0200
Subject: [PATCH] don't log monitor command output into domain log file

since it ends up in the generic logging system too.  Prefix monitor
debug output with vm name to make debugging easier on crowsded systems.
---
 src/qemu_driver.c |   60 +++++++++++++++++++++-------------------------------
 1 files changed, 24 insertions(+), 36 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 79ee072..f5b5fa5 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1710,27 +1710,11 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
             goto error;
         }
     }
-
-    /* Log, but ignore failures to write logfile for VM */
-    if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
-        char ebuf[1024];
-        VIR_WARN(_("Unable to log VM console data: %s\n"),
-                 virStrerror(errno, ebuf, sizeof ebuf));
-    }
-
     *reply = buf;
     return 0;
 
  error:
-    if (buf) {
-        /* Log, but ignore failures to write logfile for VM */
-        if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
-            char ebuf[1024];
-            VIR_WARN(_("Unable to log VM console data: %s\n"),
-                     virStrerror(errno, ebuf, sizeof ebuf));
-        }
-        VIR_FREE(buf);
-    }
+    VIR_FREE(buf);
     return -1;
 }
 
@@ -2463,7 +2447,7 @@ static int qemudDomainGetMemoryBalloon(virConnectPtr conn,
         goto cleanup;
     }
 
-    DEBUG ("balloon reply: '%s'", reply);
+    DEBUG ("%s: balloon reply: '%s'", vm->def->name, reply);
     if ((offset = strstr(reply, BALLOON_PREFIX)) != NULL) {
         unsigned int memMB;
         char *end;
@@ -2517,7 +2501,7 @@ static int qemudDomainSetMemoryBalloon(virConnectPtr conn,
 
     /* If the command failed qemu prints: 'unknown command'
      * No message is printed on success it seems */
-    DEBUG ("balloon reply: %s", reply);
+    DEBUG ("%s: balloon reply: %s",vm->def->name,  reply);
     if (strstr(reply, "\nunknown command:")) {
         /* Don't set error - it is expected memory balloon fails on many qemu */
         ret = 0;
@@ -2812,7 +2796,7 @@ static int qemudDomainSave(virDomainPtr dom,
         goto cleanup;
     }
 
-    DEBUG ("migrate reply: %s", info);
+    DEBUG ("%s: migrate reply: %s", vm->def->name, info);
 
     /* If the command isn't supported then qemu prints:
      * unknown command: migrate" */
@@ -3658,7 +3642,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
     /* If the command failed qemu prints:
      * device not found, device is locked ...
      * No message is printed on success it seems */
-    DEBUG ("ejectable media change reply: %s", reply);
+    DEBUG ("%s: ejectable media change reply: %s", vm->def->name, reply);
     if (strstr(reply, "\ndevice ")) {
         qemudReportError (conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
                           _("changing cdrom media failed: %s"), reply);
@@ -3719,7 +3703,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
         return -1;
     }
 
-    DEBUG ("pci_add reply: %s", reply);
+    DEBUG ("%s: pci_add reply: %s", vm->def->name, reply);
     /* If the command succeeds qemu prints:
      * OK bus 0... */
 #define PCI_ATTACH_OK_MSG "OK bus 0, slot "
@@ -3787,7 +3771,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
         return -1;
     }
 
-    DEBUG ("attach_usb reply: %s", reply);
+    DEBUG ("%s: attach_usb reply: %s",vm->def->name,  reply);
     /* If the command failed qemu prints:
      * Could not add ... */
     if (strstr(reply, "Could not add ")) {
@@ -3841,7 +3825,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
         return -1;
     }
 
-    DEBUG ("attach_usb reply: %s", reply);
+    DEBUG ("%s: attach_usb reply: %s", vm->def->name, reply);
     /* If the command failed qemu prints:
      * Could not add ... */
     if (strstr(reply, "Could not add ")) {
@@ -3980,7 +3964,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
         goto cleanup;
     }
 
-    DEBUG ("pci_del reply: %s", reply);
+    DEBUG ("%s: pci_del reply: %s",vm->def->name,  reply);
     /* If the command fails due to a wrong slot qemu prints: invalid slot,
      * nothing is printed on success */
     if (strstr(reply, "invalid slot")) {
@@ -4210,7 +4194,7 @@ qemudDomainBlockStats (virDomainPtr dom,
                           "%s", _("'info blockstats' command failed"));
         goto cleanup;
     }
-    DEBUG ("info blockstats reply: %s", info);
+    DEBUG ("%s: info blockstats reply: %s", vm->def->name, info);
 
     /* If the command isn't supported then qemu prints the supported
      * info commands, so the output starts "info ".  Since this is
@@ -4251,21 +4235,25 @@ qemudDomainBlockStats (virDomainPtr dom,
                 if (STRPREFIX (p, "rd_bytes=")) {
                     p += 9;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->rd_bytes) == -1)
-                        DEBUG ("error reading rd_bytes: %s", p);
+                        DEBUG ("%s: error reading rd_bytes: %s",
+                               vm->def->name, p);
                 } else if (STRPREFIX (p, "wr_bytes=")) {
                     p += 9;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->wr_bytes) == -1)
-                        DEBUG ("error reading wr_bytes: %s", p);
+                        DEBUG ("%s: error reading wr_bytes: %s",
+                               vm->def->name, p);
                 } else if (STRPREFIX (p, "rd_operations=")) {
                     p += 14;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->rd_req) == -1)
-                        DEBUG ("error reading rd_req: %s", p);
+                        DEBUG ("%s: error reading rd_req: %s",
+                               vm->def->name, p);
                 } else if (STRPREFIX (p, "wr_operations=")) {
                     p += 14;
                     if (virStrToLong_ll (p, &dummy, 10, &stats->wr_req) == -1)
-                        DEBUG ("error reading wr_req: %s", p);
+                        DEBUG ("%s: error reading wr_req: %s",
+                               vm->def->name, p);
                 } else
-                    DEBUG ("unknown block stat near %s", p);
+                    DEBUG ("%s: unknown block stat near %s", vm->def->name, p);
 
                 /* Skip to next label. */
                 p = strchr (p, ' ');
@@ -4477,7 +4465,7 @@ qemudDomainMemoryPeek (virDomainPtr dom,
         goto cleanup;
     }
 
-    DEBUG ("memsave reply: %s", info);
+    DEBUG ("%s: memsave reply: %s", vm->def->name, info);
 
     /* Read the memory file into buffer. */
     if (saferead (fd, buffer, size) == (ssize_t) -1) {
@@ -4794,7 +4782,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
                              "%s", _("off-line migration specified, but suspend operation failed"));
             goto cleanup;
         }
-        DEBUG ("stop reply: %s", info);
+        DEBUG ("%s: stop reply: %s", vm->def->name, info);
         VIR_FREE(info);
         paused = 1;
 
@@ -4811,7 +4799,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
         snprintf (cmd, sizeof cmd, "migrate_set_speed %lum", resource);
         qemudMonitorCommand (vm, cmd, &info);
 
-        DEBUG ("migrate_set_speed reply: %s", info);
+        DEBUG ("%s: migrate_set_speed reply: %s", vm->def->name, info);
         VIR_FREE (info);
     }
 
@@ -4830,7 +4818,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
         goto cleanup;
     }
 
-    DEBUG ("migrate reply: %s", info);
+    DEBUG ("%s: migrate reply: %s", vm->def->name, info);
 
     /* Now check for "fail" in the output string */
     if (strstr(info, "fail") != NULL) {
@@ -4869,7 +4857,7 @@ cleanup:
                       vm->def->name);
         }
         else {
-            DEBUG ("cont reply: %s", info);
+            DEBUG ("%s: cont reply: %s", vm->def->name, info);
             VIR_FREE(info);
         }
 
-- 
1.6.2.1

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