From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhMMC-0004nj-49 for qemu-devel@nongnu.org; Thu, 14 Jul 2011 09:53:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhMM6-000830-FK for qemu-devel@nongnu.org; Thu, 14 Jul 2011 09:53:35 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:36369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhMM6-00082t-53 for qemu-devel@nongnu.org; Thu, 14 Jul 2011 09:53:30 -0400 Received: by gxk26 with SMTP id 26so114751gxk.4 for ; Thu, 14 Jul 2011 06:53:29 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110714095539.6b3b90af@doriath> References: <1309872100-27912-1-git-send-email-mdroth@linux.vnet.ibm.com> <20110714095539.6b3b90af@doriath> Date: Thu, 14 Jul 2011 21:53:29 +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: Luiz Capitulino Cc: aliguori@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, agl@linux.vnet.ibm.com, Michael Roth , qemu-devel@nongnu.org On Thu, Jul 14, 2011 at 8:55 PM, Luiz Capitulino w= rote: > On Thu, 14 Jul 2011 10:53:51 +0800 > Zhi Yong Wu wrote: > >> HI, Michael, >> >> 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 o= btained 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 infrastru= cture in >> > place so that it can be used by the guest agent to implement a QMP-lik= e guest >> > interface, and so that future work regarding the QMP conversion to QAP= I can be >> > decoupled from the infrastructure bits. Set3 is the Qemu Guest Agent >> > (virtagent), rebased on the new code QAPI code generation infrastructu= re. 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_EXC= L, 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 t= he provided data buffer >> > =A0- made logging best-effort, removed handling of failures to log as = errors >> > =A0- guest-shutdown exec errors now logged to guest syslog, clarified = shutdown'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 fut= ure version. >> > =A0- Fixed up fsfreeze code to use enums specified within the guest ag= ent's qapi schema. >> > =A0- Fixed memory leak due to a log statement, and added missing clean= up functions for heap-allocated g_error objects. >> > =A0- Made "mode" param to guest-file-open optional, defaults to "r" (r= ead-only) >> > >> > CHANGES SINCE V3: >> > =A0- Fixed error-handling issues in fsfreeze commands leading to certa= in mounted directories causing freeze/thaw operations to fail >> > =A0- Added cleanup hook to thaw filesystems on graceful guest agent ex= it >> > =A0- Removed unused enum values and added additional details to schema= documentation >> > =A0- Fixed build issue that was missed due to deprecated files in sour= ce 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, wi= ll 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/p= ersistant 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. Wit= h this in place we have a reliable timeout mechanism for hung commands, cur= rently set at 30 seconds. >> > =A0- Add framework for registering init/cleanup routines for stateful = RPCs 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 de= precated) >> > =A0- Added GUEST_AGENT_UP/GUEST_AGENT_DOWN QMP events >> > =A0- Switched to a TCP-style host-initiated 3-way handshake for channe= l negotiation, this simplifies client negotiation/interaction over the wire >> > =A0- Added configurable log level/log file/pid file options for guest = agent >> > =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, p= lease reference the RFC for virtagent: >> > >> > http://comments.gmane.org/gmane.comp.emulators.qemu/96096 >> > >> > These patches integrate the previous virtagent guest agent work direct= ly in QAPI/QMP to leverage it's auto-generated marshalling code. This has n= umerous benefits: >> > >> > =A0- addresses previous concerns over relying on external libraries to= handle data encapsulation >> > =A0- reduces the need for manual unmarshalling of requests/responses, = which 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 implemen= tation >> > =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= =3Dvirtio \ >> > =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 t= eminal? > > In the guest. Can we make it work similiar as a linux service? It may is more convenient to use. [root@f12 ~]# service qemu-ga start/stop/status/restart [root@f12 ~]# chkconfig qemu-ga on/off > >> >> > >> > 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_b6= 4":"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":1= 024}} >> > =A0{"return": {"buf": "aGVsbG8gd29ybGQhCg=3D=3D", "count": 13, "eof": = true}} >> > =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