Hi,
We unregister qemu monitor after sending QEMU_PROCESS_EVENT_MONITOR_EOF to workerPool:
static void
qemuProcessHandleMonitorEOF(qemuMonitorPtr mon,
virDomainObjPtr vm,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
qemuDomainObjPrivatePtr priv;
struct qemuProcessEvent *processEvent;
...
processEvent->eventType = QEMU_PROCESS_EVENT_MONITOR_EOF;
processEvent->vm = vm;
virObjectRef(vm);
if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {
ignore_value(virObjectUnref(vm));
VIR_FREE(processEvent);
goto cleanup;
}
/* We don't want this EOF handler to be called over and over while the
* thread is waiting for a job.
*/
qemuMonitorUnregister(mon);
...
}
Then we handle QEMU_PROCESS_EVENT_MONITOR_EOF in processMonitorEOFEvent function:
static void
processMonitorEOFEvent(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
...
if (qemuProcessBeginStopJob(driver, vm, QEMU_JOB_DESTROY, true) < 0)
return;
...
}
Here, libvirt will show that the vm state is running all the time if
qemuProcessBeginStopJob return -1
even though qemu may terminate or be killed later.
So, may be we should re-register the monitor when qemuProcessBeginStopJob failed?
Thanks,
Zongyong Wu