From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhCDF-0000Xj-Va for qemu-devel@nongnu.org; Wed, 13 Jul 2011 23:03:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhCDA-0006dK-G4 for qemu-devel@nongnu.org; Wed, 13 Jul 2011 23:03:41 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:52661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhC3k-0004VL-96 for qemu-devel@nongnu.org; Wed, 13 Jul 2011 22:53:52 -0400 Received: by ywb3 with SMTP id 3so3146676ywb.4 for ; Wed, 13 Jul 2011 19:53:51 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1309872100-27912-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1309872100-27912-1-git-send-email-mdroth@linux.vnet.ibm.com> Date: Thu, 14 Jul 2011 10:53:51 +0800 Message-ID: From: Zhi Yong Wu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [QAPI+QGA 3/3] QEMU Guest Agent (virtagent) v6 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: aliguori@linux.vnet.ibm.com, lcapitulino@redhat.com, agl@linux.vnet.ibm.com, qemu-devel@nongnu.org, Jes.Sorensen@redhat.com HI, Michael, On Tue, Jul 5, 2011 at 9:21 PM, Michael Roth wr= ote: > This is Set 3/3 of the QAPI+QGA patchsets. > > These patches apply on top of qapi-backport-set2-v5, and can also be obta= ined from: > git://repo.or.cz/qemu/mdroth.git qapi-backport-set3-v6 > > (Set1+2 are a backport of some of the QAPI-related work from Anthony's > glib tree. The main goal is to get the basic code generation infrastructu= re in > place so that it can be used by the guest agent to implement a QMP-like g= uest > interface, and so that future work regarding the QMP conversion to QAPI c= an be > decoupled from the infrastructure bits. Set3 is the Qemu Guest Agent > (virtagent), rebased on the new code QAPI code generation infrastructure.= This > is the first user of QAPI, QMP will follow.) > ___ > > CHANGES SINCE V5: > =A0- switched to using qemu malloc/list functions where possible > =A0- removed unused proxy_path field in struct GAState > =A0- pid file now opened write-only, removed lockf() in favor of O_EXCL, = added SIGINT/SIGTERM signal handlers to handle cleanup > =A0- cleaned up error-handling, switched to asserts where appropriate, re= moved unecessary gotos and NULL checks for qemu_free()/qobject_decref() > =A0- refactored send_payload() using helper functions > =A0- fixed improper handling of pidfile fd=3D=3D0 > =A0- changed guest-shutdown's "shutdown_mode" param to "mode" > =A0- switched to using kernel-generated FDs for guest-file-open rather th= an an autoincrement value > =A0- add maximum chunk size of guest-file-read/guest-file-write > =A0- added checks to avoid guest-file-write from writing data beyond the = provided data buffer > =A0- made logging best-effort, removed handling of failures to log as err= ors > =A0- guest-shutdown exec errors now logged to guest syslog, clarified shu= tdown's asynchronous, no gauruntee nature in schema. > > CHANGES SINCE V4: > =A0- Removed timeout mechanism via worker thread/pthread_cancel due to po= tential memory leak. Will re-introduce guest-side timeout support in future= version. > =A0- Fixed up fsfreeze code to use enums specified within the guest agent= 's qapi schema. > =A0- Fixed memory leak due to a log statement, and added missing cleanup = functions for heap-allocated g_error objects. > =A0- Made "mode" param to guest-file-open optional, defaults to "r" (read= -only) > > CHANGES SINCE V3: > =A0- Fixed error-handling issues in fsfreeze commands leading to certain = mounted directories causing freeze/thaw operations to fail > =A0- Added cleanup hook to thaw filesystems on graceful guest agent exit > =A0- Removed unused enum values and added additional details to schema do= cumentation > =A0- Fixed build issue that was missed due to deprecated files in source = tree, removed unused includes > > CHANGES SINCE V2: > =A0- Rebased on new QAPI code generation framework > =A0- Dropped ability for QMP to act as a proxy for the guest agent, will = be added when new QMP server is backported from Anthony's glib tree > =A0- Replaced negotiation/control events with a simple 2-way handshake im= plemented by a standard RPC (guest-sync) > =A0- Removed enforcement of "pristine" sessions, state is now global/pers= istant across multiple clients/connections > =A0- Fixed segfault in logging code > =A0- Added Jes' filesystem freeze patches > =A0- General cleanups > > CHANGES SINCE V1: > =A0- Added guest agent worker thread to execute RPCs in the guest. With t= his in place we have a reliable timeout mechanism for hung commands, curren= tly set at 30 seconds. > =A0- Add framework for registering init/cleanup routines for stateful RPC= s to clean up after themselves after a timeout. > =A0- Added the following RPCs: guest-file-{open,close,read,write,seek}, g= uest-shutdown, guest-info, and removed stubs for guest-view-file (now depre= cated) > =A0- Added GUEST_AGENT_UP/GUEST_AGENT_DOWN QMP events > =A0- Switched to a TCP-style host-initiated 3-way handshake for channel n= egotiation, this simplifies client negotiation/interaction over the wire > =A0- Added configurable log level/log file/pid file options for guest age= nt > =A0- Various fixes for bugs/memory leaks and checkpatch.pl fixups > > ISSUES/TODOS: > =A0- Add unit tests for guest agent wire protocol > > OVERVIEW > > For a better overview of what these patches are meant to accomplish, plea= se reference the RFC for virtagent: > > http://comments.gmane.org/gmane.comp.emulators.qemu/96096 > > These patches integrate the previous virtagent guest agent work directly = in QAPI/QMP to leverage it's auto-generated marshalling code. This has nume= rous benefits: > > =A0- addresses previous concerns over relying on external libraries to ha= ndle data encapsulation > =A0- reduces the need for manual unmarshalling of requests/responses, whi= ch makes adding new RPCs much safer/less error-prone, as well as cutting do= wn on redundant code > =A0- QAPI documentation aligns completely with guest-side RPC implementat= ion > =A0- is Just Better (TM) > > BUILD/USAGE > > build: > =A0./configure --target-list=3Dx86_64-softmmu > =A0make > =A0make qemu-ga #should be built on|for target guest > > start guest: > =A0qemu \ > =A0-drive file=3D/home/mdroth/vm/rhel6_64_base.raw,snapshot=3Doff,if=3Dvi= rtio \ > =A0-net nic,model=3Dvirtio,macaddr=3D52:54:00:12:34:00 \ > =A0-net tap,script=3D/etc/qemu-ifup \ > =A0-vnc :1 -m 1024 --enable-kvm \ > =A0-chardev socket,path=3D/tmp/qga.sock,server,nowait,id=3Dqga \ > =A0-device virtio-serial \ > =A0-device virtserialport,chardev=3Dqga,name=3Dqga" > > use guest agent: > =A0./qemu-ga -h > =A0./qemu-ga -c virtio-serial -p /dev/virtio-ports/qga Is the above command "./qemu-ga" issued on guest teminal or hypervisor temi= nal? > > start/use qmp: > =A0mdroth@illuin:~$ sudo socat unix-connect:/tmp/qga.sock readline > =A0{"execute":"guest-sync", "arguments":{"id":1234}} > =A0{"return": 1234} > > =A0{"execute":"guest-info"} > =A0{"return": {}} > > =A0{"execute": "guest-info"} > =A0{"return": {"version": "1.0"}} > > =A0{"execute":"guest-file-open", "arguments":{"filepath":"/tmp/testqga","= mode":"w+"}} > =A0{"return": 0} > =A0{"execute":"guest-file-write", "arguments":{"filehandle":0,"data_b64":= "aGVsbG8gd29ybGQhCg=3D=3D","count":13}} // writes "hello world!\n" > =A0{"return": {"count": 13, "eof": false}} > > =A0{"execute":"guest-file-open", "arguments":{"filepath":"/tmp/testqga","= mode":"r"}} > =A0{"return": 1} > =A0{"execute":"guest-file-read", "arguments":{"filehandle":1,"count":1024= }} > =A0{"return": {"buf": "aGVsbG8gd29ybGQhCg=3D=3D", "count": 13, "eof": tru= e}} > =A0{"execute":"guest-file-close","arguments":{"filehandle":1}} > =A0{"return": {}} > > =A0Makefile =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 22 +- > =A0configure =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A01 + > =A0qapi-schema-guest.json =A0 =A0 =A0 =A0 =A0| =A0202 +++++++++++++ > =A0qemu-ga.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0631 +++++++= ++++++++++++++++++++++++++++++++ > =A0qerror.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A04 + > =A0qerror.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A03 + > =A0qga/guest-agent-command-state.c | =A0 73 +++++ > =A0qga/guest-agent-commands.c =A0 =A0 =A0| =A0522 +++++++++++++++++++++++= +++++++++ > =A0qga/guest-agent-core.h =A0 =A0 =A0 =A0 =A0| =A0 30 ++ > =A09 files changed, 1483 insertions(+), 5 deletions(-) > > > --=20 Regards, Zhi Yong Wu