From patchwork Wed Sep 21 16:57:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9343973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C40E601C2 for ; Wed, 21 Sep 2016 17:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 322752A808 for ; Wed, 21 Sep 2016 17:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23B002A80B; Wed, 21 Sep 2016 17:13:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE7842A808 for ; Wed, 21 Sep 2016 17:13:06 +0000 (UTC) Received: from localhost ([::1]:45506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bml50-0000yY-3l for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Sep 2016 13:13:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmkqk-0006Pd-Ra for qemu-devel@nongnu.org; Wed, 21 Sep 2016 12:58:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmkqh-0003Jb-NO for qemu-devel@nongnu.org; Wed, 21 Sep 2016 12:58:22 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmkqh-0003Ii-EZ for qemu-devel@nongnu.org; Wed, 21 Sep 2016 12:58:19 -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 u8LGwIv3011635 for ; Wed, 21 Sep 2016 12:58:18 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 25k6cmb1wj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Sep 2016 12:58:16 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Sep 2016 10:57:45 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Sep 2016 10:57:41 -0600 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 97AA03E4003F; Wed, 21 Sep 2016 10:57:40 -0600 (MDT) Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8LGvdFn7209232; Wed, 21 Sep 2016 16:57:39 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C89FF124037; Wed, 21 Sep 2016 12:57:39 -0400 (EDT) Received: from [192.168.66.108] (unknown [9.83.153.110]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 3190F12404E; Wed, 21 Sep 2016 12:57:38 -0400 (EDT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 21 Sep 2016 18:57:37 +0200 In-Reply-To: <147447700612.30952.9420141963781948805.stgit@bahia> References: <147447700612.30952.9420141963781948805.stgit@bahia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16092116-0016-0000-0000-000004BF18EC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005798; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00759917; UDB=6.00361360; IPR=6.00534336; BA=6.00004744; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012740; XFM=3.00000011; UTC=2016-09-21 16:57:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16092116-0017-0000-0000-000033259684 Message-Id: <147447705731.30952.2850028415240858240.stgit@bahia> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-21_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609210307 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 6/9] virtio-net: handle virtio_net_receive() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Michael S. Tsirkin" , Jason Wang , Greg Kurz , Max Reitz , "Aneesh Kumar K.V" , Stefan Hajnoczi , Cornelia Huck , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP All these errors are caused by a buggy guest: let's switch the device to the broken state instead of terminating QEMU. Signed-off-by: Greg Kurz Reviewed-by: Cornelia Huck --- v2: - added Cornelia's R-b tag --- hw/net/virtio-net.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 8a6f1d952467..b3e290c32cd0 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1122,21 +1122,22 @@ 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"); + return -1; } sg = elem->in_sg;