Commit f4660cc9 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Greg Kroah-Hartman

vhost/vsock: use static minor number

Vhost-vsock is a software device so there is no probe call that causes
the driver to register its misc char device node.  This creates a
chicken and egg problem: userspace applications must open
/dev/vhost-vsock to use the driver but the file doesn't exist until the
kernel module has been loaded.

Use the devname modalias mechanism so that /dev/vhost-vsock is created
at boot.  The vhost_vsock kernel module is automatically loaded when the
first application opens /dev/host-vsock.

Note that the "reserved for local use" range in
Documentation/admin-guide/devices.txt is incorrect.  The userio driver
already occupies part of that range.  I've updated the documentation
accordingly.

Cc: device@lanana.org
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ff35eb23
...@@ -369,8 +369,10 @@ ...@@ -369,8 +369,10 @@
237 = /dev/loop-control Loopback control device 237 = /dev/loop-control Loopback control device
238 = /dev/vhost-net Host kernel accelerator for virtio net 238 = /dev/vhost-net Host kernel accelerator for virtio net
239 = /dev/uhid User-space I/O driver support for HID subsystem 239 = /dev/uhid User-space I/O driver support for HID subsystem
240 = /dev/userio Serio driver testing device
241 = /dev/vhost-vsock Host kernel driver for virtio vsock
240-254 Reserved for local use 242-254 Reserved for local use
255 Reserved for MISC_DYNAMIC_MINOR 255 Reserved for MISC_DYNAMIC_MINOR
11 char Raw keyboard device (Linux/SPARC only) 11 char Raw keyboard device (Linux/SPARC only)
......
...@@ -706,7 +706,7 @@ static const struct file_operations vhost_vsock_fops = { ...@@ -706,7 +706,7 @@ static const struct file_operations vhost_vsock_fops = {
}; };
static struct miscdevice vhost_vsock_misc = { static struct miscdevice vhost_vsock_misc = {
.minor = MISC_DYNAMIC_MINOR, .minor = VHOST_VSOCK_MINOR,
.name = "vhost-vsock", .name = "vhost-vsock",
.fops = &vhost_vsock_fops, .fops = &vhost_vsock_fops,
}; };
...@@ -778,3 +778,5 @@ module_exit(vhost_vsock_exit); ...@@ -778,3 +778,5 @@ module_exit(vhost_vsock_exit);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Asias He"); MODULE_AUTHOR("Asias He");
MODULE_DESCRIPTION("vhost transport for vsock "); MODULE_DESCRIPTION("vhost transport for vsock ");
MODULE_ALIAS_MISCDEV(VHOST_VSOCK_MINOR);
MODULE_ALIAS("devname:vhost-vsock");
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#define VHOST_NET_MINOR 238 #define VHOST_NET_MINOR 238
#define UHID_MINOR 239 #define UHID_MINOR 239
#define USERIO_MINOR 240 #define USERIO_MINOR 240
#define VHOST_VSOCK_MINOR 241
#define MISC_DYNAMIC_MINOR 255 #define MISC_DYNAMIC_MINOR 255
struct device; struct device;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment