From 182a3cac2b4339e988802eb02279e7ab4c883c67 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Guido=20G=C3=BCnther?= Date: Thu, 16 Apr 2009 15:56:27 +0000 Subject: [PATCH] Don't log monitor output to domain log file. It's logged via the logging system already. Prefix monitor debug output with vm name. (cherry picked from commit 5caa1e0eb050a12fe8ed02cf635bb672a56cdb6f) Fedora-patch: libvirt-0.6.2-do-not-log-monitor-output.patch --- 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 5ca3d20..cb738b2 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1706,27 +1706,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; } @@ -2461,7 +2445,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; @@ -2515,7 +2499,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; @@ -2810,7 +2794,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" */ @@ -3662,7 +3646,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); @@ -3723,7 +3707,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 " @@ -3791,7 +3775,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 ")) { @@ -3845,7 +3829,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 ")) { @@ -3984,7 +3968,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")) { @@ -4214,7 +4198,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 @@ -4255,21 +4239,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, ' '); @@ -4481,7 +4469,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) { @@ -4798,7 +4786,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; @@ -4815,7 +4803,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); } @@ -4834,7 +4822,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) { @@ -4873,7 +4861,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.5