提交 f9907ebc 编写于 作者: C Cornelia Huck 提交者: Stefan Hajnoczi

dataplane: fail notifier setting gracefully

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: NChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 267e1a20
...@@ -232,8 +232,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) ...@@ -232,8 +232,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
vq = virtio_get_queue(s->vdev, 0); vq = virtio_get_queue(s->vdev, 0);
if (!vring_setup(&s->vring, s->vdev, 0)) { if (!vring_setup(&s->vring, s->vdev, 0)) {
s->starting = false; goto fail_vring;
return;
} }
/* Set up guest notifier (irq) */ /* Set up guest notifier (irq) */
...@@ -241,7 +240,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) ...@@ -241,7 +240,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
if (r != 0) { if (r != 0) {
fprintf(stderr, "virtio-blk failed to set guest notifier (%d), " fprintf(stderr, "virtio-blk failed to set guest notifier (%d), "
"ensure -enable-kvm is set\n", r); "ensure -enable-kvm is set\n", r);
exit(1); goto fail_guest_notifiers;
} }
s->guest_notifier = virtio_queue_get_guest_notifier(vq); s->guest_notifier = virtio_queue_get_guest_notifier(vq);
...@@ -249,7 +248,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) ...@@ -249,7 +248,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
r = k->set_host_notifier(qbus->parent, 0, true); r = k->set_host_notifier(qbus->parent, 0, true);
if (r != 0) { if (r != 0) {
fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r); 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); s->host_notifier = *virtio_queue_get_host_notifier(vq);
...@@ -269,6 +268,14 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) ...@@ -269,6 +268,14 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
aio_context_acquire(s->ctx); aio_context_acquire(s->ctx);
aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify); aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify);
aio_context_release(s->ctx); 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 */ /* Context: QEMU global mutex held */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册