Received: from eggs.gnu.org ([2001:4830:134:3::10]:44242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAeL9-0003W7-4e for qemu-devel@nongnu.org; Fri, 25 Jul 2014 08:11:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAeKx-0000mt-Fi for qemu-devel@nongnu.org; Fri, 25 Jul 2014 08:11:11 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:57831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAeKx-0000mn-6r for qemu-devel@nongnu.org; Fri, 25 Jul 2014 08:10:59 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 25 Jul 2014 13:10:58 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9F6A017D8066 for ; Fri, 25 Jul 2014 13:12:35 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6PCAt3436175960 for ; Fri, 25 Jul 2014 12:10:55 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s6PCAskv001906 for ; Fri, 25 Jul 2014 06:10:54 -0600 From: Cornelia Huck Date: Fri, 25 Jul 2014 14:10:47 +0200 Message-Id: <1406290248-11545-3-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1406290248-11545-1-git-send-email-cornelia.huck@de.ibm.com> References: <1406290248-11545-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH RFC 2/3] dataplane: fail notifier setting gracefully List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stefan Hajnoczi , Kevin Wolf Cc: Cornelia Huck The dataplane code is currently doing a hard exit if it fails to set up either guest or host notifiers. In practice, this may mean that a guest suddenly dies after a dataplane device failed to come up (e.g., when a file descriptor limit is hit for tne nth device). Let's just try to unwind the setup instead and return. Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- hw/block/dataplane/virtio-blk.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 527a53c..94e1a29 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -232,8 +232,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) vq = virtio_get_queue(s->vdev, 0); if (!vring_setup(&s->vring, s->vdev, 0)) { - s->starting = false; - return; + goto fail_vring; } /* Set up guest notifier (irq) */ @@ -241,7 +240,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) if (r != 0) { fprintf(stderr, "virtio-blk failed to set guest notifier (%d), " "ensure -enable-kvm is set\n", r); - exit(1); + goto fail_guest_notifiers; } s->guest_notifier = virtio_queue_get_guest_notifier(vq); @@ -249,7 +248,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) r = k->set_host_notifier(qbus->parent, 0, true); if (r != 0) { fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r); - exit(1); + goto fail_host_notifier; } s->host_notifier = *virtio_queue_get_host_notifier(vq); @@ -269,6 +268,14 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) aio_context_acquire(s->ctx); aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify); aio_context_release(s->ctx); + return; + + fail_host_notifier: + k->set_guest_notifiers(qbus->parent, 1, false); + fail_guest_notifiers: + vring_teardown(&s->vring, s->vdev, 0); + fail_vring: + s->starting = false; } /* Context: QEMU global mutex held */ -- 1.7.9.5