[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [QAPI+QGA 3/3] QEMU Guest Agent (virtagent) v4
From: |
Michael Roth |
Subject: |
[Qemu-devel] [QAPI+QGA 3/3] QEMU Guest Agent (virtagent) v4 |
Date: |
Fri, 3 Jun 2011 17:47:59 -0500 |
This is Set 3/3 of the QAPI+QGA patchsets.
These patches apply on top of qapi-backport-set2-v2, and can also be obtained
from:
git://repo.or.cz/qemu/mdroth.git qapi-backport-set3-v4
(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 infrastructure 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 infrastructure. This
is the first user of QAPI, QMP will follow.)
___
CHANGES SINCE V3:
- Fixed error-handling issues in fsfreeze commands leading to certain mounted
directories causing freeze/thaw operations to fail
- Added cleanup hook to thaw filesystems on graceful guest agent exit
- Removed unused enum values and added additional details to schema
documentation
- Fixed build issue that was missed due to deprecated files in source tree,
removed unused includes
CHANGES SINCE V2:
- Rebased on new QAPI code generation framework
- 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
- Replaced negotiation/control events with a simple 2-way handshake
implemented by a standard RPC (guest-sync)
- Removed enforcement of "pristine" sessions, state is now global/persistant
across multiple clients/connections
- Fixed segfault in logging code
- Added Jes' filesystem freeze patches
- General cleanups
CHANGES SINCE V1:
- Added guest agent worker thread to execute RPCs in the guest. With this in
place we have a reliable timeout mechanism for hung commands, currently set at
30 seconds.
- Add framework for registering init/cleanup routines for stateful RPCs to
clean up after themselves after a timeout.
- Added the following RPCs: guest-file-{open,close,read,write,seek},
guest-shutdown, guest-info, and removed stubs for guest-view-file (now
deprecated)
- Added GUEST_AGENT_UP/GUEST_AGENT_DOWN QMP events
- Switched to a TCP-style host-initiated 3-way handshake for channel
negotiation, this simplifies client negotiation/interaction over the wire
- Added configurable log level/log file/pid file options for guest agent
- Various fixes for bugs/memory leaks and checkpatch.pl fixups
ISSUES/TODOS:
- Add unit tests for guest agent wire protocol
OVERVIEW
For a better overview of what these patches are meant to accomplish, please
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 numerous
benefits:
- addresses previous concerns over relying on external libraries to handle
data encapsulation
- 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
- QAPI documentation aligns completely with guest-side RPC implementation
- is Just Better (TM)
BUILD/USAGE
build:
./configure --target-list=x86_64-softmmu
make
make qemu-ga #should be built on|for target guest
start guest:
qemu \
-drive file=/home/mdroth/vm/rhel6_64_base.raw,snapshot=off,if=virtio \
-net nic,model=virtio,macaddr=52:54:00:12:34:00 \
-net tap,script=/etc/qemu-ifup \
-vnc :1 -m 1024 --enable-kvm \
-chardev socket,path=/tmp/qga.sock,server,nowait,id=qga \
-device virtio-serial \
-device virtserialport,chardev=qga,name=qga"
use guest agent:
./qemu-ga -h
./qemu-ga -c virtio-serial -p /dev/virtio-ports/qga
start/use qmp:
address@hidden:~$ sudo socat unix-connect:/tmp/qga.sock readline
{"execute":"guest-sync", "arguments":{"id":1234}}
{"return": 1234}
{"execute":"guest-info"}
{"return": {}}
{"execute": "guest-info"}
{"return": {"version": "1.0", "timeout_ms": 30000}}
{"execute":"guest-file-open",
"arguments":{"filename":"/tmp/testqga","mode":"w+"}}
{"return": 0}
{"execute":"guest-file-write",
"arguments":{"filehandle":0,"data_b64":"aGVsbG8gd29ybGQhCg==","count":13}} //
writes "hello world!\n"
{"return": {"count": 13, "eof": false}}
{"execute":"guest-file-open",
"arguments":{"filename":"/tmp/testqga","mode":"r"}}
{"return": 1}
{"execute":"guest-file-read", "arguments":{"filehandle":1,"count":1024}}
{"return": {"buf": "aGVsbG8gd29ybGQhCg==", "count": 13, "eof": true}}
{"execute":"guest-file-close","arguments":{"filehandle":1}}
{"return": {}}
Makefile | 22 +-
qapi-schema-guest.json | 201 ++++++++++++
qemu-ga.c | 645 +++++++++++++++++++++++++++++++++++++++
qerror.c | 4 +
qerror.h | 3 +
qga/guest-agent-command-state.c | 73 +++++
qga/guest-agent-commands.c | 522 +++++++++++++++++++++++++++++++
qga/guest-agent-core.h | 39 +++
qga/guest-agent-worker.c | 179 +++++++++++
9 files changed, 1683 insertions(+), 5 deletions(-)
- [Qemu-devel] [QAPI+QGA 3/3] QEMU Guest Agent (virtagent) v4,
Michael Roth <=
- [Qemu-devel] [PATCH v4][ 1/7] guest agent: worker thread class, Michael Roth, 2011/06/03
- [Qemu-devel] [PATCH v4][ 2/7] guest agent: command state class, Michael Roth, 2011/06/03
- [Qemu-devel] [PATCH v4][ 3/7] guest agent: qemu-ga daemon, Michael Roth, 2011/06/03
- [Qemu-devel] [PATCH v4][ 4/7] guest agent: add error class for QERR_QGA_LOGGING_FAILED, Michael Roth, 2011/06/03
- [Qemu-devel] [PATCH v4][ 5/7] guest agent: add guest agent RPCs/commands, Michael Roth, 2011/06/03
- [Qemu-devel] [PATCH v4][ 6/7] guest agent: add guest agent commands schema file, Michael Roth, 2011/06/03
- [Qemu-devel] [PATCH v4][ 7/7] guest agent: Makefile, build qemu-ga, Michael Roth, 2011/06/03