From: Anthony Liguori <anthony@codemonkey.ws>
To: Amit Shah <amit.shah@redhat.com>
Cc: qemu list <qemu-devel@nongnu.org>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [RESEND][REBASE] [PATCH] virtio-serial: kill VirtIOSerialDevice
Date: Thu, 24 Feb 2011 12:11:01 -0600 [thread overview]
Message-ID: <4D669F35.7060600@codemonkey.ws> (raw)
In-Reply-To: <d6985904cdb586933076578206ed35743ac2d75c.1298526226.git.amit.shah@redhat.com>
On 02/23/2011 11:44 PM, Amit Shah wrote:
> From: Gerd Hoffmann<kraxel@redhat.com>
>
> VirtIOSerialDevice is like VirtIOSerialPort with just the first two
> fields, which makes it pretty pointless. Using VirtIOSerialPort
> directly works equally well and is less confusing.
>
> [Amit: - rebase
> - rename 'dev' to 'port' in function params in virtio-serial.h ]
>
> Signed-off-by: Gerd Hoffmann<kraxel@redhat.com>
> Signed-off-by: Amit Shah<amit.shah@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> hw/virtio-console.c | 17 ++++++-----------
> hw/virtio-serial-bus.c | 15 ++++++---------
> hw/virtio-serial.h | 9 ++-------
> 3 files changed, 14 insertions(+), 27 deletions(-)
>
> diff --git a/hw/virtio-console.c b/hw/virtio-console.c
> index 62624ec..c235b27 100644
> --- a/hw/virtio-console.c
> +++ b/hw/virtio-console.c
> @@ -57,10 +57,8 @@ static void chr_event(void *opaque, int event)
> }
> }
>
> -static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)
> +static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)
> {
> - vcon->port.info = dev->info;
> -
> if (vcon->chr) {
> qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
> vcon);
> @@ -70,18 +68,16 @@ static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)
> }
>
> /* Virtio Console Ports */
> -static int virtconsole_initfn(VirtIOSerialDevice *dev)
> +static int virtconsole_initfn(VirtIOSerialPort *port)
> {
> - VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev,&dev->qdev);
> VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
>
> port->is_console = true;
> - return generic_port_init(vcon, dev);
> + return generic_port_init(vcon, port);
> }
>
> -static int virtconsole_exitfn(VirtIOSerialDevice *dev)
> +static int virtconsole_exitfn(VirtIOSerialPort *port)
> {
> - VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev,&dev->qdev);
> VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
>
> if (vcon->chr) {
> @@ -113,12 +109,11 @@ static void virtconsole_register(void)
> device_init(virtconsole_register)
>
> /* Generic Virtio Serial Ports */
> -static int virtserialport_initfn(VirtIOSerialDevice *dev)
> +static int virtserialport_initfn(VirtIOSerialPort *port)
> {
> - VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev,&dev->qdev);
> VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
>
> - return generic_port_init(vcon, dev);
> + return generic_port_init(vcon, port);
> }
>
> static VirtIOSerialPortInfo virtserialport_info = {
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index e05ab5e..8446bc2 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -658,8 +658,7 @@ static VirtIOSerialBus *virtser_bus_new(DeviceState *dev)
>
> static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
> {
> - VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
> - VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev,&dev->qdev);
> + VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
>
> monitor_printf(mon, "%*s dev-prop-int: id: %u\n",
> indent, "", port->id);
> @@ -721,9 +720,8 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
>
> static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
> {
> - VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
> + VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
> VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev, base);
> - VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev,&dev->qdev);
> VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qdev->parent_bus);
> int ret;
> bool plugging_port0;
> @@ -761,8 +759,8 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
> return -1;
> }
>
> - dev->info = info;
> - ret = info->init(dev);
> + port->info = info;
> + ret = info->init(port);
> if (ret) {
> return ret;
> }
> @@ -791,8 +789,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
>
> static int virtser_port_qdev_exit(DeviceState *qdev)
> {
> - VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
> - VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev,&dev->qdev);
> + VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
> VirtIOSerial *vser = port->vser;
>
> remove_port(port->vser, port->id);
> @@ -800,7 +797,7 @@ static int virtser_port_qdev_exit(DeviceState *qdev)
> QTAILQ_REMOVE(&vser->ports, port, next);
>
> if (port->info->exit)
> - port->info->exit(dev);
> + port->info->exit(port);
>
> return 0;
> }
> diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
> index a308196..8cb9fbe 100644
> --- a/hw/virtio-serial.h
> +++ b/hw/virtio-serial.h
> @@ -62,11 +62,6 @@ typedef struct VirtIOSerialBus VirtIOSerialBus;
> typedef struct VirtIOSerialPort VirtIOSerialPort;
> typedef struct VirtIOSerialPortInfo VirtIOSerialPortInfo;
>
> -typedef struct VirtIOSerialDevice {
> - DeviceState qdev;
> - VirtIOSerialPortInfo *info;
> -} VirtIOSerialDevice;
> -
> /*
> * 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
> @@ -136,12 +131,12 @@ struct VirtIOSerialPortInfo {
> * The per-port (or per-app) init function that's called when a
> * new device is found on the bus.
> */
> - int (*init)(VirtIOSerialDevice *dev);
> + int (*init)(VirtIOSerialPort *port);
> /*
> * Per-port exit function that's called when a port gets
> * hot-unplugged or removed.
> */
> - int (*exit)(VirtIOSerialDevice *dev);
> + int (*exit)(VirtIOSerialPort *port);
>
> /* Callbacks for guest events */
> /* Guest opened device. */
>
prev parent reply other threads:[~2011-02-24 18:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 5:44 [Qemu-devel] [RESEND][REBASE] [PATCH] virtio-serial: kill VirtIOSerialDevice Amit Shah
2011-02-24 18:11 ` Anthony Liguori [this message]
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=4D669F35.7060600@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=amit.shah@redhat.com \
--cc=kraxel@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).