From patchwork Tue Sep 29 12:04:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 34421 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 2A556B7C29 for ; Tue, 29 Sep 2009 22:11:59 +1000 (EST) Received: from localhost ([127.0.0.1]:33751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MsbYh-0006J8-1G for incoming@patchwork.ozlabs.org; Tue, 29 Sep 2009 08:11:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MsbSj-000503-It for qemu-devel@nongnu.org; Tue, 29 Sep 2009 08:05:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MsbSe-0004z1-Na for qemu-devel@nongnu.org; Tue, 29 Sep 2009 08:05:45 -0400 Received: from [199.232.76.173] (port=56963 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MsbSe-0004yv-42 for qemu-devel@nongnu.org; Tue, 29 Sep 2009 08:05:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6812) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MsbSd-0004Sr-Hy for qemu-devel@nongnu.org; Tue, 29 Sep 2009 08:05:39 -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.13.8/8.13.8) with ESMTP id n8TC5cTh027332 for ; Tue, 29 Sep 2009 08:05:38 -0400 Received: from localhost (vpn-225-25.phx2.redhat.com [10.3.225.25]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8TC5aol016774; Tue, 29 Sep 2009 08:05:37 -0400 From: Amit Shah To: qemu-devel@nongnu.org Date: Tue, 29 Sep 2009 17:34:46 +0530 Message-Id: <1254225888-17093-5-git-send-email-amit.shah@redhat.com> In-Reply-To: <1254225888-17093-4-git-send-email-amit.shah@redhat.com> References: <1254225888-17093-1-git-send-email-amit.shah@redhat.com> <1254225888-17093-2-git-send-email-amit.shah@redhat.com> <1254225888-17093-3-git-send-email-amit.shah@redhat.com> <1254225888-17093-4-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Amit Shah Subject: [Qemu-devel] [PATCH 4/6] virtio-console-port: Add a new device on the virtio-console-bus for generic host-guest communication 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 is a new device that uses the virtio-console bus. 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. For requirements, use-cases and some history see http://www.linux-kvm.org/page/VMchannel_Requirements Signed-off-by: Amit Shah --- Makefile.target | 2 +- hw/virtio-console-port.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletions(-) create mode 100644 hw/virtio-console-port.c diff --git a/Makefile.target b/Makefile.target index 22a2644..918275a 100644 --- a/Makefile.target +++ b/Makefile.target @@ -173,7 +173,7 @@ obj-y = vl.o monitor.o pci.o isa_mmio.o machine.o \ gdbstub.o gdbstub-xml.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly -obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o virtio-console-bus.o virtio-pci.o +obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o virtio-console-port.o virtio-console-bus.o virtio-pci.o obj-$(CONFIG_KVM) += kvm.o kvm-all.o LIBS+=-lz diff --git a/hw/virtio-console-port.c b/hw/virtio-console-port.c new file mode 100644 index 0000000..f8c0bbc --- /dev/null +++ b/hw/virtio-console-port.c @@ -0,0 +1,54 @@ +/* + * Virtio Serial Port + * + * Copyright Red Hat, Inc. 2009 + * + * Authors: + * Amit Shah + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "hw.h" +#include "qemu-char.h" +#include "virtio-console.h" + +typedef struct VirtIOConsole +{ + VirtConPort port; +} VirtIOConsole; + +static size_t flush_buf(VirtConPort *port, const uint8_t *buf, size_t len) +{ + return qemu_chr_write(port->chr, buf, len); +} + +static int vcon_port_initfn(VirtConDevice *dev) +{ + VirtConPort *port = DO_UPCAST(VirtConPort, dev, &dev->qdev); + + port->info = dev->info; + + return 0; +} + +static VirtConPortInfo virtcon_port_info = { + .qdev.name = "virtconport", + .qdev.size = sizeof(VirtConPort), + .init = vcon_port_initfn, + .have_data = flush_buf, + .qdev.props = (Property[]) { + DEFINE_PROP_CHR("chardev", VirtConPort, chr), + DEFINE_PROP_STRING("name", VirtConPort, name), + DEFINE_PROP_INT32("flush_buffers", VirtConPort, flush_buffers, 0), + DEFINE_PROP_END_OF_LIST(), + }, +}; + +static void virtcon_port_register(void) +{ + virtcon_port_qdev_register(&virtcon_port_info); +} +device_init(virtcon_port_register)