[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH v2 00/11] QEMU Guest Agent: QMP-based host/gues
From: |
Michael Roth |
Subject: |
[Qemu-devel] [RFC][PATCH v2 00/11] QEMU Guest Agent: QMP-based host/guest communication (virtagent) |
Date: |
Mon, 18 Apr 2011 10:02:16 -0500 |
These apply on top of Anthony's glib tree, commit
03d5927deb5e6baebaade1b4c8ff2428a85e125c currently, and can also be obtained
from:
git://repo.or.cz/qemu/mdroth.git qga_v2
Patches 1-8 are general json/QAPI-related fixes. Anthony, please consider
pulling these into your glib tree. The json fix-ups may need further
evaluation, but I'm confident they're at least an improvement. The QAPI ones
are mostly trivial fix-ups.
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:
- Fix QMP proxy handling of error responses sent by guest agent, currently
ignored
- Add unit tests for guest agent wire protocol
- Add unit tests for QMP interfaces
- Add host-side timeout mechanism for async QMP commands
- Return error for guest commands if guest up event has not yet been recieved
- Make QMP param names more consistent between related commands
- Clean up logging
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/mon-qmp.sock,server,nowait,id=mon-qmp \
-qmp mon-qmp \
-chardev qmp_proxy,id=qmp_proxy \
-device virtio-serial \
-device virtserialport,chardev=qmp_proxy,name=qcg"
use guest agent:
./qemu-ga -h
./qemu-ga -c virtio-serial -p /dev/virtio-ports/qcg
start/use qmp:
address@hidden:~$ sudo socat unix-connect:/tmp/mon-qmp.sock readline
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 13, "major": 0},
"package": ""}, "capabilities": []}}
{"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 | 15 +-
Makefile.objs | 1 +
configure | 6 +-
json-lexer.c | 33 ++-
json-lexer.h | 1 +
json-parser.c | 6 +-
json-streamer.c | 35 ++-
qapi-schema.json | 140 ++++++++-
qemu-char.c | 55 +++
qemu-ga.c | 711 +++++++++++++++++++++++++++++++++++++++
qemu-sockets.c | 2 +-
qga/guest-agent-command-state.c | 73 ++++
qga/guest-agent-commands.c | 284 ++++++++++++++++
qga/guest-agent-core.c | 139 ++++++++
qga/guest-agent-core.h | 40 +++
qga/guest-agent-worker.c | 173 ++++++++++
qmp-core.c | 13 +-
qmp-core.h | 7 +-
qmp-gen.py | 15 +-
qmp-proxy-core.h | 21 ++
qmp-proxy.c | 294 ++++++++++++++++
vl.c | 1 +
22 files changed, 2023 insertions(+), 42 deletions(-)
- [Qemu-devel] [RFC][PATCH v2 00/11] QEMU Guest Agent: QMP-based host/guest communication (virtagent),
Michael Roth <=
- [Qemu-devel] [RFC][PATCH v2 04/17] qapi: fix function name typo in qmp-gen.py, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 09/17] qmp proxy: core code for proxying qmp requests to guest, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 10/17] qmp proxy: add qmp_proxy chardev, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 06/17] qapi: fix memory leak for async marshalling code, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 07/17] qapi: qmp-gen.py, use basename of path for guard/core prefix, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 02/17] json-streamer: add handling for JSON_ERROR token/state, Michael Roth, 2011/04/18