From patchwork Thu Mar 24 10:12:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 88154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A8C9AB6F8C for ; Thu, 24 Mar 2011 21:10:50 +1100 (EST) Received: from localhost ([127.0.0.1]:33921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2hUq-0001e4-97 for incoming@patchwork.ozlabs.org; Thu, 24 Mar 2011 06:10:28 -0400 Received: from [140.186.70.92] (port=34573 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2hTd-0001cO-Iw for qemu-devel@nongnu.org; Thu, 24 Mar 2011 06:09:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2hTc-0006up-KN for qemu-devel@nongnu.org; Thu, 24 Mar 2011 06:09:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2hTc-0006uh-As for qemu-devel@nongnu.org; Thu, 24 Mar 2011 06:09:12 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2OA9B65022451 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Mar 2011 06:09:11 -0400 Received: from shalem.localdomain.com (vpn2-10-55.ams2.redhat.com [10.36.10.55]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2OA97ji004461; Thu, 24 Mar 2011 06:09:10 -0400 From: Hans de Goede To: qemu-devel@nongnu.org Date: Thu, 24 Mar 2011 11:12:03 +0100 Message-Id: <1300961524-6205-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1300961524-6205-1-git-send-email-hdegoede@redhat.com> References: <1300961524-6205-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede Subject: [Qemu-devel] [PATCH 2/3] virtio-console: notify backend of guest open / close X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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..e635771 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); + + 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); + + 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; }