]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Avoid operations on NULL monitor if VM fails early
authorPeter Krempa <pkrempa@redhat.com>
Tue, 14 Jan 2014 18:13:30 +0000 (19:13 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 13 Mar 2014 08:26:59 +0000 (09:26 +0100)
commitfe74170701bf4b52de4f1d5643ade57883b44eed
treeccb0de59c94bf4cba579cd0a94567409ae95e480
parent98069ba7a1c3f1a6764869861c985c423d35fd28
qemu: Avoid operations on NULL monitor if VM fails early

https://bugzilla.redhat.com/show_bug.cgi?id=1047659

If a VM dies very early during an attempted connect to the guest agent
while the locks are down the domain monitor object will be freed. The
object is then accessed later as any failure during guest agent startup
isn't considered fatal.

In the current upstream version this doesn't lead to a crash as
virObjectLock called when entering the monitor in
qemuProcessDetectVcpuPIDs checks the pointer before attempting to
dereference (lock) it. The NULL pointer is then caught in the monitor
helper code.

Before the introduction of virObjectLockable - observed on 0.10.2 - the
pointer is locked directly via virMutexLock leading to a crash.

To avoid this problem we need to differentiate between the guest agent
not being present and the VM quitting when the locks were down. The fix
reorganizes the code in qemuConnectAgent to add the check and then adds
special handling to the callers.

(cherry picked from commit b952cbbccafd5ead8b5a70b2608a1d5a7f03b31e)
src/qemu/qemu_process.c