From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=44206 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POZyx-0001nh-HX for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POZyv-000394-OF for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:43 -0500 Received: from e5.ny.us.ibm.com ([32.97.182.145]:48641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POZyv-000385-LV for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:41 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB3HfNj7003098 for ; Fri, 3 Dec 2010 12:41:27 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id F0F94728045 for ; Fri, 3 Dec 2010 13:03:29 -0500 (EST) 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 oB3I3Tl4120950 for ; Fri, 3 Dec 2010 13:03:29 -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 oB3I3TuE011671 for ; Fri, 3 Dec 2010 13:03:29 -0500 From: Michael Roth Date: Fri, 3 Dec 2010 12:03:01 -0600 Message-Id: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH v5 00/21] 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: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com These patches apply to master, and can also be obtained from: git://repo.or.cz/qemu/mdroth.git virtagent_v5 CHANGES IN V5: - Dependency on virtproxy dropped, virtagent now handles transport and multiplexing of bi-directional RPCs internally - Removed duplification of qemu_set_fd_handler()-centered i/o code. Support for interacting with objects that use qemu_set_fd_handler() now available to tools via qemu-tools.c and a set of generalized utility functions - Fixed memory leaks in client/monitor functions - Various cleanups CHANGES IN V4: - Added guest agent capabilities negotiation - Added RPC/monitor command to invoke guest shutdown/reboot/powerdown - Added RPC/monitor command to the guest agent - Added guest startup notification ("hello") - Added syslog()'ing of guest agent RPCs - Various cleanups CHANGES IN V3: - Integrated virtagent server into virtproxy chardev. Usage examples below. - Consolidated RPC server/client setup into a pair of init routines - Fixed buffer overflow in agent_viewfile() and various memory leaks 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 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 QEMU and a simple guest daemon, aimed at providing this type of functionality. DESIGN: There are actually 2 RPC servers: 1) a server in the guest agent which handles RPC requests from QEMU 2) a server in the host, integrated into the virtagent chardev, to handle RPC requests sent by the guest agent (mainly for handling asynchronous events reported by the agent). Communication is done via RPCs (XMLRPC/HTTP between host and guest), albeit with a non-standard implementation that allows for multiplexing server/client RPC over a single virtio/isa serial channel. EXAMPLE USAGE: - Configure guest agent to talk to host via virtio-serial # start guest with virtio-serial/virtagent. for example (RHEL6): qemu \ -chardev virtagent,id=test0 \ -device virtio-serial \ -device virtserialport,chardev=test0,name=virtagent0 \ -monitor stdio ... # in the guest: ./qemu-va -c virtio-serial:/dev/virtio-ports/virtagent0:- ... # 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 (qemu) agent_shutdown powerdown (qemu) KNOWN ISSUES/PLANS: - switch to standard logging/trace mechanisms - outstanding requests should be reset if we get a hello notification (this implies guest/guest agent restart) - 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. Makefile | 4 +- Makefile.objs | 2 +- Makefile.target | 2 +- configure | 26 ++ hmp-commands.hx | 80 ++++++ monitor.c | 1 + qemu-char.c | 49 ++++ qemu-char.h | 4 + qemu-ioh.c | 115 ++++++++ qemu-ioh.h | 34 +++ qemu-tool.c | 25 ++- qemu-va.c | 327 ++++++++++++++++++++++ qerror.c | 8 + qerror.h | 6 + qmp-commands.hx | 164 +++++++++++ virtagent-common.c | 759 ++++++++++++++++++++++++++++++++++++++++++++++++++++ virtagent-common.h | 66 +++++ virtagent-server.c | 264 ++++++++++++++++++ virtagent-server.h | 30 ++ virtagent.c | 625 ++++++++++++++++++++++++++++++++++++++++++ virtagent.h | 48 ++++ vl.c | 86 ++----- 23 files changed, 2652 insertions(+), 75 deletions(-)