2006-05-04 14:01:38

by Michael Holzheu

[permalink] [raw]
Subject: [PATCH 2/3] Add /sys/hypervisor subsystem

To have a home for all hypervisors, this patch
creates /sys/hypervisor.

Acked-by: Martin Schwidefsky <[email protected]>
Signed-off-by: Michael Holzheu <[email protected]>

---

include/linux/kobject.h | 2 ++
kernel/ksysfs.c | 26 +++++++++++++++++++++-----

diff -urpN linux-2.6.16-hypfs-2006-04-28-update2/include/linux/kobject.h linux-2.6.16-hypfs-2006-04-28-update3/include/linux/kobject.h
--- linux-2.6.16-hypfs-2006-04-28-update2/include/linux/kobject.h 2006-05-04 10:22:37.000000000 +0200
+++ linux-2.6.16-hypfs-2006-04-28-update3/include/linux/kobject.h 2006-05-04 10:29:47.000000000 +0200
@@ -186,6 +186,8 @@ struct subsystem _varname##_subsys = { \

/* The global /sys/kernel/ subsystem for people to chain off of */
extern struct subsystem kernel_subsys;
+/* The global /sys/hypervisor/ subsystem */
+extern struct subsystem hypervisor_subsys;

/**
* Helpers for setting the kset of registered objects.
diff -urpN linux-2.6.16-hypfs-2006-04-28-update2/kernel/ksysfs.c linux-2.6.16-hypfs-2006-04-28-update3/kernel/ksysfs.c
--- linux-2.6.16-hypfs-2006-04-28-update2/kernel/ksysfs.c 2006-05-04 10:22:38.000000000 +0200
+++ linux-2.6.16-hypfs-2006-04-28-update3/kernel/ksysfs.c 2006-05-04 10:30:03.000000000 +0200
@@ -53,6 +53,8 @@ KERNEL_ATTR_RW(uevent_helper);

decl_subsys(kernel, NULL, NULL);
EXPORT_SYMBOL_GPL(kernel_subsys);
+decl_subsys(hypervisor, NULL, NULL);
+EXPORT_SYMBOL_GPL(hypervisor_subsys);

static struct attribute * kernel_attrs[] = {
#ifdef CONFIG_HOTPLUG
@@ -68,12 +70,26 @@ static struct attribute_group kernel_att

static int __init ksysfs_init(void)
{
- int error = subsystem_register(&kernel_subsys);
- if (!error)
- error = sysfs_create_group(&kernel_subsys.kset.kobj,
- &kernel_attr_group);
+ int rc;

- return error;
+ rc = subsystem_register(&hypervisor_subsys);
+ if (rc)
+ goto fail_hyp;
+ rc = subsystem_register(&kernel_subsys);
+ if (rc)
+ goto fail_kernel;
+ rc = sysfs_create_group(&kernel_subsys.kset.kobj,
+ &kernel_attr_group);
+ if (rc)
+ goto fail_group;
+ return 0;
+
+fail_group:
+ subsystem_unregister(&kernel_subsys);
+fail_kernel:
+ subsystem_unregister(&hypervisor_subsys);
+fail_hyp:
+ return rc;
}

core_initcall(ksysfs_init);