Skip to content

Commit

Permalink
virtio: console makes incorrect assumption about virtio API
Browse files Browse the repository at this point in the history
The get_buf() API sets the second arg to the number of bytes *written*
by the other side; in this case it should be zero as these are output buffers.

lguest gets this right (obviously kvm's console doesn't), resulting in
continual buildup of console writes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Amit Shah <amit.shah@redhat.com>
  • Loading branch information
Rusty Russell committed Apr 8, 2010
1 parent 162a689 commit 9ff4cfa
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,20 +416,16 @@ static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count)
out_vq->vq_ops->kick(out_vq);

if (ret < 0) {
len = 0;
in_count = 0;
goto fail;
}

/*
* Wait till the host acknowledges it pushed out the data we
* sent. Also ensure we return to userspace the number of
* bytes that were successfully consumed by the host.
*/
/* Wait till the host acknowledges it pushed out the data we sent. */
while (!out_vq->vq_ops->get_buf(out_vq, &len))
cpu_relax();
fail:
/* We're expected to return the amount of data we wrote */
return len;
return in_count;
}

/*
Expand Down

0 comments on commit 9ff4cfa

Please sign in to comment.