qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/6] virtio-console: Add a virtio-console bus,	support for multiple ports
Date: Tue, 29 Sep 2009 20:04:36 +0200	[thread overview]
Message-ID: <4AC24C34.2080609@redhat.com> (raw)
In-Reply-To: <1254225888-17093-4-git-send-email-amit.shah@redhat.com>


> +typedef struct VirtIOConsole
> +{

You are reusing this struct name a few times.
Better don't do that, it is confusing.

> +static VirtIOConsole *virtio_console;

Why do you need this?

> +static void flush_queue(VirtConPort *port)
> +{
> +    VirtConPortBuffer *buf, *buf2;
> +    uint8_t *outbuf;
> +    size_t outlen, outsize;
> +
> +    /*
> +     * If the app isn't interested in buffering packets till it's
> +     * opened, just drop the data guest sends us till a connection is
> +     * established.
> +     */
> +    if (!port->host_connected&&  !port->flush_buffers)
> +        return;

Hmm.  Who needs that buffering?  Only user seems to be the port driver 
(patch 4/6).  So move the buffering (and the host_connected state 
tracking) from the core to that driver?

> +/* Readiness of the guest to accept data on a port */
> +static int vcon_can_read(void *opaque)

int vcon_can_read(VirtConPort *port)

> +static void vcon_read(void *opaque, const uint8_t *buf, int size)
> +static void vcon_event(void *opaque, int event)

Likewise.

> +static VirtConBus *virtcon_bus;

Why do you need this?

> +static int virtcon_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
> +{

> +    if (port->chr) {
> +        qemu_chr_add_handlers(port->chr, vcon_can_read, vcon_read, vcon_event,
> +                              port);

Should be handled by the VirtConPort drivers.

> +    if (MAX_VIRTIO_CONSOLE_PORTS % 32) {
> +        /* We require MAX_VIRTIO_CONSOLE_PORTS be a multiple of 32:
> +         * We anyway use up that much space for the bitmap and it
> +         * simplifies some calculations
> +         */
> +        return NULL;
> +    }

Huh?  Runtime check for a compile-time constant?

> +    /* Spawn a new virtio-console bus on which the ports will ride as devices */
> +    virtcon_bus_new(dev);

s->bus = virtcon_bus_new(dev);
port0 = qdev_create(s->bus, "virtconsole");  /* console @ port0 for 
backward compat */
qdev_prop_set_*(port0, ...);
qdev_init(port0);

Or does that happen somewhere else?

> +typedef struct VirtConBus VirtConBus;
> +typedef struct VirtConPort VirtConPort;
> +typedef struct VirtConPortInfo VirtConPortInfo;
> +
> +typedef struct VirtConDevice {
> +    DeviceState qdev;
> +    VirtConPortInfo *info;
> +} VirtConDevice;

Leftover from old patch version?

> +/*
> + * This is the state that's shared between all the ports.  Some of the
> + * state is configurable via command-line options. Some of it can be
> + * set by individual devices in their initfn routines. Some of the
> + * state is set by the generic qdev device init routine.
> + */
> +struct VirtConPort {
> +    DeviceState dev;
> +    VirtConPortInfo *info;
> +
> +    /* State for the chardevice associated with this port */
> +    CharDriverState *chr;

That should go to the port driver if needed.

> +typedef int (*virtcon_port_qdev_initfn)(VirtConDevice *dev);
> +
> +struct VirtConPortInfo {
> +    DeviceInfo qdev;
> +    virtcon_port_qdev_initfn init;
> +
> +    /* Callbacks for guest events */
> +    void (*guest_open)(VirtConPort *port);
> +    void (*guest_close)(VirtConPort *port);
> +
> +    size_t (*have_data)(VirtConPort *port, const uint8_t *buf, size_t len);

Maybe it is a good idea to pass a VirtConPortBuffer here instead of 
buf+len, especially when it becomes the port drivers job to do any 
buffering if needed.

cheers,
   Gerd

  parent reply	other threads:[~2009-09-29 18:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29 12:04 [Qemu-devel] virtio-console-bus, multiport, virtio-console-port Amit Shah
2009-09-29 12:04 ` [Qemu-devel] [PATCH 1/6] char: Emit 'OPENED' events on char device open Amit Shah
2009-09-29 12:04   ` [Qemu-devel] [PATCH 2/6] qdev: add string property Amit Shah
2009-09-29 12:04     ` [Qemu-devel] [PATCH 3/6] virtio-console: Add a virtio-console bus, support for multiple ports Amit Shah
2009-09-29 12:04       ` [Qemu-devel] [PATCH 4/6] virtio-console-port: Add a new device on the virtio-console-bus for generic host-guest communication Amit Shah
2009-09-29 12:04         ` [Qemu-devel] [PATCH 5/6] vnc: add a is_vnc_active() helper Amit Shah
2009-09-29 12:04           ` [Qemu-devel] [PATCH 6/6] vnc: Add a virtio-console-bus device to send / receive guest clipboard Amit Shah
2009-09-29 18:13             ` Gerd Hoffmann
2009-09-30  4:50               ` Amit Shah
2009-09-29 18:08         ` [Qemu-devel] [PATCH 4/6] virtio-console-port: Add a new device on the virtio-console-bus for generic host-guest communication Gerd Hoffmann
2009-09-30  8:09           ` Nathan Baum
2009-09-29 18:04       ` Gerd Hoffmann [this message]
2009-09-30  4:47         ` [Qemu-devel] [PATCH 3/6] virtio-console: Add a virtio-console bus, support for multiple ports Amit Shah
2009-09-30  8:59           ` Gerd Hoffmann
2009-09-30 15:55             ` Amit Shah
2009-09-30 18:39               ` Gerd Hoffmann
2009-10-01  4:54                 ` Amit Shah
2009-10-01  8:38                   ` Gerd Hoffmann
2009-10-01  8:56                     ` Amit Shah
2009-10-01 10:48                       ` Amit Shah
2009-10-01 12:15                         ` Gerd Hoffmann
2009-10-07  9:25                           ` Amit Shah
2009-10-07  9:51                             ` Gerd Hoffmann
2009-10-07 10:06                               ` Amit Shah
2009-10-07 11:33                                 ` Gerd Hoffmann
2009-10-07 11:42                                   ` Amit Shah
2009-10-07 13:06                                     ` Gerd Hoffmann
2009-10-07 13:53                                       ` Amit Shah
2009-10-07 14:03                                         ` Gerd Hoffmann
2009-10-07 14:00                                       ` Anthony Liguori
2009-09-30 21:13   ` [Qemu-devel] [PATCH 1/6] char: Emit 'OPENED' events on char device open Anthony Liguori
2009-10-01  4:56     ` Amit Shah
2009-10-01  6:02       ` Amit Shah
2009-10-01 12:54       ` Anthony Liguori
2009-10-01 13:43         ` Gerd Hoffmann
2009-10-01 13:48           ` Anthony Liguori
2009-10-01 15:18             ` Gerd Hoffmann
2009-09-29 14:53 ` [Qemu-devel] virtio-console-bus, multiport, virtio-console-port Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AC24C34.2080609@redhat.com \
    --to=kraxel@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).