[libvirt] [PATCH] Improve debugging of QEMU start/stop

From: "Daniel P. Berrange" <berrange@redhat.com> Include reference of the VM object pointer and name in debug logs for QEMU start/stop functions. Also make sure we log the PID that we started, since it isn't available elsewhere in the logs. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/qemu/qemu_process.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bdffdf8..dd7566b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3499,6 +3499,9 @@ int qemuProcessStart(virConnectPtr conn, virQEMUDriverConfigPtr cfg; virCapsPtr caps = NULL; + VIR_DEBUG("vm=%p name=%s id=%d pid=%d", + vm, vm->def->name, vm->def->id, vm->pid); + /* Okay, these are just internal flags, * but doesn't hurt to check */ virCheckFlags(VIR_QEMU_PROCESS_START_COLD | @@ -3845,23 +3848,11 @@ int qemuProcessStart(virConnectPtr conn, _("Domain %s didn't show up"), vm->def->name); ret = -1; } -#if 0 - } else if (ret == -2) { - /* - * XXX this is bogus. It isn't safe to set vm->pid = child - * because the child no longer exists. - */ - - /* The virCommand process that launches the daemon failed. Pending on - * when it failed (we can't determine for sure), there may be - * extra info in the domain log (if the hook failed for example). - * - * Pretend like things succeeded, and let 'WaitForMonitor' report - * the log contents for us. - */ - vm->pid = child; - ret = 0; -#endif + VIR_DEBUG("QEMU vm=%p name=%s running with pid=%llu", + vm, vm->def->name, (unsigned long long)vm->pid); + } else { + VIR_DEBUG("QEMU vm=%p name=%s failed to spawn", + vm, vm->def->name); } VIR_DEBUG("Writing early domain status to disk"); @@ -4085,8 +4076,8 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags) { int ret; - VIR_DEBUG("vm=%s pid=%d flags=%x", - vm->def->name, vm->pid, flags); + VIR_DEBUG("vm=%p name=%s pid=%d flags=%x", + vm, vm->def->name, vm->pid, flags); if (!(flags & VIR_QEMU_PROCESS_KILL_NOCHECK)) { if (!virDomainObjIsActive(vm)) { @@ -4126,8 +4117,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, char ebuf[1024]; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - VIR_DEBUG("Shutting down VM '%s' pid=%d flags=%x", - vm->def->name, vm->pid, flags); + VIR_DEBUG("Shutting down vm=%p name=%s id=%d pid=%d flags=%x", + vm, vm->def->name, vm->def->id, vm->pid, flags); if (!virDomainObjIsActive(vm)) { VIR_DEBUG("VM '%s' not active", vm->def->name); -- 1.8.3.1

On 10/31/2013 05:29 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Include reference of the VM object pointer and name in debug logs for QEMU start/stop functions. Also make sure we log the PID that we started, since it isn't available elsewhere in the logs.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/qemu/qemu_process.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bdffdf8..dd7566b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3499,6 +3499,9 @@ int qemuProcessStart(virConnectPtr conn, virQEMUDriverConfigPtr cfg; virCapsPtr caps = NULL;
+ VIR_DEBUG("vm=%p name=%s id=%d pid=%d", + vm, vm->def->name, vm->def->id, vm->pid);
Needs to be '"pid=%llu", (unsigned long long) vm->pid' no thanks to mingw64.
+ VIR_DEBUG("QEMU vm=%p name=%s running with pid=%llu", + vm, vm->def->name, (unsigned long long)vm->pid);
This one is correct.
@@ -4085,8 +4076,8 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags) { int ret;
- VIR_DEBUG("vm=%s pid=%d flags=%x", - vm->def->name, vm->pid, flags); + VIR_DEBUG("vm=%p name=%s pid=%d flags=%x", + vm, vm->def->name, vm->pid, flags);
Another incorrect type.
if (!(flags & VIR_QEMU_PROCESS_KILL_NOCHECK)) { if (!virDomainObjIsActive(vm)) { @@ -4126,8 +4117,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, char ebuf[1024]; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- VIR_DEBUG("Shutting down VM '%s' pid=%d flags=%x", - vm->def->name, vm->pid, flags); + VIR_DEBUG("Shutting down vm=%p name=%s id=%d pid=%d flags=%x", + vm, vm->def->name, vm->def->id, vm->pid, flags);
and another. ACK if you consistently print pid_t as %llu. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake