Received: from eggs.gnu.org ([2001:4830:134:3::10]:37280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btQn8-0003Ms-7A for qemu-devel@nongnu.org; Sun, 09 Oct 2016 22:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btQn2-0003Vq-3d for qemu-devel@nongnu.org; Sun, 09 Oct 2016 22:58:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btQmr-0003Nk-0M for qemu-devel@nongnu.org; Sun, 09 Oct 2016 22:58:07 -0400 Date: Mon, 10 Oct 2016 05:57:55 +0300 From: "Michael S. Tsirkin" Message-ID: <1476057841-21108-16-git-send-email-mst@redhat.com> References: <1476057841-21108-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1476057841-21108-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 15/33] virtio-net: handle virtio_net_handle_ctrl() error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Greg Kurz , Stefan Hajnoczi , Jason Wang From: Greg Kurz This error is 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 Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 6b8ae2c..a1584e1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -880,6 +880,7 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd, return VIRTIO_NET_OK; } + static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) { VirtIONet *n = VIRTIO_NET(vdev); @@ -897,8 +898,10 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) } if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) || iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) { - error_report("virtio-net ctrl missing headers"); - exit(1); + virtio_error(vdev, "virtio-net ctrl missing headers"); + virtqueue_detach_element(vq, elem, 0); + g_free(elem); + break; } iov_cnt = elem->out_num; -- MST