From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNzq0-00052q-Kq for qemu-devel@nongnu.org; Wed, 18 Feb 2015 03:18:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNzpx-0004YA-Eb for qemu-devel@nongnu.org; Wed, 18 Feb 2015 03:18:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNzpx-0004Xm-6v for qemu-devel@nongnu.org; Wed, 18 Feb 2015 03:18:25 -0500 Message-ID: <1424247497.6014.44.camel@nilsson.home.kraxel.org> From: Gerd Hoffmann Date: Wed, 18 Feb 2015 09:18:17 +0100 In-Reply-To: <528329A9-EA6C-4207-A03B-ED9D92E53E62@gmail.com> References: <1424166243-24589-1-git-send-email-kraxel@redhat.com> <528329A9-EA6C-4207-A03B-ED9D92E53E62@gmail.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] console/gtk: add qemu_console_get_label List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Programmingkid Cc: qemu-devel@nongnu.org, Anthony Liguori Hi, > Thanks for this code. Is this how I should display the Serial console? > void myDisplaySerialConsole() > { > QemuConsole *con; > char *name; > int index = 0; > > con = qemu_console_lookup_by_index(0); > while(con != NULL) { > name = qemu_console_get_label(con); > > /* If we found the console */ > if (strstr(name, "Serial")) { > console_select(index); > break; > } > index++; > con = qemu_console_lookup_by_index(index); This mixes up several things. When initializing the UI you'll loop over the consoles, like this: QemuConsole *con; int i; for (i = 0;; i++) { con = qemu_console_lookup_by_index(i); if (!con) { break; } /* * add a menu entry for the console here, * using qemu_console_get_label() to get * the text for the menu entry */ } When the menu entry is activated by the user use console_select() to switch. cheers, Gerd