virtio-serial: make flow control explicit in virtio-console
virtio-console.c used to return a value less than the number of bytes asked to be written out to a chardev backend in case the backend is not writable. virtio-serial-bus.c then implicitly enabled flow control for that port. Make this explicit instead. Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: f5ec50b068c25422256e499cf4adc06d353bf394.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
7df4d4578f
commit
d6258c93a7
@ -47,20 +47,21 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
|
|||||||
ret = qemu_chr_fe_write(vcon->chr, buf, len);
|
ret = qemu_chr_fe_write(vcon->chr, buf, len);
|
||||||
trace_virtio_console_flush_buf(port->id, len, ret);
|
trace_virtio_console_flush_buf(port->id, len, ret);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret <= 0) {
|
||||||
|
VirtIOSerialPortClass *k = VIRTIO_SERIAL_PORT_GET_CLASS(port);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ideally we'd get a better error code than just -1, but
|
* Ideally we'd get a better error code than just -1, but
|
||||||
* that's what the chardev interface gives us right now. If
|
* that's what the chardev interface gives us right now. If
|
||||||
* we had a finer-grained message, like -EPIPE, we could close
|
* we had a finer-grained message, like -EPIPE, we could close
|
||||||
* this connection. Absent such error messages, the most we
|
* this connection.
|
||||||
* can do is to return 0 here.
|
|
||||||
*
|
|
||||||
* This will prevent stray -1 values to go to
|
|
||||||
* virtio-serial-bus.c and cause abort()s in
|
|
||||||
* do_flush_queued_data().
|
|
||||||
*/
|
*/
|
||||||
ret = 0;
|
ret = 0;
|
||||||
qemu_chr_fe_add_watch(vcon->chr, G_IO_OUT, chr_write_unblocked, vcon);
|
if (!k->is_console) {
|
||||||
|
virtio_serial_throttle_port(port, true);
|
||||||
|
qemu_chr_fe_add_watch(vcon->chr, G_IO_OUT, chr_write_unblocked,
|
||||||
|
vcon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -172,24 +172,7 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
|
|||||||
port->elem.out_sg[i].iov_base
|
port->elem.out_sg[i].iov_base
|
||||||
+ port->iov_offset,
|
+ port->iov_offset,
|
||||||
buf_size);
|
buf_size);
|
||||||
if (ret < 0 && ret != -EAGAIN) {
|
if (port->throttled) {
|
||||||
/* We don't handle any other type of errors here */
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
if (ret == -EAGAIN || (ret >= 0 && ret < buf_size)) {
|
|
||||||
/*
|
|
||||||
* this is a temporary check until chardevs can signal to
|
|
||||||
* frontends that they are writable again. This prevents
|
|
||||||
* the console from going into throttled mode (forever)
|
|
||||||
* if virtio-console is connected to a pty without a
|
|
||||||
* listener. Otherwise the guest spins forever.
|
|
||||||
* We can revert this if
|
|
||||||
* 1: chardevs can notify frondends
|
|
||||||
* 2: the guest driver does not spin in these cases
|
|
||||||
*/
|
|
||||||
if (!vsc->is_console) {
|
|
||||||
virtio_serial_throttle_port(port, true);
|
|
||||||
}
|
|
||||||
port->iov_idx = i;
|
port->iov_idx = i;
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
port->iov_offset += ret;
|
port->iov_offset += ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user