From 376be52bb02d081c676db29a9738f49df4e905b2 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Wed, 1 Aug 2018 10:52:18 +0800 Subject: [PATCH] vhost: fix the coredump when perform live migration QEMU will send SET_VRING_ADDR when perform live migration, it's not correct to update the memory table while the device is running. Change-Id: I899d3a996355ab6aa69835d90da14a86f93240fa Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/420944 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Pawel Wodkowski Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/vhost/rte_vhost/vhost_user.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/vhost/rte_vhost/vhost_user.c b/lib/vhost/rte_vhost/vhost_user.c index 9aef88c9b..0ce4798d0 100644 --- a/lib/vhost/rte_vhost/vhost_user.c +++ b/lib/vhost/rte_vhost/vhost_user.c @@ -364,21 +364,20 @@ vhost_user_set_vring_addr(struct virtio_net *dev, VhostUserMsg *msg) struct vhost_virtqueue *vq; uint64_t len; - if (dev->has_new_mem_table) { - vhost_setup_mem_table(dev); - dev->has_new_mem_table = 0; - } - - - if (dev->mem == NULL) - return -1; - /* Remove from the data plane. */ if (dev->flags & VIRTIO_DEV_RUNNING) { dev->flags &= ~VIRTIO_DEV_RUNNING; dev->notify_ops->destroy_device(dev->vid); } + if (dev->has_new_mem_table) { + vhost_setup_mem_table(dev); + dev->has_new_mem_table = 0; + } + + if (dev->mem == NULL) + return -1; + /* addr->index refers to the queue index. The txq 1, rxq is 0. */ vq = dev->virtqueue[msg->payload.addr.index];