Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio: allow drivers to validate features

Some drivers can't support all features in all configurations. At the
moment we blindly set FEATURES_OK and later FAILED. Support this better
by adding a callback drivers can use to do some early checks.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

+7
+6
drivers/virtio/virtio.c
··· 232 232 if (device_features & (1ULL << i)) 233 233 __virtio_set_bit(dev, i); 234 234 235 + if (drv->validate) { 236 + err = drv->validate(dev); 237 + if (err) 238 + goto err; 239 + } 240 + 235 241 err = virtio_finalize_features(dev); 236 242 if (err) 237 243 goto err;
+1
include/linux/virtio.h
··· 167 167 unsigned int feature_table_size; 168 168 const unsigned int *feature_table_legacy; 169 169 unsigned int feature_table_size_legacy; 170 + int (*validate)(struct virtio_device *dev); 170 171 int (*probe)(struct virtio_device *dev); 171 172 void (*scan)(struct virtio_device *dev); 172 173 void (*remove)(struct virtio_device *dev);