From ac48d782f3b91b2e9962ded5f8a55bd3929a82a5 Mon Sep 17 00:00:00 2001 From: Michael S. Tsirkin Date: Wed, 24 Feb 2010 21:09:54 +0200 Subject: [PATCH] vhost: used addr migration fix Enable used buffer logging when migration starts. Fixed 'id XX is not a head' message after migration. Signed-off-by: Michael S. Tsirkin --- hw/vhost.c | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 54386e1..48034ba 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -325,7 +325,7 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev, return 0; } -static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) +static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) { uint64_t features = dev->acked_features; int r; @@ -336,6 +336,31 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) return r < 0 ? -errno : 0; } +static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) +{ + int r, t, i; + 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, + enable_log); + if (r < 0) + goto err_vq; + } + return 0; +err_vq: + for (; i >= 0; --i) { + t = vhost_virtqueue_set_addr(dev, dev->vqs + i, i, + dev->log_enabled); + assert(t >= 0); + } + t = vhost_dev_set_features(dev, dev->log_enabled); + assert(t >= 0); +err_features: + return r; +} + static int vhost_client_migration_log(struct CPUPhysMemoryClient *client, int enable) { @@ -544,7 +569,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) { int i, r; - r = vhost_dev_set_log(hdev, hdev->log_enabled); + r = vhost_dev_set_features(hdev, hdev->log_enabled); if (r < 0) goto fail; r = ioctl(hdev->control, VHOST_SET_MEM_TABLE, hdev->mem); -- 1.6.6.1