-----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 <ian.mol...@collabora.co.uk> 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 <ian.mol...@collabora.co.uk> --- 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
0001-virtio-console-Remove-ugly-device-reg.-hack.patch.sig
Description: PGP signature