summaryrefslogtreecommitdiff
path: root/Documentation/lguest
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-06-12 22:27:04 -0600
committerRusty Russell <rusty@rustcorp.com.au>2009-06-12 22:27:05 +0930
commite606490c440900e50ccf73a54f6fc6150ff40815 (patch)
tree43a660399ee81b3926789bd1644513e83c605d50 /Documentation/lguest
parentf086122bb6e885f926f935b1418fca3b293375f0 (diff)
downloadlinux-3.10-e606490c440900e50ccf73a54f6fc6150ff40815.tar.gz
linux-3.10-e606490c440900e50ccf73a54f6fc6150ff40815.tar.bz2
linux-3.10-e606490c440900e50ccf73a54f6fc6150ff40815.zip
lguest: clean up length-used value in example launcher
The "len" field in the used ring for virtio indicates the number of bytes *written* to the buffer. This means the guest doesn't have to zero the buffers in advance as it always knows the used length. Erroneously, the console and network example code puts the length *read* into that field. The guest ignores it, but it's wrong. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'Documentation/lguest')
-rw-r--r--Documentation/lguest/lguest.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 9f3240c4571..8704600c5e4 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -830,15 +830,14 @@ static bool handle_console_input(struct device *dev)
static void handle_console_output(struct virtqueue *vq, bool timeout)
{
unsigned int head, out, in;
- int len;
struct iovec iov[vq->vring.num];
/* Keep getting output buffers from the Guest until we run out. */
while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
if (in)
errx(1, "Input buffers in output queue?");
- len = writev(STDOUT_FILENO, iov, out);
- add_used_and_trigger(vq, head, len);
+ writev(STDOUT_FILENO, iov, out);
+ add_used_and_trigger(vq, head, 0);
}
}
@@ -870,7 +869,6 @@ static void block_vq(struct virtqueue *vq)
static void handle_net_output(struct virtqueue *vq, bool timeout)
{
unsigned int head, out, in, num = 0;
- int len;
struct iovec iov[vq->vring.num];
static int last_timeout_num;
@@ -878,10 +876,9 @@ static void handle_net_output(struct virtqueue *vq, bool timeout)
while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
if (in)
errx(1, "Input buffers in output queue?");
- len = writev(vq->dev->fd, iov, out);
- if (len < 0)
+ if (writev(vq->dev->fd, iov, out) < 0)
err(1, "Writing network packet to tun");
- add_used_and_trigger(vq, head, len);
+ add_used_and_trigger(vq, head, 0);
num++;
}