virtio: console makes incorrect assumption about virtio API
Subsystems (3)
PATCH 3/4 virtio: console makes incorrect assumption about virtio API
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 <[email protected]>
To: Amit Shah <[email protected]>
--- drivers/char/virtio_console.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/char/virtio_console.c +3 -7
@@ -415,20 +415,16 @@ static ssize_t send_buf(struct port *por 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; }/*
Quoted 8 lines · Rusty Russell
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 <[email protected]>To: Amit Shah <[email protected]>
Acked-by Amit Shah <[email protected]>
Quoted 22 lines
--- drivers/char/virtio_console.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/char/virtio_console.c +1
-6@@ -415,20 +415,16 @@ static ssize_t send_buf(struct port *por 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. -*/
drivers/char/virtio_console.c static ssize_t send_buf(struct port *por · line 430
Quoted 10 lines
drivers/char/virtio_console.c +2
-1+/* 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; }/*
Amit
Signature · 1 line
http://log.amitshah.net/