vdpa: Add device migration blocker
Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker if it uses CVQ. However, qemu is able to migrate simple devices with no CVQ as long as they use SVQ. To allow it, add a placeholder error to vhost_vdpa, and only add to vhost_dev when used. vhost_dev machinery place the migration blocker if needed. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
8170ab3f43
commit
c156d5bf2b
@ -20,6 +20,7 @@
|
|||||||
#include "hw/virtio/vhost-shadow-virtqueue.h"
|
#include "hw/virtio/vhost-shadow-virtqueue.h"
|
||||||
#include "hw/virtio/vhost-vdpa.h"
|
#include "hw/virtio/vhost-vdpa.h"
|
||||||
#include "exec/address-spaces.h"
|
#include "exec/address-spaces.h"
|
||||||
|
#include "migration/blocker.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qemu/main-loop.h"
|
#include "qemu/main-loop.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
@ -1022,6 +1023,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v->migration_blocker) {
|
||||||
|
int r = migrate_add_blocker(v->migration_blocker, &err);
|
||||||
|
if (unlikely(r < 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < v->shadow_vqs->len; ++i) {
|
for (i = 0; i < v->shadow_vqs->len; ++i) {
|
||||||
VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
|
VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
|
||||||
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
|
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
|
||||||
@ -1064,6 +1072,10 @@ err:
|
|||||||
vhost_svq_stop(svq);
|
vhost_svq_stop(svq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v->migration_blocker) {
|
||||||
|
migrate_del_blocker(v->migration_blocker);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,6 +1095,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v->migration_blocker) {
|
||||||
|
migrate_del_blocker(v->migration_blocker);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
|
|||||||
bool shadow_vqs_enabled;
|
bool shadow_vqs_enabled;
|
||||||
/* IOVA mapping used by the Shadow Virtqueue */
|
/* IOVA mapping used by the Shadow Virtqueue */
|
||||||
VhostIOVATree *iova_tree;
|
VhostIOVATree *iova_tree;
|
||||||
|
Error *migration_blocker;
|
||||||
GPtrArray *shadow_vqs;
|
GPtrArray *shadow_vqs;
|
||||||
const VhostShadowVirtqueueOps *shadow_vq_ops;
|
const VhostShadowVirtqueueOps *shadow_vq_ops;
|
||||||
void *shadow_vq_ops_opaque;
|
void *shadow_vq_ops_opaque;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user