render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0016-virtio-console-notify-backend-of-guest-open-close.patch

Justin M. Forbes 252f3a
>From 3baf76e384c04f58f032632c078860d66c8c9db3 Mon Sep 17 00:00:00 2001
Justin M. Forbes 252f3a
From: Hans de Goede <hdegoede@redhat.com>
Justin M. Forbes 252f3a
Date: Fri, 18 Mar 2011 15:30:45 +0100
Justin M. Forbes 252f3a
Subject: [PATCH 16/17] virtio-console: notify backend of guest open / close
Justin M. Forbes 252f3a
Justin M. Forbes 252f3a
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Justin M. Forbes 252f3a
---
Justin M. Forbes 252f3a
 hw/virtio-console.c |   18 ++++++++++++++++++
Justin M. Forbes 252f3a
 1 files changed, 18 insertions(+), 0 deletions(-)
Justin M. Forbes 252f3a
Justin M. Forbes 252f3a
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
Justin M. Forbes 252f3a
index eecbdf7..828a1a3 100644
Justin M. Forbes 252f3a
--- a/hw/virtio-console.c
Justin M. Forbes 252f3a
+++ b/hw/virtio-console.c
Justin M. Forbes 252f3a
@@ -37,6 +37,22 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
Justin M. Forbes 252f3a
     return qemu_chr_write(vcon->chr, buf, len);
Justin M. Forbes 252f3a
 }
Justin M. Forbes 252f3a
 
Justin M. Forbes 252f3a
+/* Callback function that's called when the guest opens the port */
Justin M. Forbes 252f3a
+static void guest_open(VirtIOSerialPort *port)
Justin M. Forbes 252f3a
+{
Justin M. Forbes 252f3a
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
Justin M. Forbes 252f3a
+
Justin M. Forbes 252f3a
+    qemu_chr_guest_open(vcon->chr);
Justin M. Forbes 252f3a
+}
Justin M. Forbes 252f3a
+
Justin M. Forbes 252f3a
+/* Callback function that's called when the guest closes the port */
Justin M. Forbes 252f3a
+static void guest_close(VirtIOSerialPort *port)
Justin M. Forbes 252f3a
+{
Justin M. Forbes 252f3a
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
Justin M. Forbes 252f3a
+
Justin M. Forbes 252f3a
+    qemu_chr_guest_close(vcon->chr);
Justin M. Forbes 252f3a
+}
Justin M. Forbes 252f3a
+
Justin M. Forbes 252f3a
 /* Readiness of the guest to accept data on a port */
Justin M. Forbes 252f3a
 static int chr_can_read(void *opaque)
Justin M. Forbes 252f3a
 {
Justin M. Forbes 252f3a
@@ -81,6 +97,8 @@ static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)
Justin M. Forbes 252f3a
     if (vcon->chr) {
Justin M. Forbes 252f3a
         qemu_chr_add_handlers(vcon->chr, &chr_handlers, vcon);
Justin M. Forbes 252f3a
         vcon->port.info->have_data = flush_buf;
Justin M. Forbes 252f3a
+        vcon->port.info->guest_open = guest_open;
Justin M. Forbes 252f3a
+        vcon->port.info->guest_close = guest_close;
Justin M. Forbes 252f3a
     }
Justin M. Forbes 252f3a
     return 0;
Justin M. Forbes 252f3a
 }
Justin M. Forbes 252f3a
-- 
Justin M. Forbes 252f3a
1.7.3.2
Justin M. Forbes 252f3a