Thread (6 messages) 6 messages, 2 authors, 2025-11-19

Re: [PATCH v5 2/2] vhost: switch to arrays of feature bits

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: 2025-11-19 12:35:06
Also in: kvm, linux-doc, lkml, virtualization

On Wed, Nov 19, 2025 at 12:04:12PM +0100, Paolo Abeni wrote:
On 11/19/25 7:55 AM, Michael S. Tsirkin wrote:
quoted
@@ -1720,6 +1720,7 @@ static long vhost_net_set_owner(struct vhost_net *n)
 static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
 			    unsigned long arg)
 {
+	const DEFINE_VHOST_FEATURES_ARRAY(features_array, vhost_net_features);
I'm sorry for the late feedback, I was drowning in other stuff.

I have just a couple of non blocking suggestions, feel free to ignore.

I think that if you rename `vhost_net_features` as
`vhost_net_features_bits` and `features_array` as `vhost_net_features`
the diffstat could be smaller and possibly clearer.
quoted
 	u64 all_features[VIRTIO_FEATURES_U64S];
 	struct vhost_net *n = f->private_data;
 	void __user *argp = (void __user *)arg;
@@ -1734,14 +1735,14 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
 			return -EFAULT;
 		return vhost_net_set_backend(n, backend.index, backend.fd);
 	case VHOST_GET_FEATURES:
-		features = vhost_net_features[0];
+		features = VHOST_FEATURES_U64(vhost_net_features, 0);
Here and below you could use directly:

		features = features_array[0];

Ah. Good point.

if you apply the rename mentioned above, this chunk and the following 3
should not be needed.

[...]> diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
quoted
index 42c955a5b211..af727fccfe40 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -308,6 +308,12 @@ static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd)
 	return r;
 }
 
+static const int vhost_test_features[] = {
+	VHOST_FEATURES
+};
+
+#define VHOST_TEST_FEATURES VHOST_FEATURES_U64(vhost_test_features, 0)
If you rename `VHOST_FEATURES` to `VHOST_FEATURES_BITS` and
`VHOST_TEST_FEATURES` to `VHOST_FEATURES`,
This one I don't want to do, people tend to copy/paste code
and this is not what devices should be doing.
the following two chunks
should not be needed.

Thanks,

Paolo
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help