From patchwork Tue Jan 19 19:06:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 43205 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 023A9B7D53 for ; Wed, 20 Jan 2010 06:28:16 +1100 (EST) Received: from localhost ([127.0.0.1]:60855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXJh4-0004tR-FS for incoming@patchwork.ozlabs.org; Tue, 19 Jan 2010 14:24:50 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXJRA-0008VH-QM for qemu-devel@nongnu.org; Tue, 19 Jan 2010 14:08:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXJR6-0008Sr-E0 for qemu-devel@nongnu.org; Tue, 19 Jan 2010 14:08:24 -0500 Received: from [199.232.76.173] (port=53094 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXJR6-0008Sd-5k for qemu-devel@nongnu.org; Tue, 19 Jan 2010 14:08:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3052) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXJR5-00069d-HG for qemu-devel@nongnu.org; Tue, 19 Jan 2010 14:08:19 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0JJ8I9o004347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Jan 2010 14:08:18 -0500 Received: from localhost (vpn-247-16.phx2.redhat.com [10.3.247.16]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0JJ8HGC031899; Tue, 19 Jan 2010 14:08:17 -0500 From: Amit Shah To: qemu-devel@nongnu.org Date: Wed, 20 Jan 2010 00:36:56 +0530 Message-Id: <1263928018-32531-7-git-send-email-amit.shah@redhat.com> In-Reply-To: <1263928018-32531-6-git-send-email-amit.shah@redhat.com> References: <1263928018-32531-1-git-send-email-amit.shah@redhat.com> <1263928018-32531-2-git-send-email-amit.shah@redhat.com> <1263928018-32531-3-git-send-email-amit.shah@redhat.com> <1263928018-32531-4-git-send-email-amit.shah@redhat.com> <1263928018-32531-5-git-send-email-amit.shah@redhat.com> <1263928018-32531-6-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Amit Shah Subject: [Qemu-devel] [PATCH 6/8] virtio-serial: Add a 'virtserialport' device for generic serial port support 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 This commit adds a simple chardev-based serial port. Any data the guest sends is forwarded to the chardev and vice-versa. Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage. Signed-off-by: Amit Shah --- hw/virtio-serial.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/hw/virtio-serial.c b/hw/virtio-serial.c index 9c2c93c..bd44ec6 100644 --- a/hw/virtio-serial.c +++ b/hw/virtio-serial.c @@ -110,3 +110,37 @@ static void virtconsole_register(void) virtio_serial_port_qdev_register(&virtconsole_info); } device_init(virtconsole_register) + +/* Generic Virtio Serial Ports */ +static int virtserialport_initfn(VirtIOSerialDevice *dev) +{ + VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev); + VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); + + port->info = dev->info; + + if (vcon->chr) { + qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event, + vcon); + port->info->have_data = flush_buf; + } + return 0; +} + +static VirtIOSerialPortInfo virtserialport_info = { + .qdev.name = "virtserialport", + .qdev.size = sizeof(VirtConsole), + .init = virtserialport_initfn, + .exit = virtconsole_exitfn, + .qdev.props = (Property[]) { + DEFINE_PROP_CHR("chardev", VirtConsole, chr), + DEFINE_PROP_STRING("name", VirtConsole, port.name), + DEFINE_PROP_END_OF_LIST(), + }, +}; + +static void virtserialport_register(void) +{ + virtio_serial_port_qdev_register(&virtserialport_info); +} +device_init(virtserialport_register)