From patchwork Tue Jun 28 08:24:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 9202291 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 D3F6F6075F for ; Tue, 28 Jun 2016 08:27:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5666285F1 for ; Tue, 28 Jun 2016 08:27:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA2CE285F7; Tue, 28 Jun 2016 08:27:09 +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 438E0285F1 for ; Tue, 28 Jun 2016 08:27:08 +0000 (UTC) Received: from localhost ([::1]:34999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHoMN-0006uO-Q2 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 28 Jun 2016 04:27:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHoJx-0003nB-QG for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:24:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHoJt-0002dE-OV for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:24:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHoJt-0002d5-GM for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:24:33 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 000721FB05 for ; Tue, 28 Jun 2016 08:24:32 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5S8OV1G002915; Tue, 28 Jun 2016 04:24:32 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Tue, 28 Jun 2016 10:24:29 +0200 Message-Id: <1467102269-11112-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 28 Jun 2016 08:24:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] virtio: abort on fatal error instead of just exiting 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: mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP replace mainly useless exit(1) on fatal error path with abort(), so that it would be possible to generate core dump, that could be used to analyse cause of problem. Signed-off-by: Igor Mammedov Acked-by: Greg Kurz Acked-by: Cornelia Huck --- hw/virtio/virtio.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7ed06ea..9d3ac72 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -315,7 +315,7 @@ static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx) if (num_heads > vq->vring.num) { error_report("Guest moved used index from %u to %u", idx, vq->shadow_avail_idx); - exit(1); + abort(); } /* On success, callers read a descriptor at vq->last_avail_idx. * Make sure descriptor read does not bypass avail index read. */ @@ -337,7 +337,7 @@ static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx) /* If their number is silly, that's a fatal mistake. */ if (head >= vq->vring.num) { error_report("Guest says index %u is available", head); - exit(1); + abort(); } return head; @@ -360,7 +360,7 @@ static unsigned virtqueue_read_next_desc(VirtIODevice *vdev, VRingDesc *desc, if (next >= max) { error_report("Desc next is %u", next); - exit(1); + abort(); } vring_desc_read(vdev, desc, desc_pa, next); @@ -393,13 +393,13 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); - exit(1); + abort(); } /* If we've got too many, that implies a descriptor loop. */ if (num_bufs >= max) { error_report("Looped descriptor"); - exit(1); + abort(); } /* loop over the indirect descriptor table */ @@ -414,7 +414,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, /* If we've got too many, that implies a descriptor loop. */ if (++num_bufs > max) { error_report("Looped descriptor"); - exit(1); + abort(); } if (desc.flags & VRING_DESC_F_WRITE) { @@ -462,7 +462,7 @@ static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iove if (num_sg == max_num_sg) { error_report("virtio: too many write descriptors in indirect table"); - exit(1); + abort(); } iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write); @@ -500,11 +500,11 @@ static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr, sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write); if (!sg[i].iov_base) { error_report("virtio: error trying to map MMIO memory"); - exit(1); + abort(); } if (len != sg[i].iov_len) { error_report("virtio: unexpected memory split"); - exit(1); + abort(); } } } @@ -570,7 +570,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz) if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); - exit(1); + abort(); } /* loop over the indirect descriptor table */ @@ -588,7 +588,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz) } else { if (in_num) { error_report("Incorrect order for descriptors"); - exit(1); + abort(); } virtqueue_map_desc(&out_num, addr, iov, VIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len); @@ -597,7 +597,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz) /* If we've got too many, that implies a descriptor loop. */ if ((in_num + out_num) > max) { error_report("Looped descriptor"); - exit(1); + abort(); } } while ((i = virtqueue_read_next_desc(vdev, &desc, desc_pa, max)) != max);