Patchwork vhost: enable log before starting vq

login
register
mail settings
Submitter Michael S. Tsirkin
Date Oct. 25, 2010, 8:03 a.m.
Message ID <20101025080354.GA5438@redhat.com>
Download mbox | patch
Permalink /patch/69079/
State New
Headers show

Comments

Michael S. Tsirkin - Oct. 25, 2010, 8:03 a.m.
Log must be started before backend is enabled,
to make sure no memory changes are untracked.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/vhost.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/vhost.c b/hw/vhost.c
index 8586f66..e0152e2 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -650,15 +650,6 @@  int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
         r = -errno;
         goto fail_mem;
     }
-    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);
@@ -671,11 +662,19 @@  int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
             goto fail_log;
         }
     }
+    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;
-fail_log:
 fail_vq:
     while (--i >= 0) {
         vhost_virtqueue_cleanup(hdev,
@@ -683,6 +682,7 @@  fail_vq:
                                 hdev->vqs + i,
                                 i);
     }
+fail_log:
 fail_mem:
 fail_features:
     vdev->binding->set_guest_notifiers(vdev->binding_opaque, false);