Received: from eggs.gnu.org ([140.186.70.92]:43421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhLSP-0007if-45 for qemu-devel@nongnu.org; Thu, 14 Jul 2011 08:56:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhLSJ-0006Vu-Py for qemu-devel@nongnu.org; Thu, 14 Jul 2011 08:55:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhLSJ-0006Vf-8X for qemu-devel@nongnu.org; Thu, 14 Jul 2011 08:55:51 -0400 Date: Thu, 14 Jul 2011 09:55:39 -0300 From: Luiz Capitulino Message-ID: <20110714095539.6b3b90af@doriath> In-Reply-To: References: <1309872100-27912-1-git-send-email-mdroth@linux.vnet.ibm.com> Mime-Version: 1.0 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: Zhi Yong Wu Cc: aliguori@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, agl@linux.vnet.ibm.com, Michael Roth , qemu-devel@nongnu.org On Thu, 14 Jul 2011 10:53:51 +0800 Zhi Yong Wu wrote: > HI, Michael, >=20 > On Tue, Jul 5, 2011 at 9:21 PM, Michael Roth = wrote: > > This is Set 3/3 of the QAPI+QGA patchsets. > > > > These patches apply on top of qapi-backport-set2-v5, and can also be ob= tained 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 infrastruc= ture in > > place so that it can be used by the guest agent to implement a QMP-like= guest > > interface, and so that future work regarding the QMP conversion to QAPI= can be > > decoupled from the infrastructure bits. Set3 is the Qemu Guest Agent > > (virtagent), rebased on the new code QAPI code generation infrastructur= e. 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, = removed 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 = than 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 th= e provided data buffer > > =A0- made logging best-effort, removed handling of failures to log as e= rrors > > =A0- guest-shutdown exec errors now logged to guest syslog, clarified s= hutdown's asynchronous, no gauruntee nature in schema. > > > > CHANGES SINCE V4: > > =A0- Removed timeout mechanism via worker thread/pthread_cancel due to = potential memory leak. Will re-introduce guest-side timeout support in futu= re version. > > =A0- Fixed up fsfreeze code to use enums specified within the guest age= nt's qapi schema. > > =A0- Fixed memory leak due to a log statement, and added missing cleanu= p functions for heap-allocated g_error objects. > > =A0- Made "mode" param to guest-file-open optional, defaults to "r" (re= ad-only) > > > > CHANGES SINCE V3: > > =A0- Fixed error-handling issues in fsfreeze commands leading to certai= n 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 = documentation > > =A0- Fixed build issue that was missed due to deprecated files in sourc= e 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, wil= l be added when new QMP server is backported from Anthony's glib tree > > =A0- Replaced negotiation/control events with a simple 2-way handshake = implemented by a standard RPC (guest-sync) > > =A0- Removed enforcement of "pristine" sessions, state is now global/pe= rsistant 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= this in place we have a reliable timeout mechanism for hung commands, curr= ently set at 30 seconds. > > =A0- Add framework for registering init/cleanup routines for stateful R= PCs to clean up after themselves after a timeout. > > =A0- Added the following RPCs: guest-file-{open,close,read,write,seek},= guest-shutdown, guest-info, and removed stubs for guest-view-file (now dep= recated) > > =A0- Added GUEST_AGENT_UP/GUEST_AGENT_DOWN QMP events > > =A0- Switched to a TCP-style host-initiated 3-way handshake for channel= negotiation, this simplifies client negotiation/interaction over the wire > > =A0- Added configurable log level/log file/pid file options for guest a= gent > > =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, pl= ease reference the RFC for virtagent: > > > > http://comments.gmane.org/gmane.comp.emulators.qemu/96096 > > > > These patches integrate the previous virtagent guest agent work directl= y in QAPI/QMP to leverage it's auto-generated marshalling code. This has nu= merous benefits: > > > > =A0- addresses previous concerns over relying on external libraries to = handle data encapsulation > > =A0- reduces the need for manual unmarshalling of requests/responses, w= hich makes adding new RPCs much safer/less error-prone, as well as cutting = down on redundant code > > =A0- QAPI documentation aligns completely with guest-side RPC implement= ation > > =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=3D= virtio \ > > =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 te= minal? In the guest. >=20 > > > > 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":10= 24}} > > =A0{"return": {"buf": "aGVsbG8gd29ybGQhCg=3D=3D", "count": 13, "eof": t= rue}} > > =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(-) > > > > > >