From patchwork Mon Nov 16 17:58:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Molton X-Patchwork-Id: 38534 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 2A117B7093 for ; Tue, 17 Nov 2009 05:20:51 +1100 (EST) Received: from localhost ([127.0.0.1]:43235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NA6C0-0008SO-7J for incoming@patchwork.ozlabs.org; Mon, 16 Nov 2009 13:20:48 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NA5qq-0006ir-Sd for qemu-devel@nongnu.org; Mon, 16 Nov 2009 12:58:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NA5qp-0006gc-No for qemu-devel@nongnu.org; Mon, 16 Nov 2009 12:58:56 -0500 Received: from [199.232.76.173] (port=40173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NA5qp-0006gK-Fx for qemu-devel@nongnu.org; Mon, 16 Nov 2009 12:58:55 -0500 Received: from bhuna.collabora.co.uk ([93.93.128.226]:40439) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NA5qo-0003br-QN for qemu-devel@nongnu.org; Mon, 16 Nov 2009 12:58:55 -0500 Received: from [192.168.1.64] (94-192-117-31.zone6.bethere.co.uk [94.192.117.31]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 1968F60019C; Mon, 16 Nov 2009 17:58:53 +0000 (GMT) Message-ID: <4B0192BE.4010105@collabora.co.uk> Date: Mon, 16 Nov 2009 17:58:22 +0000 From: Ian Molton User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: Gerd Hoffmann Subject: Re: [Qemu-devel] virtio-rng References: <4AFB2D4D.8050208@collabora.co.uk> <4B011F38.9070500@redhat.com> <4B014584.6000001@collabora.co.uk> <4B014F2D.3040205@redhat.com> In-Reply-To: <4B014F2D.3040205@redhat.com> X-Enigmail-Version: 0.96.0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: qemu-devel@nongnu.org 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 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gerd Hoffmann wrote: > Maybe ... > > -chardev socket,id=egd,host=egd.domain.tld,port=whatever > -device virtio-rng,chardev=egd I've had a go at modifying virtio-console.c to use these semantics, attached below. I'd appreciate it if you could let me know if this is 'the right way'. >> This doesnt, however, get around my problem that the -device option >> doesnt know how to parse OPT_SIZE types, though. (I'd like to be able to >> specify 'rate' in B/s or KB/s (or even kbits/sec, more appropriately)) > > Yes, there is no qdev property type (yet) which can parse those > postfixes. Which is no reason to not add one though ;) I'll look into it ;-) Heres my patch to virtio-console. The device is now specified like this: - -chardev file,path=/path/to/testfile,id=test - -device virtio-console-pci,chardev=test (for example) TTFN! - -Ian -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJLAZK2AAoJEFIjE1w7L6YHS0UP/0v/0a42Mon+SsUfowv7EpKw 0clLC/JCTcNFzSD1PqFdYV5E2kqCeMHHRS2DsCjjGFxgC5uOD7tuBLp66dk2vxvh 0QnIXkVD9FRBfRS5E2VtjterYmp2Fu+EBE3ugtAiKZhtQWVtmiQfRVqrqClpz8hd 4l/RXxTNkjJE5yRm9J7tBZ9lZqJ5tKTxqQtQV2+pPghOX7zAu4tsv3kLk9LY6SZr dfUfv1iXiNwiZh3Z7pKEiezzJKtoPS5y30wIszPziv2Ef/V153hxED35nT6y1+1i 16wknBJgFUG7Hp0GrprUp6N5pRTX2f7X07IXhPdMyX79J9RtS8Vg7+5aX6nsK5m0 8B0WvXZqn6i+DHGrcXNPw0IpkP/MDCTVSn15O9TsiyKLnkKfjHlQHzhDkVb9yMub bkd4uE8e9i+vqIY57kqsvcfGytcw4g3bHzT2SasKKyBjGVcwahQT4zDI9PjX7CUg vxqktTy3y4de/ijrzuIy5e/oCK6b9AAKI0dJJJfH6NsP1ljMldEeJlkLKRheWBy9 2AqdkmQhD3eD5fo5idmp9oxx0okfg/p3v5IdLTUadgIYSL70J61fb0TL6hBNo8TS uuCoZdgeKXD470tUXWvrWPxIACvG8ZAMYhz3CGXrFGb8WJjt1Rb0DXvHbr2Z8Wdn 2PwPSOliAY0iPfzo79Ke =TM+C -----END PGP SIGNATURE----- From 40a7a43484176194490a7980741a6d4764c10fb1 Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Mon, 16 Nov 2009 17:49:18 +0000 Subject: [PATCH] virtio-console: Remove ugly device reg. hack This patch removes the unsightly hack in qdev_init_chardev() that was used in order to pass the host device to virtio-console. It does not remove the limit of only one console which is imposed by the use of the virtio-pci proxy in virtio-pci.c, however if this were fixed, it would be possible to register numerous consoles without further modification of the virtio-console qdev. Signed-off-by: Ian Molton --- hw/pc.c | 9 --------- hw/ppc440_bamboo.c | 7 ------- hw/qdev.c | 9 ++------- hw/virtio-console.c | 8 ++++---- sysemu.h | 6 ------ vl.c | 37 ------------------------------------- 6 files changed, 6 insertions(+), 70 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index fb73a54..1d0c870 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1368,15 +1368,6 @@ static void pc_init1(ram_addr_t ram_size, extboot_init(info->bdrv, 1); } - /* Add virtio console devices */ - if (pci_enabled) { - for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { - if (virtcon_hds[i]) { - pci_create_simple(pci_bus, -1, "virtio-console-pci"); - } - } - } - #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT if (kvm_enabled()) { add_assigned_devices(pci_bus, assigned_devices, assigned_devices_index); diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index 25417e3..c94c961 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -109,13 +109,6 @@ static void bamboo_init(ram_addr_t ram_size, env = ppc440ep_init(&ram_size, &pcibus, pci_irq_nrs, 1, cpu_model); if (pcibus) { - /* Add virtio console devices */ - for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { - if (virtcon_hds[i]) { - pci_create_simple(pcibus, -1, "virtio-console-pci"); - } - } - /* Register network interfaces. */ for (i = 0; i < nb_nics; i++) { /* There are no PCI NICs on the Bamboo board, but there are diff --git a/hw/qdev.c b/hw/qdev.c index 373ddfc..237da57 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -321,13 +321,8 @@ void qdev_machine_creation_done(void) CharDriverState *qdev_init_chardev(DeviceState *dev) { static int next_serial; - static int next_virtconsole; - /* FIXME: This is a nasty hack that needs to go away. */ - if (strncmp(dev->info->name, "virtio", 6) == 0) { - return virtcon_hds[next_virtconsole++]; - } else { - return serial_hds[next_serial++]; - } + + return serial_hds[next_serial++]; } BusState *qdev_get_parent_bus(DeviceState *dev) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index bc3681f..8fe8a5d 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -21,7 +21,7 @@ typedef struct VirtIOConsole { VirtIODevice vdev; VirtQueue *ivq, *ovq; - CharDriverState *chr; + CharDriverState chr; } VirtIOConsole; static VirtIOConsole *to_virtio_console(VirtIODevice *vdev) @@ -39,7 +39,7 @@ static void virtio_console_handle_output(VirtIODevice *vdev, VirtQueue *vq) int d; for (d = 0; d < elem.out_num; d++) { - len += qemu_chr_write(s->chr, (uint8_t *)elem.out_sg[d].iov_base, + len += qemu_chr_write(&s->chr, (uint8_t *)elem.out_sg[d].iov_base, elem.out_sg[d].iov_len); } virtqueue_push(vq, &elem, len); @@ -137,8 +137,8 @@ VirtIODevice *virtio_console_init(DeviceState *dev, CharDriverState *chr) s->ivq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_input); s->ovq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_output); - s->chr = qdev_init_chardev(dev); - qemu_chr_add_handlers(s->chr, vcon_can_read, vcon_read, vcon_event, s); + memcpy(&s->chr, chr, sizeof(*chr)); + qemu_chr_add_handlers(&s->chr, vcon_can_read, vcon_read, vcon_event, s); register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s); diff --git a/sysemu.h b/sysemu.h index 8455743..1a494e5 100644 --- a/sysemu.h +++ b/sysemu.h @@ -229,12 +229,6 @@ extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; -/* virtio consoles */ - -#define MAX_VIRTIO_CONSOLES 1 - -extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; - #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) #ifdef HAS_AUDIO diff --git a/vl.c b/vl.c index 60eccee..a26e7ac 100644 --- a/vl.c +++ b/vl.c @@ -212,7 +212,6 @@ static int no_frame = 0; int no_quit = 0; CharDriverState *serial_hds[MAX_SERIAL_PORTS]; CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; -CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; #ifdef TARGET_I386 int win2k_install_hack = 0; int rtc_td_hack = 0; @@ -4673,8 +4672,6 @@ int main(int argc, char **argv, char **envp) int serial_device_index; const char *parallel_devices[MAX_PARALLEL_PORTS]; int parallel_device_index; - const char *virtio_consoles[MAX_VIRTIO_CONSOLES]; - int virtio_console_index; const char *loadvm = NULL; QEMUMachine *machine; const char *cpu_model; @@ -4750,10 +4747,6 @@ int main(int argc, char **argv, char **envp) parallel_devices[i] = NULL; parallel_device_index = 0; - for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) - virtio_consoles[i] = NULL; - virtio_console_index = 0; - monitor_devices[0] = "vc:80Cx24C"; for (i = 1; i < MAX_MONITOR_DEVICES; i++) { monitor_devices[i] = NULL; @@ -5216,14 +5209,6 @@ int main(int argc, char **argv, char **envp) exit(1); } 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++; - break; case QEMU_OPTION_parallel: if (parallel_device_index >= MAX_PARALLEL_PORTS) { fprintf(stderr, "qemu: too many parallel ports\n"); @@ -5776,20 +5761,6 @@ int main(int argc, char **argv, char **envp) } } - 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); - } - } - } - module_call_init(MODULE_INIT_DEVICE); if (watchdog) { @@ -5918,14 +5889,6 @@ int main(int argc, char **argv, char **envp) } } - 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.5