From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com
Subject: [Qemu-devel] [PATCH 5/5] virtio-console: Simplify init callbacks
Date: Wed, 25 May 2011 14:21:14 +0200 [thread overview]
Message-ID: <1306326074-22737-6-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1306326074-22737-1-git-send-email-armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/virtio-console.c | 35 +++++++++--------------------------
1 files changed, 9 insertions(+), 26 deletions(-)
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 713f6ef..b076331 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -74,11 +74,17 @@ static void chr_event(void *opaque, int event)
}
}
-static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)
+static int virtconsole_initfn(VirtIOSerialPort *port)
{
+ VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev,
vcon->port.dev.info);
+ if (port->id == 0 && !info->is_console) {
+ error_report("Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.");
+ return -1;
+ }
+
if (vcon->chr) {
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
vcon);
@@ -86,15 +92,8 @@ static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)
info->guest_open = guest_open;
info->guest_close = guest_close;
}
- return 0;
-}
-
-/* Virtio Console Ports */
-static int virtconsole_initfn(VirtIOSerialPort *port)
-{
- VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
- return generic_port_init(vcon, port);
+ return 0;
}
static int virtconsole_exitfn(VirtIOSerialPort *port)
@@ -132,26 +131,10 @@ static void virtconsole_register(void)
}
device_init(virtconsole_register)
-/* Generic Virtio Serial Ports */
-static int virtserialport_initfn(VirtIOSerialPort *port)
-{
- VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
-
- if (port->id == 0) {
- /*
- * Disallow a generic port at id 0, that's reserved for
- * console ports.
- */
- error_report("Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.");
- return -1;
- }
- return generic_port_init(vcon, port);
-}
-
static VirtIOSerialPortInfo virtserialport_info = {
.qdev.name = "virtserialport",
.qdev.size = sizeof(VirtConsole),
- .init = virtserialport_initfn,
+ .init = virtconsole_initfn,
.exit = virtconsole_exitfn,
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID),
--
1.7.2.3
next prev parent reply other threads:[~2011-05-25 15:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 12:21 [Qemu-devel] [PATCH 0/5] virtio-serial: Fixes and cleanups Markus Armbruster
2011-05-25 12:21 ` [Qemu-devel] [PATCH 1/5] virtio-serial: Plug memory leak on qdev exit() Markus Armbruster
2011-05-25 12:21 ` [Qemu-devel] [PATCH 2/5] virtio-serial: Clean up virtconsole detection Markus Armbruster
2011-05-25 12:21 ` [Qemu-devel] [PATCH 3/5] virtio-serial: Drop useless property is_console Markus Armbruster
2011-05-25 12:21 ` [Qemu-devel] [PATCH 4/5] virtio-serial: Drop redundant VirtIOSerialPort member info Markus Armbruster
2011-05-25 12:21 ` Markus Armbruster [this message]
2011-05-25 12:29 ` [Qemu-devel] [PATCH 0/5] virtio-serial: Fixes and cleanups 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=1306326074-22737-6-git-send-email-armbru@redhat.com \
--to=armbru@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).