mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 14:04:27 -04:00
vduse: add VDUSE_SET_FEATURES ioctl
Add an ioctl to allow VDUSE instances to set the VDUSE features supported by the userland VDUSE instance. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20260707122502.239022-4-eperezma@redhat.com>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
a596238c2a
commit
3b441820cb
@@ -159,6 +159,7 @@ struct vduse_dev_msg {
|
||||
|
||||
struct vduse_control {
|
||||
u64 api_version;
|
||||
u64 vduse_features;
|
||||
};
|
||||
|
||||
static DEFINE_MUTEX(vduse_lock);
|
||||
@@ -2348,7 +2349,29 @@ static long vduse_ioctl(struct file *file, unsigned int cmd,
|
||||
case VDUSE_GET_FEATURES:
|
||||
ret = put_user(vduse_features, (u64 __user *)argp);
|
||||
break;
|
||||
case VDUSE_SET_FEATURES: {
|
||||
u64 features;
|
||||
|
||||
ret = -EFAULT;
|
||||
if (get_user(features, (u64 __user *)argp)) {
|
||||
dev_dbg(vduse_ctrl_dev, "Could not get vduse features");
|
||||
break;
|
||||
}
|
||||
|
||||
ret = -EINVAL;
|
||||
if (features & ~vduse_features) {
|
||||
dev_dbg(vduse_ctrl_dev,
|
||||
"Invalid features in %llx, expected %llx",
|
||||
features, vduse_features);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
control->vduse_features = features;
|
||||
dev_dbg(vduse_ctrl_dev, "Set features %llx", features);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
@@ -2375,6 +2398,7 @@ static int vduse_open(struct inode *inode, struct file *file)
|
||||
return -ENOMEM;
|
||||
|
||||
control->api_version = VDUSE_API_VERSION_NOT_ASKED;
|
||||
control->vduse_features = 0;
|
||||
file->private_data = control;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -66,6 +66,9 @@ struct vduse_dev_config {
|
||||
/* Get the VDUSE supported features */
|
||||
#define VDUSE_GET_FEATURES _IOR(VDUSE_BASE, 0x04, __u64)
|
||||
|
||||
/* Set the VDUSE features */
|
||||
#define VDUSE_SET_FEATURES _IOW(VDUSE_BASE, 0x05, __u64)
|
||||
|
||||
/* The ioctls for VDUSE device (/dev/vduse/$NAME) */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user