From patchwork Thu Apr 24 17:35:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 342599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C3432140159 for ; Fri, 25 Apr 2014 12:33:46 +1000 (EST) Received: from localhost ([::1]:54287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdVxQ-0002xO-BY for incoming@patchwork.ozlabs.org; Thu, 24 Apr 2014 22:33:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdUcU-00086d-EK for qemu-devel@nongnu.org; Thu, 24 Apr 2014 21:08:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdNbi-0003C0-Cd for qemu-devel@nongnu.org; Thu, 24 Apr 2014 13:38:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdNbi-0003BS-4s for qemu-devel@nongnu.org; Thu, 24 Apr 2014 13:38:46 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3OHcjhv029040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Apr 2014 13:38:45 -0400 Received: from colepc.home.com (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3OHcglO000505; Thu, 24 Apr 2014 13:38:44 -0400 From: Cole Robinson To: qemu-devel@nongnu.org Date: Thu, 24 Apr 2014 13:35:54 -0400 Message-Id: <70aa1ca8ff22603126045ebde42f319379d9d4f4.1398360849.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Cole Robinson Subject: [Qemu-devel] [PATCH 3/5] gtk: Fix -serial vc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Try kicking off a rhel5 text install over serial, the text menu navigation is all messed up, and some of the kernel boot messages are randomly corrupted. Drop use of a pty and just use vte infrastructure for reading and writing. This fixes the above corruption, and is simpler to boot. (I don't know what was wrong with the original code though. FWIW this is what virt-manager has done for years). Signed-off-by: Cole Robinson --- ui/gtk.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 816ef15..117b0eb 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -115,7 +115,6 @@ typedef struct VirtualConsole GtkWidget *scrolled_window; CharDriverState *chr; #endif - int fd; } VirtualConsole; typedef struct GtkDisplayState @@ -1166,9 +1165,12 @@ static gboolean gd_focus_out_event(GtkWidget *widget, static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { +#if defined(CONFIG_VTE) VirtualConsole *vc = chr->opaque; - return vc ? write(vc->fd, buf, len) : len; + vte_terminal_feed(VTE_TERMINAL(vc->terminal), (const char *)buf, len); +#endif + return len; } static int nb_vcs; @@ -1194,18 +1196,11 @@ void early_gtk_display_init(void) } #if defined(CONFIG_VTE) -static gboolean gd_vc_in(GIOChannel *chan, GIOCondition cond, void *opaque) +static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size, + gpointer user_data) { - VirtualConsole *vc = opaque; - uint8_t buffer[1024]; - ssize_t len; - - len = read(vc->fd, buffer, sizeof(buffer)); - if (len <= 0) { - return FALSE; - } - - qemu_chr_be_write(vc->chr, buffer, len); + VirtualConsole *vc = user_data; + qemu_chr_be_write(vc->chr, (uint8_t *)text, (unsigned int)size); return TRUE; } @@ -1218,13 +1213,8 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL const char *label; char buffer[32]; char path[32]; -#if VTE_CHECK_VERSION(0, 26, 0) - VtePty *pty; -#endif - GIOChannel *chan; GtkWidget *scrolled_window; GtkAdjustment *vadjustment; - int master_fd, slave_fd; int width, height; snprintf(buffer, sizeof(buffer), "vc%d", index); @@ -1244,16 +1234,7 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL gtk_accel_map_add_entry(path, GDK_KEY_2 + index, HOTKEY_MODIFIERS); vc->terminal = vte_terminal_new(); - - master_fd = qemu_openpty_raw(&slave_fd, NULL); - g_assert(master_fd != -1); - -#if VTE_CHECK_VERSION(0, 26, 0) - pty = vte_pty_new_foreign(master_fd, NULL); - vte_terminal_set_pty_object(VTE_TERMINAL(vc->terminal), pty); -#else - vte_terminal_set_pty(VTE_TERMINAL(vc->terminal), master_fd); -#endif + g_signal_connect(vc->terminal, "commit", G_CALLBACK(gd_vc_in), vc); vte_terminal_set_scrollback_lines(VTE_TERMINAL(vc->terminal), -1); @@ -1277,7 +1258,6 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL gtk_widget_set_size_request(vc->terminal, width, height); #endif - vc->fd = slave_fd; vc->chr->opaque = vc; vc->scrolled_window = scrolled_window; @@ -1295,9 +1275,6 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL vc->chr->init(vc->chr); } - chan = g_io_channel_unix_new(vc->fd); - g_io_add_watch(chan, G_IO_IN, gd_vc_in, vc); - #endif /* CONFIG_VTE */ return group; }