linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mdev: Send uevents around parent device registration
@ 2019-07-01 14:54 Alex Williamson
  2019-07-01 15:06 ` Cornelia Huck
  2019-07-01 17:13 ` Kirti Wankhede
  0 siblings, 2 replies; 16+ messages in thread
From: Alex Williamson @ 2019-07-01 14:54 UTC (permalink / raw)
  To: kwankhede, alex.williamson, cohuck; +Cc: kvm, linux-kernel

This allows udev to trigger rules when a parent device is registered
or unregistered from mdev.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

v2: Don't remove the dev_info(), Kirti requested they stay and
    removing them is only tangential to the goal of this change.

 drivers/vfio/mdev/mdev_core.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index ae23151442cb..7fb268136c62 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -146,6 +146,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
 {
 	int ret;
 	struct mdev_parent *parent;
+	char *env_string = "MDEV_STATE=registered";
+	char *envp[] = { env_string, NULL };
 
 	/* check for mandatory ops */
 	if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
@@ -197,6 +199,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
 	mutex_unlock(&parent_list_lock);
 
 	dev_info(dev, "MDEV: Registered\n");
+	kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
+
 	return 0;
 
 add_dev_err:
@@ -220,6 +224,8 @@ EXPORT_SYMBOL(mdev_register_device);
 void mdev_unregister_device(struct device *dev)
 {
 	struct mdev_parent *parent;
+	char *env_string = "MDEV_STATE=unregistered";
+	char *envp[] = { env_string, NULL };
 
 	mutex_lock(&parent_list_lock);
 	parent = __find_parent_device(dev);
@@ -243,6 +249,8 @@ void mdev_unregister_device(struct device *dev)
 	up_write(&parent->unreg_sem);
 
 	mdev_put_parent(parent);
+
+	kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
 }
 EXPORT_SYMBOL(mdev_unregister_device);
 


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-07-02 18:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-01 14:54 [PATCH v2] mdev: Send uevents around parent device registration Alex Williamson
2019-07-01 15:06 ` Cornelia Huck
2019-07-01 17:13 ` Kirti Wankhede
2019-07-01 17:24   ` Alex Williamson
2019-07-01 17:50     ` Kirti Wankhede
2019-07-01 20:04       ` Alex Williamson
2019-07-02  4:55         ` Kirti Wankhede
2019-07-02  5:42           ` Alex Williamson
2019-07-02  7:13             ` Parav Pandit
2019-07-02 12:47               ` Kirti Wankhede
2019-07-02 13:08                 ` Alex Williamson
2019-07-02 13:40                   ` Kirti Wankhede
2019-07-02 14:43                     ` Alex Williamson
2019-07-02 18:04                       ` Kirti Wankhede
2019-07-02 18:31                         ` Alex Williamson
2019-07-02  5:46           ` Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).