From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: abeekhof@redhat.com, agl@linux.vnet.ibm.com,
mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com
Subject: [Qemu-devel] [RFC][RESEND][PATCH v1 00/15] virtproxy: host/guest communication layer
Date: Wed, 3 Nov 2010 10:27:55 -0500 [thread overview]
Message-ID: <1288798090-7127-1-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
This set of patches is a prereq for the proposed guest agent (virtagent), so resending these to accompany this morning's virtagent v2 submission.
OVERVIEW:
Virtproxy proxies and multiplexes socket streams over a data channel between a host and a guest (currently network connections, emulated serial, or virtio-serial channels are supported). This allows for services such as guest data collection agents, host/guest file transfer, and event generation/handling to be implemented/deployed as basic socket-based daemons, independently of the actual data channel.
This code is intended to provide a channel-independent abstraction layer for communicating with a QEMU-specific guest agent (in particular, the virtagent RPC guest agent which will follow this in a seperate patchset), but may have general utility beyond this (for instance: ssh/sftp/other guest agents/etc over isa/virtio serial), and so is submitted here as a seperate patchset.
Currently this communication involves 2 daemons (common code): 1 in the guest, and 1 in the host. Each end multiplexes/demultiplexes/proxies connections from the other end. In the future we hope to integrate the host component directly into qemu as a chardev.
BUILD/USAGE INFO:
make qemu-vp
./qemu-vp -h
EXAMPLE USAGE:
- Proxy http and ssh connections from a host to a guest over a virtio-serial connection:
# start guest with virtio-serial. for example (RHEL6s13):
qemu \
-device virtio-serial \
-chardev socket,path=/tmp/test0-virtioconsole.sock,server,nowait,id=test0 \
-device virtconsole,chardev=test0,name=test0 \
-chardev socket,path=/tmp/test1-virtio-serial.sock,server,nowait,id=test1 \
-device virtserialport,chardev=test1,name=test1 \
-chardev socket,path=/tmp/test2-virtio-serial.sock,server,nowait,id=test2 \
-device virtserialport,chardev=test2,name=test2 \
...
# in the host:
./qemu-vp -c unix-connect:/tmp/test2-virtio-serial.sock:- -o http:127.0.0.1:9080 \
-o ssh:127.0.0.1:9022
# in the guest:
./qemu-vp -c virtserial-open:/dev/virtio-ports/test2:- -i http:127.0.0.1:80 \
-i ssh:127.0.0.1:22
# from host, access guest http server
wget http://locahost:9080
# from host, access guest ssh server
ssh localhost -p 9022
- Proxy http and ssh connections from a host to a guest over a network connection:
# start guest with network connectivity to host
# in the guest:
./qemu-vp -c tcp-listen:<guest_ip>:9000 -i http:127.0.0.1:80 \
-i ssh:127.0.0.1:22
# in the host:
./qemu-vp -c tcp-connect:<guest_ip>:9000 -o http:127.0.0.1:9080 \
-o ssh:127.0.0.1:9022
...
By specifying -i and -o options in the host and guest, respectively, the channel can also be used to establish connections from a guest to a host.
KNOWN ISSUES:
- Deadlocking the guest: In tests over isa-serial ports I've hit cases where the chardev (socket) on the host-side seem to fill up the buffer, likely due to qemu rate-limiting data in accordance with the port's baud rate (which may explain why i hadn't seen this with network-based or virtio-serial data channels. When qemu-vp reads data from client connections it puts it into a VPPacket and tries to send the packet in it's entirety back over the channel. In this particular case that write() blocks (or vp_send_all() spins if we set O_NONBLOCK on the client FD). In the meantime qemu fills up the other end of the socket buffer and ends up spinning in qemu-char:send_all(), basically causing a deadlock between qemu and qemu-vp, and causing the guest to freeze.
Currently I'm planning on replacing vp_send_all() with a function that simply buffers write()'s, which would allow the use of non-blocking write()'s out to the channel/chardev socket while still retaining wholeness/fifo-ordering of the VPPackets.
- Sync issues with virtio-serial: This may or may not be related to the issue above, but I noticed some cases where proxied ssh sessions from the guest to the host would "lag" by a few bytes. For instance typing "top" would result in "to" being displayed, and the "p" wouldn't show up till I hit another key. This could be related to how I'm handling the buffering, but I haven't been able to reproduce using a network-based channel.
TODO:
- Rework vp_send_all() to use buffering to avoid above-mentioned deadlock scenario
- Integrate qemu-vp directly into qemu by adding a virtproxy chardev device. For example:
./qemu-vp -c unix-connect:/tmp/vp1-virtio-serial.sock:- -o ssh:127.0.0.1:9022
in the host, would be analogous to:
qemu \
-device virtio-serial \
-chardev virtproxy,oforward=ssh:127.0.0.1:9022,id=vp1 \
-device virtserialport,chardev=vp1,name=vp1
- Better channel negotiation to gracefully handle guest reboots/disconnects/etc
- Add monitor commands to add/remove virtproxy channels/oforwards/iforwards on the fly
.gitignore | 1 +
Makefile | 4 +-
configure | 1 +
qemu-vp.c | 618 +++++++++++++++++++++++++++++++++++++++++++++
virtproxy.c | 799 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
virtproxy.h | 40 +++
6 files changed, 1462 insertions(+), 1 deletions(-)
next reply other threads:[~2010-11-03 15:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-03 15:27 Michael Roth [this message]
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 01/15] virtproxy: base data structures and constants Michael Roth
2010-11-03 22:33 ` [Qemu-devel] " Adam Litke
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 02/15] virtproxy: qemu-vp, standalone daemon skeleton Michael Roth
2010-11-03 22:47 ` [Qemu-devel] " Adam Litke
2010-11-04 13:57 ` Michael Roth
2010-11-05 13:32 ` Adam Litke
2010-11-09 10:45 ` Amit Shah
2010-11-10 2:51 ` Michael Roth
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 03/15] virtproxy: add debug functions for virtproxy core Michael Roth
2010-11-03 22:51 ` [Qemu-devel] " Adam Litke
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 04/15] virtproxy: list look-up functions conns/oforwards/iforwards Michael Roth
2010-11-03 22:56 ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 05/15] virtproxy: add accept handler for communication channel Michael Roth
2010-11-03 23:02 ` [Qemu-devel] " Adam Litke
2010-11-04 16:17 ` Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 06/15] virtproxy: add read " Michael Roth
2010-11-03 23:38 ` [Qemu-devel] " Adam Litke
2010-11-04 17:00 ` Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 07/15] virtproxy: add vp_new() VPDriver constructor Michael Roth
2010-11-03 23:45 ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 08/15] virtproxy: interfaces to set/remove/handle VPOForwards Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 09/15] virtproxy: add handler for data packets Michael Roth
2010-11-04 0:46 ` [Qemu-devel] " Adam Litke
2010-11-04 18:23 ` Michael Roth
2010-11-04 1:48 ` Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 10/15] virtproxy: add handler for control packet Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 11/15] virtproxy: add vp_handle_packet() Michael Roth
2010-11-04 1:13 ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 12/15] virtproxy: interfaces to set/remove VPIForwards Michael Roth
2010-11-04 1:12 ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 13/15] virtproxy: add read handler for proxied connections Michael Roth
2010-11-04 1:21 ` [Qemu-devel] " Adam Litke
2010-11-04 18:26 ` Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 14/15] virtproxy: Makefile/configure changes to build qemu-vp Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 15/15] virtproxy: qemu-vp, main logic Michael Roth
2010-11-03 23:44 ` [Qemu-devel] Re: [RFC][RESEND][PATCH v1 00/15] virtproxy: host/guest communication layer Adam Litke
2010-11-04 18:46 ` Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288798090-7127-1-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=abeekhof@redhat.com \
--cc=agl@linux.vnet.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).