<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From d59ea0f9a965c3ec6f1b0d1a59c6ebf6e3fe5131 Mon Sep 17 00:00:00 2001
From: Amit Shah &lt;amit.shah@redhat.com&gt;
Date: Thu, 22 Dec 2011 05:02:01 +0100
Subject: [PATCH 09/10] virtio-console: Properly initialise class methods

RH-Author: Amit Shah &lt;amit.shah@redhat.com&gt;
Message-id: &lt;a1d6cfe991c9de9901e7355c019aaa53ca8d8f85.1324529974.git.amit.shah@redhat.com&gt;
Patchwork-id: 35927
O-Subject: [RHEL6.3 qemu-kvm PATCH 09/10] virtio-console: Properly initialise class methods
Bugzilla: 769528
RH-Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
RH-Acked-by: Gerd Hoffmann &lt;kraxel@redhat.com&gt;
RH-Acked-by: Markus Armbruster &lt;armbru@redhat.com&gt;

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 &lt;aliguori@us.ibm.com&gt;
Signed-off-by: Amit Shah &lt;amit.shah@redhat.com&gt;
(cherry picked from commit 05e7af694ce00dafdc464ca70306fa9dd6f78dcd)

Conflicts:

	hw/virtio-console.c
---
 hw/virtio-console.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Signed-off-by: Michal Novotny &lt;minovotn@redhat.com&gt;
---
 hw/virtio-console.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 09bee01..1545e06 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -141,9 +141,6 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
             handlers = &amp;chr_handlers_no_flow_control;
         }
         qemu_chr_add_handlers(vcon-&gt;chr, handlers, vcon);
-        info-&gt;have_data = flush_buf;
-        info-&gt;guest_open = guest_open;
-        info-&gt;guest_close = guest_close;
     }
 
     return 0;
@@ -170,6 +167,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(),
@@ -187,6 +187,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(),
-- 
1.7.7.4

</pre></body></html>