From patchwork Mon Dec 7 12:42:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 40487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CBCE5B6F0C for ; Tue, 8 Dec 2009 00:12:58 +1100 (EST) Received: from localhost ([127.0.0.1]:38541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHdOZ-0008R1-V6 for incoming@patchwork.ozlabs.org; Mon, 07 Dec 2009 08:12:56 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHcwx-0005Rb-FT for qemu-devel@nongnu.org; Mon, 07 Dec 2009 07:44:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHcws-0005Od-GE for qemu-devel@nongnu.org; Mon, 07 Dec 2009 07:44:22 -0500 Received: from [199.232.76.173] (port=58690 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHcws-0005OJ-8Z for qemu-devel@nongnu.org; Mon, 07 Dec 2009 07:44:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33372) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHcwq-0000hY-E9 for qemu-devel@nongnu.org; Mon, 07 Dec 2009 07:44:16 -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 nB7CiFY0020251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Dec 2009 07:44:15 -0500 Received: from zweiblum.home.kraxel.org (vpn2-8-247.ams2.redhat.com [10.36.8.247]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB7Ci46P004575; Mon, 7 Dec 2009 07:44:13 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id D0D487011A; Mon, 7 Dec 2009 13:43:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 7 Dec 2009 13:42:52 +0100 Message-Id: <1260189773-20728-21-git-send-email-kraxel@redhat.com> In-Reply-To: <1260189773-20728-1-git-send-email-kraxel@redhat.com> References: <1260189773-20728-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann , agraf@suse.de, lcapitulino@redhat.com Subject: [Qemu-devel] [FOR 0.12 PATCH v3 20/21] default devices: virtio consoles. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds a variable default_virtcon which says whenever a default virtio console should be added. It is disabled by default, followup patch will enable it for s390. It is cleared when qemu finds '-virtiocon', '-device virtio-console-s390' or '-device virtio-console-pci' on the command line. Signed-off-by: Gerd Hoffmann --- vl.c | 64 ++++++++++++++++++++++++++++++++++------------------------------ 1 files changed, 34 insertions(+), 30 deletions(-) diff --git a/vl.c b/vl.c index 9949886..298ac73 100644 --- a/vl.c +++ b/vl.c @@ -270,6 +270,7 @@ static void *boot_set_opaque; static int default_serial = 1; static int default_parallel = 1; +static int default_virtcon = 1; static int default_monitor = 1; static int default_vga = 1; static int default_drive = 1; @@ -280,6 +281,8 @@ static struct { } default_list[] = { { .driver = "isa-serial", .flag = &default_serial }, { .driver = "isa-parallel", .flag = &default_parallel }, + { .driver = "virtio-console-pci", .flag = &default_virtcon }, + { .driver = "virtio-console-s390", .flag = &default_virtcon }, { .driver = "VGA", .flag = &default_vga }, { .driver = "Cirrus VGA", .flag = &default_vga }, { .driver = "QEMUware SVGA", .flag = &default_vga }, @@ -4701,10 +4704,11 @@ static void monitor_parse(const char *optarg, const char *mode) struct device_config { enum { - DEV_USB, /* -usbdevice */ - DEV_BT, /* -bt */ - DEV_SERIAL, /* -serial */ - DEV_PARALLEL, /* -parallel */ + DEV_USB, /* -usbdevice */ + DEV_BT, /* -bt */ + DEV_SERIAL, /* -serial */ + DEV_PARALLEL, /* -parallel */ + DEV_VIRTCON, /* -virtioconsole */ } type; const char *cmdline; QTAILQ_ENTRY(device_config) next; @@ -4780,6 +4784,28 @@ static int parallel_parse(const char *devname) return 0; } +static int virtcon_parse(const char *devname) +{ + static int index = 0; + char label[32]; + + if (strcmp(devname, "none") == 0) + return 0; + if (index == MAX_VIRTIO_CONSOLES) { + fprintf(stderr, "qemu: too many virtio consoles\n"); + exit(1); + } + snprintf(label, sizeof(label), "virtcon%d", index); + virtcon_hds[index] = qemu_chr_open(label, devname, NULL); + if (!virtcon_hds[index]) { + fprintf(stderr, "qemu: could not open virtio console '%s': %s\n", + devname, strerror(errno)); + return -1; + } + index++; + return 0; +} + int main(int argc, char **argv, char **envp) { const char *gdbstub_dev = NULL; @@ -4795,8 +4821,6 @@ int main(int argc, char **argv, char **envp) QemuOpts *hda_opts = NULL, *opts; int optind; const char *r, *optarg; - const char *virtio_consoles[MAX_VIRTIO_CONSOLES]; - int virtio_console_index; const char *loadvm = NULL; QEMUMachine *machine; const char *cpu_model; @@ -4862,10 +4886,6 @@ int main(int argc, char **argv, char **envp) cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; - for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) - virtio_consoles[i] = NULL; - virtio_console_index = 0; - for (i = 0; i < MAX_NODES; i++) { node_mem[i] = 0; node_cpumask[i] = 0; @@ -5324,12 +5344,8 @@ int main(int argc, char **argv, char **envp) } break; case QEMU_OPTION_virtiocon: - if (virtio_console_index >= MAX_VIRTIO_CONSOLES) { - fprintf(stderr, "qemu: too many virtio consoles\n"); - exit(1); - } - virtio_consoles[virtio_console_index] = optarg; - virtio_console_index++; + add_device_config(DEV_VIRTCON, optarg); + default_virtcon = 0; break; case QEMU_OPTION_parallel: add_device_config(DEV_PARALLEL, optarg); @@ -5832,20 +5848,8 @@ int main(int argc, char **argv, char **envp) exit(1); if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) exit(1); - - for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { - const char *devname = virtio_consoles[i]; - if (devname && strcmp(devname, "none")) { - char label[32]; - snprintf(label, sizeof(label), "virtcon%d", i); - virtcon_hds[i] = qemu_chr_open(label, devname, NULL); - if (!virtcon_hds[i]) { - fprintf(stderr, "qemu: could not open virtio console '%s': %s\n", - devname, strerror(errno)); - exit(1); - } - } - } + if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0) + exit(1); module_call_init(MODULE_INIT_DEVICE);