Received: from eggs.gnu.org ([2001:4830:134:3::10]:53934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzVF-0004My-Hq for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpzV9-0004ei-Dn for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:13:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzV9-0004eN-4g for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:13:27 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8UFDQNb069355 for ; Fri, 30 Sep 2016 11:13:26 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 25sm7ws17c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 30 Sep 2016 11:13:26 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 30 Sep 2016 09:13:24 -0600 From: Greg Kurz Date: Fri, 30 Sep 2016 17:13:16 +0200 In-Reply-To: <147524835229.953.16853431367911587573.stgit@bahia> References: <147524835229.953.16853431367911587573.stgit@bahia> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <147524839598.953.2517950464382347429.stgit@bahia> Subject: [Qemu-devel] [PATCH v4 5/9] 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: Kevin Wolf , "Michael S. Tsirkin" , Jason Wang , Greg Kurz , Max Reitz , "Aneesh Kumar K.V" , Stefan Hajnoczi , Cornelia Huck , Paolo Bonzini 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 --- v4: - added Stefan's R-b tag --- 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 01f1351554aa..2c02ba8a70a4 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -875,6 +875,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); @@ -892,8 +893,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;