From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAKW9-00026W-P2 for qemu-devel@nongnu.org; Tue, 17 Nov 2009 04:38:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAKW3-00024P-Pg for qemu-devel@nongnu.org; Tue, 17 Nov 2009 04:38:33 -0500 Received: from [199.232.76.173] (port=51748 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAKW3-00024F-Kl for qemu-devel@nongnu.org; Tue, 17 Nov 2009 04:38:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15514) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NAKW3-0007BN-5U for qemu-devel@nongnu.org; Tue, 17 Nov 2009 04:38:27 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAH9cPxU019909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Nov 2009 04:38:25 -0500 From: Gerd Hoffmann Date: Tue, 17 Nov 2009 10:38:11 +0100 Message-Id: <1258450699-24445-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1258450699-24445-1-git-send-email-kraxel@redhat.com> References: <1258450699-24445-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/9] chardev: add greeting List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add a greeting string to CharDriverState which is printed after initialization. Used to have the qemu vc consoles labeled. This way we can avoid walking all the chardevs a second time after initialization just to print the greeting. Signed-off-by: Gerd Hoffmann --- qemu-char.c | 2 ++ qemu-char.h | 1 + vl.c | 36 ++++++++++++------------------------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 40bd7e8..19be58f 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -132,6 +132,8 @@ void qemu_chr_initial_reset(void) QTAILQ_FOREACH(chr, &chardevs, next) { qemu_chr_reset(chr); + if (chr->greeting) + qemu_chr_printf(chr, "%s", chr->greeting); } } diff --git a/qemu-char.h b/qemu-char.h index 05fe15d..e50a4f3 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -66,6 +66,7 @@ struct CharDriverState { QEMUBH *bh; char *label; char *filename; + char *greeting; QTAILQ_ENTRY(CharDriverState) next; }; diff --git a/vl.c b/vl.c index fff8e8d..095aff6 100644 --- a/vl.c +++ b/vl.c @@ -5657,6 +5657,10 @@ int main(int argc, char **argv, char **envp) devname, strerror(errno)); exit(1); } + if (strstart(devname, "vc", 0)) { + snprintf(label, sizeof(label), "serial%d console\r\n", i); + serial_hds[i]->greeting = qemu_strdup(label); + } } } @@ -5671,6 +5675,10 @@ int main(int argc, char **argv, char **envp) devname, strerror(errno)); exit(1); } + if (strstart(devname, "vc", 0)) { + snprintf(label, sizeof(label), "parallel%d console\r\n", i); + parallel_hds[i]->greeting = qemu_strdup(label); + } } } @@ -5685,6 +5693,10 @@ int main(int argc, char **argv, char **envp) devname, strerror(errno)); exit(1); } + if (strstart(devname, "vc", 0)) { + snprintf(label, sizeof(label), "virtio console%d\r\n", i); + virtcon_hds[i]->greeting = qemu_strdup(label); + } } } @@ -5800,30 +5812,6 @@ int main(int argc, char **argv, char **envp) } } - for(i = 0; i < MAX_SERIAL_PORTS; i++) { - const char *devname = serial_devices[i]; - if (devname && strcmp(devname, "none")) { - if (strstart(devname, "vc", 0)) - qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i); - } - } - - for(i = 0; i < MAX_PARALLEL_PORTS; i++) { - const char *devname = parallel_devices[i]; - if (devname && strcmp(devname, "none")) { - if (strstart(devname, "vc", 0)) - qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i); - } - } - - for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { - const char *devname = virtio_consoles[i]; - if (virtcon_hds[i] && devname) { - if (strstart(devname, "vc", 0)) - qemu_chr_printf(virtcon_hds[i], "virtio console%d\r\n", i); - } - } - if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) { fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n", gdbstub_dev); -- 1.6.2.5