From: Amit Shah <amit.shah@redhat.com>
To: qemu-devel@nongnu.org
Cc: Amit Shah <amit.shah@redhat.com>
Subject: [Qemu-devel] [PATCH] virtio-console: Have a static instance of virtconsole
Date: Fri, 4 Sep 2009 14:44:30 +0530 [thread overview]
Message-ID: <1252055670-26958-1-git-send-email-amit.shah@redhat.com> (raw)
Currently the VirtIOConsole struct is allocated from the call
to virtio_common_init, also doing an UP_CAST implicitly.
The new multiport functionality will need a few arrays and
it's easier to move to the new VMState infrastructure by
keeping it all within one struct.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
hw/virtio-console.c | 37 +++++++++++++++++++++----------------
1 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 57f8f89..5d08321 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -19,11 +19,13 @@
typedef struct VirtIOConsole
{
- VirtIODevice vdev;
+ VirtIODevice *vdev;
VirtQueue *ivq, *ovq;
CharDriverState *chr;
} VirtIOConsole;
+VirtIOConsole virtconsole;
+
static VirtIOConsole *to_virtio_console(VirtIODevice *vdev)
{
return (VirtIOConsole *)vdev;
@@ -61,7 +63,7 @@ static int vcon_can_read(void *opaque)
VirtIOConsole *s = (VirtIOConsole *) opaque;
if (!virtio_queue_ready(s->ivq) ||
- !(s->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) ||
+ !(s->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) ||
virtio_queue_empty(s->ivq))
return 0;
@@ -97,7 +99,7 @@ static void vcon_read(void *opaque, const uint8_t *buf, int size)
}
virtqueue_push(s->ivq, &elem, size);
}
- virtio_notify(&s->vdev, s->ivq);
+ virtio_notify(s->vdev, s->ivq);
}
static void vcon_event(void *opaque, int event)
@@ -109,7 +111,7 @@ static void virtio_console_save(QEMUFile *f, void *opaque)
{
VirtIOConsole *s = opaque;
- virtio_save(&s->vdev, f);
+ virtio_save(s->vdev, f);
}
static int virtio_console_load(QEMUFile *f, void *opaque, int version_id)
@@ -119,25 +121,28 @@ static int virtio_console_load(QEMUFile *f, void *opaque, int version_id)
if (version_id != 1)
return -EINVAL;
- virtio_load(&s->vdev, f);
+ virtio_load(s->vdev, f);
return 0;
}
VirtIODevice *virtio_console_init(DeviceState *dev)
{
- VirtIOConsole *s;
- s = (VirtIOConsole *)virtio_common_init("virtio-console",
- VIRTIO_ID_CONSOLE,
- 0, sizeof(VirtIOConsole));
- s->vdev.get_features = virtio_console_get_features;
+ virtconsole.vdev = virtio_common_init("virtio-console",
+ VIRTIO_ID_CONSOLE,
+ 0, sizeof(VirtIODevice));
+ virtconsole.vdev->get_features = virtio_console_get_features;
- s->ivq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_input);
- s->ovq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_output);
+ virtconsole.ivq = virtio_add_queue(virtconsole.vdev, 128,
+ virtio_console_handle_input);
+ virtconsole.ovq = virtio_add_queue(virtconsole.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);
+ virtconsole.chr = qdev_init_chardev(dev);
+ qemu_chr_add_handlers(virtconsole.chr, vcon_can_read, vcon_read, vcon_event,
+ &virtconsole);
- register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s);
+ register_savevm("virtio-console", -1, 1, virtio_console_save,
+ virtio_console_load, &virtconsole);
- return &s->vdev;
+ return virtconsole.vdev;
}
--
1.6.2.5
next reply other threads:[~2009-09-04 9:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-04 9:14 Amit Shah [this message]
2009-09-04 16:26 ` [Qemu-devel] [PATCH] virtio-console: Have a static instance of virtconsole Blue Swirl
2009-09-04 16:33 ` Amit Shah
2009-09-04 16:37 ` Blue Swirl
2009-09-04 16:40 ` Amit Shah
2009-09-04 16:45 ` Blue Swirl
2009-09-04 16:51 ` Amit Shah
[not found] ` <m3y6ouy5lq.fsf@neno.mitica>
2009-09-04 17:40 ` [Qemu-devel] " Amit Shah
2009-09-08 14:08 ` Anthony Liguori
2009-09-08 14:41 ` Gerd Hoffmann
2009-09-09 6:07 ` 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=1252055670-26958-1-git-send-email-amit.shah@redhat.com \
--to=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).