* the next monitor msg */
virError lastError;
+ /* Set to true when EOF is detected on the monitor */
+ bool goteof;
+
int nextSerial;
bool waitGreeting;
{
qemuMonitor *mon = opaque;
bool error = false;
- bool eof = false;
bool hangup = false;
virObjectRef(mon);
if (mon->lastError.code != VIR_ERR_OK) {
if (cond & (G_IO_HUP | G_IO_ERR))
- eof = true;
+ mon->goteof = true;
error = true;
} else {
if (cond & G_IO_OUT) {
if (errno == ECONNRESET)
hangup = true;
} else if (got == 0) {
- eof = true;
+ mon->goteof = true;
} else {
/* Ignore hangup/error cond if we read some data, to
* give time for that data to be consumed */
if (cond & G_IO_HUP) {
hangup = true;
- if (!error) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("End of file from qemu monitor"));
- eof = true;
- }
+ if (!error)
+ mon->goteof = true;
}
- if (!error && !eof &&
+ if (!error && !mon->goteof &&
cond & G_IO_ERR) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid file descriptor while waiting for monitor"));
- eof = true;
+ mon->goteof = true;
}
}
- if (error || eof) {
+ if (error || mon->goteof) {
if (hangup && mon->logFunc != NULL) {
/* Check if an error message from qemu is available and if so, use
* it to overwrite the actual message. It's done only in early
/* Already have an error, so clear any new error */
virResetLastError();
} else {
- if (virGetLastErrorCode() == VIR_ERR_OK)
+ if (virGetLastErrorCode() == VIR_ERR_OK && !mon->goteof)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Error while processing monitor IO"));
virCopyLastError(&mon->lastError);
/* We have to unlock to avoid deadlock against command thread,
* but is this safe ? I think it is, because the callback
* will try to acquire the virDomainObj *mutex next */
- if (eof) {
+ if (mon->goteof) {
qemuMonitorEofNotifyCallback eofNotify = mon->cb->eofNotify;
virDomainObj *vm = mon->vm;
virSetError(&mon->lastError);
return -1;
}
+ if (mon->goteof) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("End of file from qemu monitor"));
+ return -1;
+ }
mon->msg = msg;
qemuMonitorUpdateWatch(mon);