[libvirt] [PATCH] Debug: Record the VM PID in per-VM logs.

Prerna Saxena saxenap.ltc at gmail.com
Mon Jul 18 06:17:01 UTC 2016


For certain situations such as Out-of-memory scenarios, it is helpful to
record the QEMU PID in the per-VM logs, so that correlation with kernel-reported
events is easier.

While this is already recorded in libvirt daemon logs as a DEBUG message,
I believe it merits more attention :-)
Hence introducing it in per-VM log.

Signed-off-by: Prerna Saxena <saxenap.ltc at gmail.com>
---
 src/qemu/qemu_process.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4adb14e..2d3b0f5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4983,6 +4983,7 @@ qemuProcessLaunch(virConnectPtr conn,
     int ret = -1;
     int rv;
     int logfile = -1;
+    char *msg_buffer = NULL;
     qemuDomainLogContextPtr logCtxt = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virCommandPtr cmd = NULL;
@@ -5095,8 +5096,14 @@ qemuProcessLaunch(virConnectPtr conn,
                            _("Domain %s didn't show up"), vm->def->name);
             rv = -1;
         }
+
         VIR_DEBUG("QEMU vm=%p name=%s running with pid=%llu",
                   vm, vm->def->name, (unsigned long long)vm->pid);
+        ignore_value(virAsprintf(&msg_buffer,
+                    "QEMU vm=%p name=%s running with pid=%llu",
+                    vm, vm->def->name, (unsigned long long)vm->pid));
+        qemuLogOperation(vm, msg_buffer, NULL, logCtxt);
+        virFree(msg_buffer);
     } else {
         VIR_DEBUG("QEMU vm=%p name=%s failed to spawn",
                   vm, vm->def->name);
-- 
1.8.1.2




More information about the libvir-list mailing list