Commit 5b45c921 authored by jiangdongxu's avatar jiangdongxu
Browse files

vhost-vdpa: add uAPI for device migration status

virt inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I86ITO



----------------------------------------------------------------------

These new ioctl add support for setting vhost-vdpa device migration
state.

During migration, there is several migration state such as start/stop,
pre_start/pre_stop, post_start/post_stop, cancel etc.Some hardware needs
to do something at these stages, introduce a new ioctl to implement it.

Signed-off-by: default avatarjiangdongxu <jiangdongxu1@huawei.com>
parent 4c3d3bae
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -629,6 +629,21 @@ static int vhost_vdpa_set_dev_buffer(struct vhost_vdpa *v,
	return ret;
}

static int vhost_vdpa_set_mig_state(struct vhost_vdpa *v, u8 __user *c)
{
	struct vdpa_device *vdpa = v->vdpa;
	const struct vdpa_config_ops *ops = vdpa->config;
	u8 state;

	if (!ops->set_mig_state)
		return -EOPNOTSUPP;

	if (get_user(state, c))
		return -EFAULT;

	return ops->set_mig_state(vdpa, state);
}

static long vhost_vdpa_set_log_base(struct vhost_vdpa *v, u64 __user *argp)
{
	struct vdpa_device *vdpa = v->vdpa;
@@ -889,6 +904,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
	case VHOST_SET_DEV_BUFFER:
		r = vhost_vdpa_set_dev_buffer(v, argp);
		break;
	case VHOST_VDPA_SET_MIG_STATE:
		r = vhost_vdpa_set_mig_state(v, argp);
		break;
	default:
		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
		if (r == -ENOIOCTLCMD)
+3 −0
Original line number Diff line number Diff line
@@ -197,4 +197,7 @@
#define VHOST_SET_DEV_BUFFER _IOW(VHOST_VIRTIO, 0xb1, struct vhost_vdpa_config)
#define VHOST_GET_DEV_BUFFER_SIZE _IOR(VHOST_VIRTIO, 0xb3, __u32)

/* set device migtration state */
#define VHOST_VDPA_SET_MIG_STATE _IOW(VHOST_VIRTIO, 0xb2, __u8)

#endif
+16 −0
Original line number Diff line number Diff line
@@ -147,6 +147,22 @@ struct vhost_vdpa_iova_range {
	__u64 last;
};

/* vhost vdpa device migration statue */
enum {
	VHOST_VDPA_DEVICE_START,
	VHOST_VDPA_DEVICE_STOP,
	VHOST_VDPA_DEVICE_PRE_START,
	VHOST_VDPA_DEVICE_PRE_STOP,
	VHOST_VDPA_DEVICE_CANCEL,
	VHOST_VDPA_DEVICE_POST_START,
	VHOST_VDPA_DEVICE_START_ASYNC,
	VHOST_VDPA_DEVICE_STOP_ASYNC,
	VHOST_VDPA_DEVICE_PRE_START_ASYNC,
	VHOST_VDPA_DEVICE_QUERY_OP_STATE,
	VHOST_VDPA_DEVICE_MSIX_MASK,
	VHOST_VDPA_DEVICE_MSIX_UNMASK,
};

/* Feature bits */
/* Log all write descriptors. Can be changed while device is active. */
#define VHOST_F_LOG_ALL 26