Skip to contentSkip to conversation

support vduse feature provisioning in vdpa netlink command

RFC In review Eugenio Pérez 3 participants 7 messages Oct 2, 2025 – Oct 10, 2025 virtio core

lore
Share & tools
lore

Eugenio Pérez

author maintainer
#0 lore raw

cover support vduse feature provisioning in vdpa netlink command

This series implements features provisioning for vduse devices. This allows the device provisioner to clear the features exposed by the userland device, so the driver never see them. The intended use case is to provision more than one different device with the same feature set, allowing live migration between them.

The device addition validates the provisioned features to be a subset of the parent features, as the rest of the backends.

Eugenio Pérez (2):
vduse: support feature provisioning
vduse: allow to specify device-specific features if it's multiclass

 drivers/vdpa/vdpa.c                |  9 ---------
 drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++++++++++---
 2 files changed, 14 insertions(+), 12 deletions(-)
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

RFC 1/2 vduse: support feature provisioning

This patch implements features provisioning for vduse devices. This allows the device provisioner to clear the features exposed by the userland device, so the driver never see them. The intended use case is to provision more than one different device with the same feature set, allowing live migration between them.

The device addition validates the provisioned features to be a subset of the parent features, as the rest of the backends.

---
 drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +14 -3
index 6c74282d5721..ef8fc795cfeb 100644
@@ -121,6 +121,7 @@ struct vduse_dev {
 	bool connected;
 	u64 api_version;
 	u64 device_features;
+	u64 supported_features;
 	u64 driver_features;
 	u32 device_id;
 	u32 vendor_id;
@@ -698,7 +699,7 @@ static u64 vduse_vdpa_get_device_features(struct vdpa_device *vdpa)
 {
 	struct vduse_dev *dev = vdpa_to_vduse(vdpa);
 
-	return dev->device_features;
+	return dev->supported_features;
 }
 
 static int vduse_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 features)
@@ -2256,13 +2257,22 @@ struct vduse_mgmt_dev {
 
 static struct vduse_mgmt_dev *vduse_mgmt;
 
-static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name)
+static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name,
+			       const struct vdpa_dev_set_config *config)
 {
 	struct vduse_vdpa *vdev;
 
 	if (dev->vdev)
 		return -EEXIST;
 
+	if (config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) {
+		if (config->device_features & ~dev->device_features)
+			return -EINVAL;
+		dev->supported_features = config->device_features;
+	} else {
+		dev->supported_features = dev->device_features;
+	}
+
 	vdev = vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev,
 				 &vduse_vdpa_config_ops, &vduse_map_ops,
 				 dev->ngroups, dev->nas, name, true);
@@ -2289,7 +2299,7 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 		mutex_unlock(&vduse_lock);
 		return -EINVAL;
 	}
-	ret = vduse_dev_init_vdpa(dev, name);
+	ret = vduse_dev_init_vdpa(dev, name, config);
 	mutex_unlock(&vduse_lock);
 	if (ret)
 		return ret;
@@ -2376,6 +2386,7 @@ static int vduse_mgmtdev_init(void)
 	vduse_mgmt->mgmt_dev.id_table = id_table;
 	vduse_mgmt->mgmt_dev.ops = &vdpa_dev_mgmtdev_ops;
 	vduse_mgmt->mgmt_dev.device = &vduse_mgmt->dev;
+	vduse_mgmt->mgmt_dev.config_attr_mask = BIT_ULL(VDPA_ATTR_DEV_FEATURES);
 	ret = vdpa_mgmtdev_register(&vduse_mgmt->mgmt_dev);
 	if (ret)
 		device_unregister(&vduse_mgmt->dev);
Signature · 1 line
2.51.0
#2 lore raw

Re: [RFC 1/2] vduse: support feature provisioning

Quoted 46 lines · Eugenio Pérez

This patch implements features provisioning for vduse devices. This allows the device provisioner to clear the features exposed by the userland device, so the driver never see them. The intended use case is to provision more than one different device with the same feature set, allowing live migration between them.

The device addition validates the provisioned features to be a subset of the parent features, as the rest of the backends.

---
  drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +4 -2
index 6c74282d5721..ef8fc795cfeb 100644
@@ -121,6 +121,7 @@ struct vduse_dev {
  	bool connected;
  	u64 api_version;
  	u64 device_features;
+	u64 supported_features;
  	u64 driver_features;
  	u32 device_id;
  	u32 vendor_id;
@@ -698,7 +699,7 @@ static u64 vduse_vdpa_get_device_features(struct vdpa_device *vdpa)
  {
  	struct vduse_dev *dev = vdpa_to_vduse(vdpa);
 
-	return dev->device_features;
+	return dev->supported_features;
  }
 
  static int vduse_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 features)
@@ -2256,13 +2257,22 @@ struct vduse_mgmt_dev {
 
  static struct vduse_mgmt_dev *vduse_mgmt;
 
-static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name)
+static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name,
+			       const struct vdpa_dev_set_config *config)
  {
  	struct vduse_vdpa *vdev;
 
  	if (dev->vdev)

drivers/vdpa/vdpa_user/vduse_dev.c struct vduse_mgmt_dev { · line 2275

Quoted 10 lines
drivers/vdpa/vdpa_user/vduse_dev.c +8 -0
  		return -EEXIST;
 
+	if (config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) {
+		if (config->device_features & ~dev->device_features)
+			return -EINVAL;
+		dev->supported_features = config->device_features;
+	} else {
+		dev->supported_features = dev->device_features;
+	}
+

Why this feature filter can't be done in the client (library) of vduse itself, similar to other device specific features of the existing vduse client? I thought those vduse clients are never managed by vdpa tool, while the device class can't be bound until client had registered with vduse. What is the point to define the feature bit in one place, but the value of the feature (for e.g. mac, mtu) is still or has to be provided by the client itself? Is it the right behavior to filter features in a separate layer rather than contain all relevant feature bits and attributes in one central location?

Regards,
-Siwei

Quoted 20 lines
drivers/vdpa/vdpa_user/vduse_dev.c +2 -1
  	vdev = vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev,
  				 &vduse_vdpa_config_ops, &vduse_map_ops,
  				 dev->ngroups, dev->nas, name, true);
@@ -2289,7 +2299,7 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
  		mutex_unlock(&vduse_lock);
  		return -EINVAL;
  	}
-	ret = vduse_dev_init_vdpa(dev, name);
+	ret = vduse_dev_init_vdpa(dev, name, config);
  	mutex_unlock(&vduse_lock);
  	if (ret)
  		return ret;
@@ -2376,6 +2386,7 @@ static int vduse_mgmtdev_init(void)
  	vduse_mgmt->mgmt_dev.id_table = id_table;
  	vduse_mgmt->mgmt_dev.ops = &vdpa_dev_mgmtdev_ops;
  	vduse_mgmt->mgmt_dev.device = &vduse_mgmt->dev;
+	vduse_mgmt->mgmt_dev.config_attr_mask = BIT_ULL(VDPA_ATTR_DEV_FEATURES);
  	ret = vdpa_mgmtdev_register(&vduse_mgmt->mgmt_dev);
  	if (ret)
  		device_unregister(&vduse_mgmt->dev);
author maintainer
#3 lore raw

Re: [RFC 1/2] vduse: support feature provisioning

Quoted 61 lines · Si-Wei Liu
Quoted 46 lines · Eugenio Pérez

This patch implements features provisioning for vduse devices. This allows the device provisioner to clear the features exposed by the userland device, so the driver never see them. The intended use case is to provision more than one different device with the same feature set, allowing live migration between them.

The device addition validates the provisioned features to be a subset of the parent features, as the rest of the backends.

---
  drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +4 -2
index 6c74282d5721..ef8fc795cfeb 100644
@@ -121,6 +121,7 @@ struct vduse_dev {
      bool connected;
      u64 api_version;
      u64 device_features;
+     u64 supported_features;
      u64 driver_features;
      u32 device_id;
      u32 vendor_id;
@@ -698,7 +699,7 @@ static u64 vduse_vdpa_get_device_features(struct vdpa_device *vdpa)
  {
      struct vduse_dev *dev = vdpa_to_vduse(vdpa);
 
-     return dev->device_features;
+     return dev->supported_features;
  }
 
  static int vduse_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 features)
@@ -2256,13 +2257,22 @@ struct vduse_mgmt_dev {
 
  static struct vduse_mgmt_dev *vduse_mgmt;
 
-static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name)
+static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name,
+                            const struct vdpa_dev_set_config *config)
  {
      struct vduse_vdpa *vdev;
 
      if (dev->vdev)

drivers/vdpa/vdpa_user/vduse_dev.c struct vduse_mgmt_dev { · line 2275

Quoted 10 lines
drivers/vdpa/vdpa_user/vduse_dev.c +8 -0
              return -EEXIST;
 
+     if (config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) {
+             if (config->device_features & ~dev->device_features)
+                     return -EINVAL;
+             dev->supported_features = config->device_features;
+     } else {
+             dev->supported_features = dev->device_features;
+     }
+

Why this feature filter can't be done in the client (library) of vduse

Quoted 9 lines

itself, similar to other device specific features of the existing vduse client? I thought those vduse clients are never managed by vdpa tool, while the device class can't be bound until client had registered with vduse. What is the point to define the feature bit in one place, but the value of the feature (for e.g. mac, mtu) is still or has to be provided by the client itself? Is it the right behavior to filter features in a separate layer rather than contain all relevant feature bits and attributes in one central location?

Maxime can expand on this, but the user of the vdpa command should not need to know if the backend device is VDUSE, HW, or other device: It should just call the vdpa command the same way, and expect the same results.

That also implies that it should handle the same way if a HW device has its own MAC address and then you set a different one with the vdpa command, but device_featues just came first in the pending list :).

author maintainer
#4 lore raw

RFC 2/2 vduse: allow to specify device-specific features if it's multiclass

In reply to Eugenio Pérez

Even if the device supports more than one class, there are ways to solve the ambiguity of which device are we creating. In the VDUSE case it is the name, for example.

RFC: I fon't understand 100% the motivation of this limitation, as the backend should be the one filtering out the invalid features if any.

---
 drivers/vdpa/vdpa.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/vdpa/vdpa.c +0 -9
index 34874beb0152..0fc32f3bd66f 100644
@@ -688,15 +688,6 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
 		err = -EINVAL;
 		goto err;
 	}
-	if (!(config.mask & VDPA_DEV_NET_ATTRS_MASK) &&
-	    config.mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES) &&
-	    classes & BIT_ULL(VIRTIO_ID_NET) && ncls > 1 &&
-	    config.device_features & VIRTIO_DEVICE_F_MASK) {
-		NL_SET_ERR_MSG_MOD(info->extack,
-				   "Management device supports multi-class while device features specified are ambiguous");
-		err = -EINVAL;
-		goto err;
-	}
 
 	err = mdev->ops->dev_add(mdev, name, &config);
 err:

--
2.51.0

#5 lore raw

Re: [RFC 2/2] vduse: allow to specify device-specific features if it's multiclass

Quoted 4 lines · Eugenio Pérez

Even if the device supports more than one class, there are ways to solve the ambiguity of which device are we creating. In the VDUSE case it is the name, for example.

This may only work for VDUSE but not other parents.

Quoted 3 lines

RFC: I fon't understand 100% the motivation of this limitation, as the backend should be the one filtering out the invalid features if any.

I think we can avoid these tricks. Currently, there's a one single mgmt device, this seems to be in-convenient. Could we have a per device mgmt device? For example, if user space creates vduse0, vdpa mgmtdev show may see vduse0 so we won't have this issue.

Quoted 27 lines
---
 drivers/vdpa/vdpa.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/vdpa/vdpa.c +0 -10
index 34874beb0152..0fc32f3bd66f 100644
@@ -688,15 +688,6 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
                err = -EINVAL;
                goto err;
        }
-       if (!(config.mask & VDPA_DEV_NET_ATTRS_MASK) &&
-           config.mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES) &&
-           classes & BIT_ULL(VIRTIO_ID_NET) && ncls > 1 &&
-           config.device_features & VIRTIO_DEVICE_F_MASK) {
-               NL_SET_ERR_MSG_MOD(info->extack,
-                                  "Management device supports multi-class while device features specified are ambiguous");
-               err = -EINVAL;
-               goto err;
-       }
 
        err = mdev->ops->dev_add(mdev, name, &config);
 err:
--
Quoted 2 lines

2.51.0

Thanks

#6 lore raw

Re: [RFC 2/2] vduse: allow to specify device-specific features if it's multiclass

Quoted 10 lines · Jason Wang
Quoted 4 lines · Eugenio Pérez

Even if the device supports more than one class, there are ways to solve the ambiguity of which device are we creating. In the VDUSE case it is the name, for example.

This may only work for VDUSE but not other parents.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

RFC: I fon't understand 100% the motivation of this limitation, as the backend should be the one filtering out the invalid features if any.

I think we can avoid these tricks. Currently, there's a one single mgmt device, this seems to be in-convenient. Could we have a per device mgmt device? For example, if user space creates vduse0, vdpa mgmtdev show may see vduse0 so we won't have this issue.

Or if we specify the class, there won't be ambiguity.

Thanks

Quoted 32 lines
Quoted 28 lines
---
 drivers/vdpa/vdpa.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/vdpa/vdpa.c +0 -10
index 34874beb0152..0fc32f3bd66f 100644
@@ -688,15 +688,6 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
                err = -EINVAL;
                goto err;
        }
-       if (!(config.mask & VDPA_DEV_NET_ATTRS_MASK) &&
-           config.mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES) &&
-           classes & BIT_ULL(VIRTIO_ID_NET) && ncls > 1 &&
-           config.device_features & VIRTIO_DEVICE_F_MASK) {
-               NL_SET_ERR_MSG_MOD(info->extack,
-                                  "Management device supports multi-class while device features specified are ambiguous");
-               err = -EINVAL;
-               goto err;
-       }
 
        err = mdev->ops->dev_add(mdev, name, &config);
 err:
--
Quoted 2 lines

2.51.0

Thanks