From 29181903cedd89100f8686cca0cc67bf5ce511a5 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Thu, 18 Jan 2018 19:27:41 +0100 Subject: [PATCH] vhost: prevent IO freeze by kicking all queues after starting device See comment in vhost.c file for more details why this fix is needed. Change-Id: I782119768fb200ad36f9253e704cc08a3be36ae6 Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/395514 Reviewed-by: Dariusz Stojaczyk Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/vhost/vhost.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 6cf459126..d8bc4ad21 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -985,6 +985,21 @@ start_device(int vid) goto out; } + /* + * Not sure right now but this look like some kind of QEMU bug and guest IO + * might be frozed without kicking all queues after live-migration. This look like + * the previous vhost instance failed to effectively deliver all interrupts before + * the GET_VRING_BASE message. This shouldn't harm guest since spurious interrupts + * should be ignored by guest virtio driver. + * + * Tested on QEMU 2.10.91 and 2.11.50. + */ + for (i = 0; i < num_queues; i++) { + if (vdev->virtqueue[i].vring.callfd != -1) { + eventfd_write(vdev->virtqueue[i].vring.callfd, (eventfd_t)1); + } + } + vdev->lcore = spdk_vhost_allocate_reactor(vdev->cpumask); rc = spdk_vhost_event_send(vdev, vdev->backend->start_device, 3, "start device"); if (rc != 0) {