qemu: Fix segmentation fault on reconnect

On start up of libvirtd the worker pool of the QEMU driver must be
initialized before trying to reconnect to all the running QEMU
instances. Otherwise segmentation faults can occur if there are QEMU
monitor events emitted.

 #0  __GI___pthread_mutex_lock
 #1  0x000003fffdba9e62 in virMutexLock
 #2  0x000003fffdbab2dc in virThreadPoolSendJob
 #3  0x000003ffd8343b70 in qemuProcessHandleSerialChanged
 #4  0x000003ffd836a776 in qemuMonitorEmitSerialChange
 #5  0x000003ffd8378e52 in qemuMonitorJSONHandleSerialChange
 #6  0x000003ffd8378930 in qemuMonitorJSONIOProcessEvent
 #7  0x000003ffd837edee in qemuMonitorJSONIOProcessLine
 #8  0x000003ffd837ef86 in qemuMonitorJSONIOProcess
 #9  0x000003ffd836757a in qemuMonitorIOProcess
 #10 0x000003ffd836863e in qemuMonitorIO
 #11 0x000003fffdb4033a in virEventPollDispatchHandles
 #12 0x000003fffdb4055e in virEventPollRunOnce
 #13 0x000003fffdb3e782 in virEventRunDefaultImpl
 #14 0x000003fffdc89400 in virNetDaemonRun
 #15 0x000000010002a816 in main

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Marc Hartmayer 2018-06-08 12:49:07 +02:00 committed by Erik Skultety
parent 6142758a57
commit fef4d132c4

View File

@ -932,12 +932,15 @@ qemuStateInitialize(bool privileged,
qemuDomainManagedSaveLoad,
qemu_driver);
qemuProcessReconnectAll(qemu_driver);
/* must be initialized before trying to reconnect to all the
* running domains since there might occur some QEMU monitor
* events that will be dispatched to the worker pool */
qemu_driver->workerPool = virThreadPoolNew(0, 1, 0, qemuProcessEventHandler, qemu_driver);
if (!qemu_driver->workerPool)
goto error;
qemuProcessReconnectAll(qemu_driver);
virNWFilterRegisterCallbackDriver(&qemuCallbackDriver);
return 0;