vhost-user-blk: support inter-host inflight migration
During inter-host migration, waiting for disk requests to be drained in the vhost-user backend can incur significant downtime. This can be avoided if QEMU migrates the inflight region in vhost-user-blk. Thus, during the qemu migration, with feature flag the vhost-user back-end can immediately stop vrings, so all in-flight requests will be migrated to another host. Signed-off-by: Alexandr Moshkov <dtalexundeer@yandex-team.ru> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260115081103.655749-6-dtalexundeer@yandex-team.ru>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
3a80ff0721
commit
3dfd711ea9
@@ -353,6 +353,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
|
||||
vhost_dev_set_config_notifier(&s->dev, &blk_ops);
|
||||
|
||||
s->vhost_user.supports_config = true;
|
||||
s->vhost_user.supports_inflight_migration = s->inflight_migration;
|
||||
ret = vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0,
|
||||
errp);
|
||||
if (ret < 0) {
|
||||
@@ -568,6 +569,26 @@ static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev)
|
||||
return &s->dev;
|
||||
}
|
||||
|
||||
static bool vhost_user_blk_inflight_needed(void *opaque)
|
||||
{
|
||||
struct VHostUserBlk *s = opaque;
|
||||
|
||||
bool inflight_migration = virtio_has_feature(s->dev.protocol_features,
|
||||
VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT);
|
||||
|
||||
return inflight_migration;
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_vhost_user_blk_inflight = {
|
||||
.name = "vhost-user-blk/inflight",
|
||||
.version_id = 1,
|
||||
.needed = vhost_user_blk_inflight_needed,
|
||||
.fields = (const VMStateField[]) {
|
||||
VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk),
|
||||
VMSTATE_END_OF_LIST()
|
||||
},
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_vhost_user_blk = {
|
||||
.name = "vhost-user-blk",
|
||||
.minimum_version_id = 1,
|
||||
@@ -576,6 +597,10 @@ static const VMStateDescription vmstate_vhost_user_blk = {
|
||||
VMSTATE_VIRTIO_DEVICE,
|
||||
VMSTATE_END_OF_LIST()
|
||||
},
|
||||
.subsections = (const VMStateDescription * const []) {
|
||||
&vmstate_vhost_user_blk_inflight,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
static const Property vhost_user_blk_properties[] = {
|
||||
@@ -591,6 +616,8 @@ static const Property vhost_user_blk_properties[] = {
|
||||
VIRTIO_BLK_F_WRITE_ZEROES, true),
|
||||
DEFINE_PROP_BOOL("skip-get-vring-base-on-force-shutdown", VHostUserBlk,
|
||||
skip_get_vring_base_on_force_shutdown, false),
|
||||
DEFINE_PROP_BOOL("inflight-migration", VHostUserBlk,
|
||||
inflight_migration, false),
|
||||
};
|
||||
|
||||
static void vhost_user_blk_class_init(ObjectClass *klass, const void *data)
|
||||
|
||||
@@ -52,6 +52,7 @@ struct VHostUserBlk {
|
||||
bool started_vu;
|
||||
|
||||
bool skip_get_vring_base_on_force_shutdown;
|
||||
bool inflight_migration;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -554,4 +554,10 @@ static inline int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f,
|
||||
}
|
||||
#endif
|
||||
|
||||
extern const VMStateDescription vmstate_vhost_inflight_region;
|
||||
#define VMSTATE_VHOST_INFLIGHT_REGION(_field, _state) \
|
||||
VMSTATE_STRUCT_POINTER(_field, _state, \
|
||||
vmstate_vhost_inflight_region, \
|
||||
struct vhost_inflight)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user