More precisely this patch reuse existing mon->lastError to mark monitor as closed. Why we need this state? For sure monitor have closed state and attempts to send commands in this state must fail otherwise we hang on waiting command response, AFAIK monitor is never used in this state because of locks structure: first check if domain is active (that is monitor is not closed), then lock monitor, then unlock domain - any code that closes monitor first lock domain so at this moment we have a lock on monitor and it is not closed. So this patch just makes monitor more incapsulated. Just to be sure. --- src/qemu/qemu_monitor.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index f402300..950b371 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -957,23 +957,24 @@ qemuMonitorClose(qemuMonitorPtr mon) VIR_FORCE_CLOSE(mon->fd); } + if (mon->lastError.code == VIR_ERR_OK) { + virErrorPtr err = virSaveLastError(); + + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("Qemu monitor was closed")); + virCopyLastError(&mon->lastError); + if (err) { + virSetError(err); + virFreeError(err); + } else { + virResetLastError(); + } + } + /* In case another thread is waiting for its monitor command to be * processed, we need to wake it up with appropriate error set. */ if (mon->msg) { - if (mon->lastError.code == VIR_ERR_OK) { - virErrorPtr err = virSaveLastError(); - - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("Qemu monitor was closed")); - virCopyLastError(&mon->lastError); - if (err) { - virSetError(err); - virFreeError(err); - } else { - virResetLastError(); - } - } mon->msg->finished = 1; virCondSignal(&mon->notify); } -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list