thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qemu-char-ignore-flow-control-if-a-PTY-s-slave-is-no.patch

9ae3a8
From 6a40d58e03beaef265f6c1293301f5f8860ecbea Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Thu, 18 May 2017 09:21:22 +0200
9ae3a8
Subject: [PATCH 09/18] qemu-char: ignore flow control if a PTY's slave is not
9ae3a8
 connected
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <20170518092131.16571-10-famz@redhat.com>
9ae3a8
Patchwork-id: 75301
9ae3a8
O-Subject: [RHEL-7.4 qemu-kvm PATCH v3 09/18] qemu-char: ignore flow control if a PTY's slave is not connected
9ae3a8
Bugzilla: 1451470
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
After commit f702e62 (serial: change retry logic to avoid concurrency,
9ae3a8
2014-07-11), guest boot hangs if the backend is an unconnected PTY.
9ae3a8
9ae3a8
The reason is that PTYs do not support G_IO_HUP, and serial_xmit is
9ae3a8
never called.  To fix this, simply invoke serial_xmit immediately
9ae3a8
(via g_idle_source_new) when this happens.
9ae3a8
9ae3a8
Tested-by: Pavel Hrdina <phrdina@redhat.com>
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
(cherry picked from commit 62c339c5272ce8fbe8ca52695cee8ff40da7872e)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 qemu-char.c | 7 +++++++
9ae3a8
 1 file changed, 7 insertions(+)
9ae3a8
9ae3a8
diff --git a/qemu-char.c b/qemu-char.c
9ae3a8
index 47ac55a..08cb959 100644
9ae3a8
--- a/qemu-char.c
9ae3a8
+++ b/qemu-char.c
9ae3a8
@@ -1068,6 +1068,9 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
9ae3a8
 static GSource *pty_chr_add_watch(CharDriverState *chr, GIOCondition cond)
9ae3a8
 {
9ae3a8
     PtyCharDriver *s = chr->opaque;
9ae3a8
+    if (!s->connected) {
9ae3a8
+        return NULL;
9ae3a8
+    }
9ae3a8
     return g_io_create_watch(s->fd, cond);
9ae3a8
 }
9ae3a8
 
9ae3a8
@@ -3381,6 +3384,10 @@ int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,
9ae3a8
     }
9ae3a8
 
9ae3a8
     src = s->chr_add_watch(s, cond);
9ae3a8
+    if (!src) {
9ae3a8
+        return -EINVAL;
9ae3a8
+    }
9ae3a8
+
9ae3a8
     g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);
9ae3a8
     tag = g_source_attach(src, NULL);
9ae3a8
     g_source_unref(src);
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8