Received: from [140.186.70.92] (port=48177 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDbdR-0006XI-Qi for qemu-devel@nongnu.org; Wed, 03 Nov 2010 07:36:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDbdP-0005OX-SG for qemu-devel@nongnu.org; Wed, 03 Nov 2010 07:36:09 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:41688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDbdP-0005ON-Pk for qemu-devel@nongnu.org; Wed, 03 Nov 2010 07:36:07 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oA3BJj5s012581 for ; Wed, 3 Nov 2010 07:19:45 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oA3Ba5xl158952 for ; Wed, 3 Nov 2010 07:36:05 -0400 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 oA3Ba5aM013176 for ; Wed, 3 Nov 2010 07:36:05 -0400 From: Michael Roth Date: Wed, 3 Nov 2010 06:35:29 -0500 Message-Id: <1288784139-1110-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH v2 00/10] virtagent: host/guest RPC communication agent List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@linux.vnet.ibm.com, agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com This set of patches is meant to be applied on top of the Virtproxy v1 patchset, which was submitted a couple weeks ago and can also be obtained at: git://repo.or.cz/qemu/mdroth.git virtproxy_v1 OVERVIEW: There are a wide range of use cases motivating the need for a guest agent of some sort to extend the functionality/usability/control offered by QEMU. Some examples include graceful guest shutdown/reboot and notifications thereof, copy/paste syncing between host/guest, guest statistics gathering, file access, etc. Ideally these would all be served by a single, easilly extensible agent that can be deployed in a wide range of guests. Virtagent is an XMLRPC server integrated into the Virtproxy guest daemon and aimed at providing this type of functionality. CHANGES IN V2: - All RPC communication is now done using asynchronous/non-blocking read/write handlers - Previously fork()'d RPC server loop is now integrated into qemu-vp/virtproxy i/o loop - Cleanups/suggestions from previous RFC DESIGN: There are actually 2 RPC servers: 1) a server in the guest integrated into the Virtproxy guest daemon which handles RPC requests from QEMU 2) a server in the host (integrated into the Virtproxy host daemon, which we plan to integrate directly into qemu) to handle RPC requests sent by the guest agent (mainly for handling asynchronous events reported by the agent). At the Virtagent level, communication is done via standard RPCs (HTTP between host and guest). Virtproxy transparently handles transport over a network or isa/virtio serial channel, allowing the agent to be deployed on older guests which may not support virtio-serial. Currently there are only 2 RPCs implemented for the guest server (getfile and getdmesg), and 0 for the host. Additional RPCs can be added fairly easily, but are dependent on feedback from here and elsewhere. ping/status, shutdown, and reboot are likely candidates (although the latter 2 will likely require asynchronous notifications to the host RPC server to implement reliably). EXAMPLE USAGE: The commandline options are a little convoluted right now; this will addressed in later revisions. - Configure guest agent to talk to host via virtio-serial # start guest with virtio-serial. for example (RHEL6s13): qemu \ -device virtio-serial \ -chardev socket,path=/tmp/test0-virtioconsole.sock,server,nowait,id=test0 \ -device virtconsole,chardev=test0,name=test0 \ -chardev socket,path=/tmp/test1-virtio-serial.sock,server,nowait,id=test1 \ -device virtserialport,chardev=test1,name=test1 \ -chardev socket,path=/tmp/test2-virtio-serial.sock,server,nowait,id=test2 \ -device virtserialport,chardev=test2,name=test2 \ -monitor stdio ... # in the host: ./qemu-vp -c unix-connect:/tmp/test2-virtio-serial.sock:- \ -o virtagent:/tmp/virtagent-guest-client.sock:- # in the guest: ./qemu-vp -c virtserial-open:/dev/virtio-ports/test2:- -g ... # monitor commands (qemu) agent_viewdmesg [139311.710326] wlan0: deauthenticating from 00:30:bd:f7:12:d5 by local choice (reason=3) [139323.469857] wlan0: deauthenticating from 00:21:29:cd:41:ee by local choice (reason=3) ... [257683.375646] wlan0: authenticated [257683.375684] wlan0: associate with AP 00:30:bd:f7:12:d5 (try 1) [257683.377932] wlan0: RX AssocResp from 00:30:bd:f7:12:d5 (capab=0x411 status=0 aid=4) [257683.377940] wlan0: associated (qemu) agent_viewfile /proc/meminfo MemTotal: 3985488 kB MemFree: 400524 kB Buffers: 220556 kB Cached: 2073160 kB SwapCached: 0 kB ... Hugepagesize: 2048 kB DirectMap4k: 8896 kB DirectMap2M: 4110336 kB KNOWN ISSUES/PLANS: - the client socket that qemu connects to send RPCs is a hardcoded filepath. This is unacceptable as the socket is channel/process specific and things will break when multiple guests are started. - capability negotiation will be needed to handle version/architecture differences. - proper channel negotiation is needed to avoid hung monitors and such when a guest reboots or the guest agent is stopped for whatever reason. additionally, a timeout may need to be imposed on the amount of time the http read handler can block the monitor. - additional host-to-guest RPCs as well as asynchronous notifications via guest-to-host RPCs for events such as shutdown/reboot/agent up/agent down Makefile | 2 +- Makefile.target | 2 +- configure | 25 +++ hmp-commands.hx | 32 ++++ monitor.c | 1 + qemu-vp.c | 115 +++++++++++++- qerror.c | 4 + qerror.h | 3 + qmp-commands.hx | 68 ++++++++ virtagent-common.c | 431 +++++++++++++++++++++++++++++++++++++++++++++++++++ virtagent-common.h | 73 +++++++++ virtagent-daemon.c | 253 ++++++++++++++++++++++++++++++ virtagent-daemon.h | 21 +++ virtagent.c | 286 ++++++++++++++++++++++++++++++++++ virtagent.h | 32 ++++ virtproxy-builtin.c | 30 ++++ 16 files changed, 1367 insertions(+), 11 deletions(-)