[libvirt] [PATCH] Don't log qemu monitor output from blockStats

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

 



The attached patch changes the qemu driver blockStats command to not log
qemu monitor output. virt-manager offers an option to continually poll
VM disk stats, and if the app is left running for a while with many VMs,
this can make the logs huge, for little benefit (a user reported 100 MB
with virt-manager left running overnight).

The output from the command is still printed with a DEBUG call, so the
info isn't completely lost.

Thanks,
Cole
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 3b9b08a..b3bfd51 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -115,11 +115,15 @@ static int qemudDomainGetMaxVcpus(virDomainPtr dom);
 static int qemudMonitorCommand(const virDomainObjPtr vm,
                                const char *cmd,
                                char **reply);
+static int qemudMonitorCommandNoLog(const virDomainObjPtr vm,
+                                    const char *cmd,
+                                    char **reply);
 static int qemudMonitorCommandExtra(const virDomainObjPtr vm,
                                     const char *cmd,
                                     const char *extra,
                                     const char *extraPrompt,
-                                    char **reply);
+                                    char **reply,
+                                    int doLog);
 
 static struct qemud_driver *qemu_driver = NULL;
 
@@ -1083,7 +1087,8 @@ qemudInitPasswords(virConnectPtr conn,
                                      vm->def->graphics->data.vnc.passwd :
                                      driver->vncPassword,
                                      QEMU_PASSWD_PROMPT,
-                                     &info) < 0) {
+                                     &info,
+                                     1) < 0) {
             qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
                              "%s", _("setting VNC password failed"));
             return -1;
@@ -1428,7 +1433,8 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
                          const char *cmd,
                          const char *extra,
                          const char *extraPrompt,
-                         char **reply) {
+                         char **reply,
+                         int doLog) {
     int size = 0;
     char *buf = NULL;
     size_t cmdlen = strlen(cmd);
@@ -1507,7 +1513,7 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
     }
 
     /* Log, but ignore failures to write logfile for VM */
-    if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
+    if (doLog && safewrite(vm->logfile, buf, strlen(buf)) < 0) {
         char ebuf[1024];
         qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s\n"),
                  virStrerror(errno, ebuf, sizeof ebuf));
@@ -1533,9 +1539,15 @@ static int
 qemudMonitorCommand(const virDomainObjPtr vm,
                     const char *cmd,
                     char **reply) {
-    return qemudMonitorCommandExtra(vm, cmd, NULL, NULL, reply);
+    return qemudMonitorCommandExtra(vm, cmd, NULL, NULL, reply, 1);
 }
 
+static int
+qemudMonitorCommandNoLog(const virDomainObjPtr vm,
+                         const char *cmd,
+                         char **reply) {
+    return qemudMonitorCommandExtra(vm, cmd, NULL, NULL, reply, 0);
+}
 
 /**
  * qemudProbe:
@@ -3774,7 +3786,10 @@ qemudDomainBlockStats (virDomainPtr dom,
         goto cleanup;
     len = strlen (qemu_dev_name);
 
-    if (qemudMonitorCommand (vm, "info blockstats", &info) < 0) {
+    /* Specifically don't log the command output, since regular polling
+     * will create huuuuge logs.
+     */
+    if (qemudMonitorCommandNoLog (vm, "info blockstats", &info) < 0) {
         qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
                           "%s", _("'info blockstats' command failed"));
         goto cleanup;
--
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]