Below is patch that simulates race behaviour. Let's add delay on replying to virDomainOpenConsole and report error for console stream immediately. For this let's use IO helper thread for console fd stream.
With this patch you'll get next error in interactive virsh session: (note that a generated file with stubs is patched also) ######################################################### Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh # console centos2 Connected to domain centos2 Escape character is ^] error: internal error: Unexpected message type 0 virsh # error: Disconnected from qemu:///system due to I/O error diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 5090a67..740845c 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -413,7 +413,7 @@ int virChrdevOpen(virChrdevsPtr devs, /* open the character device */ switch (source->type) { case VIR_DOMAIN_CHR_TYPE_PTY: - if (virFDStreamOpenPTY(st, path, 0, 0, O_RDWR) < 0) + if (virFDStreamOpenPTY(st, path, 0, 0, O_RDONLY) < 0) goto error; break; case VIR_DOMAIN_CHR_TYPE_UNIX: diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 1bc43e2..6968f95 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -434,6 +434,9 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, char *buf = NULL; ssize_t got; + virReportError(VIR_ERR_INTERNAL_ERROR, _("immediate stream error")); + goto error; + if (sparse && *dataLen == 0) { if (virFileInData(fdin, &inData, §ionLen) < 0) goto error; @@ -1376,11 +1379,13 @@ int virFDStreamOpenPTY(virStreamPtr st, if (virFDStreamOpenFileInternal(st, path, offset, length, oflags | O_CREAT, 0, - false, false) < 0) + true, false) < 0) return -1; fdst = st->privateData; + return 0; + if (tcgetattr(fdst->fd, &rawattr) < 0) { virReportSystemError(errno, _("unable to get tty attributes: %s"), --- a/src/remote/remote_daemon_dispatch_stubs.h +++ b/src/remote/remote_daemon_dispatch_stubs.h @@ -8936,6 +8936,8 @@ if (daemonAddClientStream(client, stream, true) < 0) goto cleanup; + sleep(3); + rv = 0; cleanup: -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list