Patchwork [2/3] virtio-console: notify backend of guest open / close

login
register
mail settings
Submitter Hans de Goede
Date March 22, 2011, 1:15 p.m.
Message ID <1300799723-664-3-git-send-email-hdegoede@redhat.com>
Download mbox | patch
Permalink /patch/87917/
State New
Headers show

Comments

Hans de Goede - March 22, 2011, 1:15 p.m.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 hw/virtio-console.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index c235b27..a23ef5a 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -27,6 +27,22 @@  static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
     return qemu_chr_write(vcon->chr, buf, len);
 }
 
+/* Callback function that's called when the guest opens the port */
+static void guest_open(VirtIOSerialPort *port)
+{
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+    return qemu_chr_guest_open(vcon->chr);
+}
+
+/* Callback function that's called when the guest closes the port */
+static void guest_close(VirtIOSerialPort *port)
+{
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+    return qemu_chr_guest_close(vcon->chr);
+}
+
 /* Readiness of the guest to accept data on a port */
 static int chr_can_read(void *opaque)
 {
@@ -63,6 +79,8 @@  static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)
         qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
                               vcon);
         vcon->port.info->have_data = flush_buf;
+        vcon->port.info->guest_open = guest_open;
+        vcon->port.info->guest_close = guest_close;
     }
     return 0;
 }