[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 6/9] virtio-net: handle virtio_net_receive() erro
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PATCH v4 6/9] virtio-net: handle virtio_net_receive() errors |
Date: |
Fri, 30 Sep 2016 17:13:24 +0200 |
User-agent: |
StGit/0.17.1-dirty |
All these errors are caused by a buggy guest: let's switch the device to
the broken state instead of terminating QEMU. Also we detach the element
from the virtqueue and free it.
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
v4: - added Stefan's R-b tag
---
hw/net/virtio-net.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2c02ba8a70a4..10a4c745f0bd 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1125,21 +1125,24 @@ static ssize_t virtio_net_receive(NetClientState *nc,
const uint8_t *buf, size_t
elem = virtqueue_pop(q->rx_vq, sizeof(VirtQueueElement));
if (!elem) {
- if (i == 0)
- return -1;
- error_report("virtio-net unexpected empty queue: "
- "i %zd mergeable %d offset %zd, size %zd, "
- "guest hdr len %zd, host hdr len %zd "
- "guest features 0x%" PRIx64,
- i, n->mergeable_rx_bufs, offset, size,
- n->guest_hdr_len, n->host_hdr_len,
- vdev->guest_features);
- exit(1);
+ if (i) {
+ virtio_error(vdev, "virtio-net unexpected empty queue: "
+ "i %zd mergeable %d offset %zd, size %zd, "
+ "guest hdr len %zd, host hdr len %zd "
+ "guest features 0x%" PRIx64,
+ i, n->mergeable_rx_bufs, offset, size,
+ n->guest_hdr_len, n->host_hdr_len,
+ vdev->guest_features);
+ }
+ return -1;
}
if (elem->in_num < 1) {
- error_report("virtio-net receive queue contains no in buffers");
- exit(1);
+ virtio_error(vdev,
+ "virtio-net receive queue contains no in buffers");
+ virtqueue_detach_element(q->rx_vq, elem, 0);
+ g_free(elem);
+ return -1;
}
sg = elem->in_sg;
- [Qemu-devel] [PATCH v4 0/9] virtio: avoid inappropriate QEMU termination in device code, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 1/9] virtio-9p: add parentheses to sizeof operator, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 2/9] virtio-blk: make some functions static, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 3/9] virtio-9p: handle handle_9p_output() error, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 4/9] virtio-blk: handle virtio_blk_handle_request() errors, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 5/9] virtio-net: handle virtio_net_handle_ctrl() error, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 6/9] virtio-net: handle virtio_net_receive() errors,
Greg Kurz <=
- [Qemu-devel] [PATCH v4 7/9] virtio-net: handle virtio_net_flush_tx() errors, Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 8/9] virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error(), Greg Kurz, 2016/09/30
- [Qemu-devel] [PATCH v4 9/9] virtio-scsi: handle virtio_scsi_set_config() error, Greg Kurz, 2016/09/30
- Re: [Qemu-devel] [PATCH v4 0/9] virtio: avoid inappropriate QEMU termination in device code, no-reply, 2016/09/30