diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2010-07-16 17:11:46 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2010-07-19 14:20:00 +0300 |
commit | d154e0bafbd51bfd029ade9f1362bdff612b0f55 (patch) | |
tree | 4cd6ee80eb1ebc3212fc98f8e5f604d41c0420bf /hw/vhost.c | |
parent | 55e8d1ce6b09300cc5f3adcd9a705156d168381d (diff) | |
download | qemu-d154e0bafbd51bfd029ade9f1362bdff612b0f55.zip qemu-d154e0bafbd51bfd029ade9f1362bdff612b0f55.tar.gz qemu-d154e0bafbd51bfd029ade9f1362bdff612b0f55.tar.bz2 |
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=615228
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/vhost.c')
-rw-r--r-- | hw/vhost.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -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; |