summaryrefslogtreecommitdiffstats
path: root/hw/virtio-console.c
diff options
context:
space:
mode:
authorAmit Shah2011-12-21 07:58:28 +0100
committerAnthony Liguori2011-12-21 22:00:29 +0100
commit05e7af694ce00dafdc464ca70306fa9dd6f78dcd (patch)
tree06c0ced4f1558aced1004634eae18a9bbf775753 /hw/virtio-console.c
parentvirtio-console: Check if chardev backends available before calling into them (diff)
downloadqemu-05e7af694ce00dafdc464ca70306fa9dd6f78dcd.tar.gz
qemu-05e7af694ce00dafdc464ca70306fa9dd6f78dcd.tar.xz
qemu-05e7af694ce00dafdc464ca70306fa9dd6f78dcd.zip
virtio-console: Properly initialise class methods
The earlier code really was a hack: initialising class methods in an object init function as noted by Anthony. The motivation for that was to not have the virtio-serial-bus call into the callback functions if there was no chardev backend registered. However, that really wasn't a worthwhile optimisation, and definitely not one that was well-implemented. Get rid of it. Reported-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-console.c')
-rw-r--r--hw/virtio-console.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index dbbea76dfb..73d866a52d 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -120,9 +120,6 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
if (vcon->chr) {
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
vcon);
- info->have_data = flush_buf;
- info->guest_open = guest_open;
- info->guest_close = guest_close;
}
return 0;
@@ -149,6 +146,9 @@ static VirtIOSerialPortInfo virtconsole_info = {
.is_console = true,
.init = virtconsole_initfn,
.exit = virtconsole_exitfn,
+ .have_data = flush_buf,
+ .guest_open = guest_open,
+ .guest_close = guest_close,
.qdev.props = (Property[]) {
DEFINE_PROP_CHR("chardev", VirtConsole, chr),
DEFINE_PROP_END_OF_LIST(),
@@ -166,6 +166,9 @@ static VirtIOSerialPortInfo virtserialport_info = {
.qdev.size = sizeof(VirtConsole),
.init = virtconsole_initfn,
.exit = virtconsole_exitfn,
+ .have_data = flush_buf,
+ .guest_open = guest_open,
+ .guest_close = guest_close,
.qdev.props = (Property[]) {
DEFINE_PROP_CHR("chardev", VirtConsole, chr),
DEFINE_PROP_END_OF_LIST(),