From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42155 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q21O8-0006SE-U6 for qemu-devel@nongnu.org; Tue, 22 Mar 2011 09:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q21O7-0002b0-NK for qemu-devel@nongnu.org; Tue, 22 Mar 2011 09:12:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q21O7-0002ap-9n for qemu-devel@nongnu.org; Tue, 22 Mar 2011 09:12:43 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2MDCgdD029782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Mar 2011 09:12:42 -0400 From: Hans de Goede Date: Tue, 22 Mar 2011 14:15:22 +0100 Message-Id: <1300799723-664-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1300799723-664-1-git-send-email-hdegoede@redhat.com> References: <1300799723-664-1-git-send-email-hdegoede@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] virtio-console: notify backend of guest open / close List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Hans de Goede Signed-off-by: Hans de Goede --- hw/virtio-console.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) 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; } -- 1.7.3.2