Received: from eggs.gnu.org ([2001:4830:134:3::10]:47281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoA2h-0006DI-P4 for qemu-devel@nongnu.org; Mon, 19 Oct 2015 09:00:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoA2d-0003qo-4F for qemu-devel@nongnu.org; Mon, 19 Oct 2015 08:59:59 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoA2c-0003qg-VQ for qemu-devel@nongnu.org; Mon, 19 Oct 2015 08:59:55 -0400 Received: by wicfx6 with SMTP id fx6so4548483wic.1 for ; Mon, 19 Oct 2015 05:59:54 -0700 (PDT) From: Thibaut Collet Date: Mon, 19 Oct 2015 14:59:27 +0200 Message-Id: <1445259567-28516-2-git-send-email-thibaut.collet@6wind.com> In-Reply-To: <1445259567-28516-1-git-send-email-thibaut.collet@6wind.com> References: <1445259567-28516-1-git-send-email-thibaut.collet@6wind.com> Subject: [Qemu-devel] [PATCH 1/1] vhost: set the correct queue index in case of migration with multiqueue List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: thibaut.collet@6wind.com, qemu-devel@nongnu.org, mst@redhat.com, marcandre.lureau@gmail.com, jasowang@redhat.com, pbonzini@redhat.com, haifeng.lin@huawei.com When a live migration is started the log address to mark dirty pages is provided to the vhost backend through the vhost_dev_set_log function. This function is called for each queue pairs but the queue index is wrongly set: always set to the first queue pair. Then vhost backend lost descriptor addresses of the queue pairs greater than 1 and behaviour of the vhost backend is unpredictable. The queue index is computed by taking account of the vq_index (to retrieve the queue pair index) and calling the vhost_get_vq_index method of the backend. Signed-off-by: Thibaut Collet --- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index feeaaa4..de29968 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) { - int r, t, i; + int r, t, i, idx; r = vhost_dev_set_features(dev, enable_log); if (r < 0) { goto err_features; } for (i = 0; i < dev->nvqs; ++i) { - r = vhost_virtqueue_set_addr(dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i); + r = vhost_virtqueue_set_addr(dev, dev->vqs + i, idx, enable_log); if (r < 0) { goto err_vq; @@ -671,7 +672,8 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) return 0; err_vq: for (; i >= 0; --i) { - t = vhost_virtqueue_set_addr(dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i); + t = vhost_virtqueue_set_addr(dev, dev->vqs + i, idx, dev->log_enabled); assert(t >= 0); } -- 2.1.4