From patchwork Wed Nov 10 22:28:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 70729 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 1FFD9B7112 for ; Thu, 11 Nov 2010 10:26:45 +1100 (EST) Received: from localhost ([127.0.0.1]:35344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGJkW-0003rT-6U for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2010 18:06:40 -0500 Received: from [140.186.70.92] (port=42918 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGJDI-0008Jc-Tf for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:32:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGJ9u-0007tf-ES for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:28:52 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:46270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGJ9u-0007ta-Bx for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:28:50 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oAAMCDpV017176 for ; Wed, 10 Nov 2010 17:12:13 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oAAMSnrK392732 for ; Wed, 10 Nov 2010 17:28:49 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oAAMSnHF003981 for ; Wed, 10 Nov 2010 17:28:49 -0500 Received: from localhost.localdomain (sig-9-65-242-217.mts.ibm.com [9.65.242.217]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oAAMSI5b001385; Wed, 10 Nov 2010 17:28:48 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 10 Nov 2010 16:28:12 -0600 Message-Id: <1289428095-5059-17-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1289428095-5059-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1289428095-5059-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: agl@linux.vnet.ibm.com, abeekhof@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, amit.shah@redhat.com Subject: [Qemu-devel] [RFC][PATCH v2 16/19] virtproxy: qemu integration, add virtproxy chardev 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 allows us to create a virtproxy instance via a chardev. It can now be created with something like: qemu -chardev virtproxy,id=vp1 \ -device virtio-serial \ -device virtserialport,chardev=vp1 In the future the ability to add oforwards/iforwards in the command-line invocation and the monitor will be added. For now we leave it to users of virtproxy (currently only virtagent) to set up the forwarding sockets/ports they need via direct virtproxy API calls. Signed-off-by: Michael Roth --- qemu-char.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 88997f9..e318acb 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1902,6 +1902,48 @@ return_err: } /***********************************************************/ +/* Virtproxy chardev driver */ + +#include "virtproxy.h" + +static int vp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) +{ + VPDriver *drv = chr->opaque; + int ret; + + fprintf(stderr, "called, opaque: %p\n", chr); + + ret = vp_handle_packet_buf(drv, buf, len); + if (ret == -1) { + fprintf(stderr, "error handling data from virtproxy channel"); + } + + return 0; +} + +static CharDriverState *qemu_chr_open_virtproxy(QemuOpts *opts) +{ + CharDriverState *chr = qemu_mallocz(sizeof(CharDriverState)); + VPDriver *drv = vp_new(VP_CTX_CHARDEV, chr, 0, 0); + + chr->opaque = drv; + chr->chr_write = vp_chr_write; + + qemu_chr_generic_open(chr); + + /* TODO: eventually we will parse opts here to configure + * basic host/guest socket/port forwarding functionality. + * for now we exist solely for use by the virtagent RPC + * client/server, which will add it's oforwards/iforwards + * using using virtproxy API calls directly + */ + + /* for "info chardev" monitor command */ + chr->filename = NULL; + return chr; +} + +/***********************************************************/ /* TCP Net console */ typedef struct { @@ -2408,6 +2450,7 @@ static const struct { { .name = "udp", .open = qemu_chr_open_udp }, { .name = "msmouse", .open = qemu_chr_open_msmouse }, { .name = "vc", .open = text_console_init }, + { .name = "virtproxy", .open = qemu_chr_open_virtproxy }, #ifdef _WIN32 { .name = "file", .open = qemu_chr_open_win_file_out }, { .name = "pipe", .open = qemu_chr_open_win_pipe },