提交 d154e0ba 编写于 作者: M Michael S. Tsirkin

vhost: fix miration during device start

We need to know ring layout to allocate log buffer.
So init rings first.

Also fixes a theoretical memory-leak-on-error.

https://bugzilla.redhat.com/show_bug.cgi?id=615228Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Tested-by: NGerd Hoffmann <kraxel@redhat.com>
上级 55e8d1ce
......@@ -659,6 +659,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
r = -errno;
goto fail;
}
for (i = 0; i < hdev->nvqs; ++i) {
r = vhost_virtqueue_init(hdev,
vdev,
hdev->vqs + i,
i);
if (r < 0) {
goto fail_vq;
}
}
if (hdev->log_enabled) {
hdev->log_size = vhost_get_log_size(hdev);
hdev->log = hdev->log_size ?
......@@ -667,19 +677,10 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
(uint64_t)(unsigned long)hdev->log);
if (r < 0) {
r = -errno;
goto fail;
}
}
for (i = 0; i < hdev->nvqs; ++i) {
r = vhost_virtqueue_init(hdev,
vdev,
hdev->vqs + i,
i);
if (r < 0) {
goto fail_vq;
}
}
hdev->started = true;
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册