]> 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)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 15 Jan 2014 17:04:25 +0000 (18:04 +0100)
commitb952cbbccafd5ead8b5a70b2608a1d5a7f03b31e
tree46b0afee43d6bd13ce5647166b484622141883a4
parent974e5914522099ba4d463e24941289b785fe2096
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.
src/qemu/qemu_process.c