ia64/xen-unstable

changeset 10586:bd4080876297

New /sys/hypervisor/uuid, containing this domain's UUID.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Jun 28 21:03:25 2006 +0100 (2006-06-28)
parents d49e5cc672eb
children 4b45f7f62dc7
files linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Wed Jun 28 20:46:01 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Wed Jun 28 21:03:25 2006 +0100
     1.3 @@ -8,12 +8,14 @@
     1.4   */
     1.5  
     1.6  #include <linux/config.h>
     1.7 +#include <linux/err.h>
     1.8  #include <linux/kernel.h>
     1.9  #include <linux/module.h>
    1.10  #include <linux/init.h>
    1.11  #include <asm/hypervisor.h>
    1.12  #include <xen/features.h>
    1.13  #include <xen/hypervisor_sysfs.h>
    1.14 +#include <xen/xenbus.h>
    1.15  
    1.16  MODULE_LICENSE("GPL");
    1.17  MODULE_AUTHOR("Mike D. Day <ncmike@us.ibm.com>");
    1.18 @@ -97,6 +99,37 @@ static void xen_sysfs_version_destroy(vo
    1.19  	sysfs_remove_group(&hypervisor_subsys.kset.kobj, &version_group);
    1.20  }
    1.21  
    1.22 +/* UUID */
    1.23 +
    1.24 +static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
    1.25 +{
    1.26 +	char *vm, *val;
    1.27 +	int ret;
    1.28 +
    1.29 +	vm = xenbus_read(XBT_NIL, "vm", "", NULL);
    1.30 +	if (IS_ERR(vm))
    1.31 +		return PTR_ERR(vm);
    1.32 +	val = xenbus_read(XBT_NIL, vm, "uuid", NULL);
    1.33 +	kfree(vm);
    1.34 +	if (IS_ERR(val))
    1.35 +		return PTR_ERR(val);
    1.36 +	ret = sprintf(buffer, "%s\n", val);
    1.37 +	kfree(val);
    1.38 +	return ret;
    1.39 +}
    1.40 +
    1.41 +HYPERVISOR_ATTR_RO(uuid);
    1.42 +
    1.43 +static int __init xen_sysfs_uuid_init(void)
    1.44 +{
    1.45 +	return sysfs_create_file(&hypervisor_subsys.kset.kobj, &uuid_attr.attr);
    1.46 +}
    1.47 +
    1.48 +static void xen_sysfs_uuid_destroy(void)
    1.49 +{
    1.50 +	sysfs_remove_file(&hypervisor_subsys.kset.kobj, &uuid_attr.attr);
    1.51 +}
    1.52 +
    1.53  /* xen compilation attributes */
    1.54  
    1.55  static ssize_t compiler_show(struct hyp_sysfs_attr *attr, char *buffer)
    1.56 @@ -314,10 +347,15 @@ static int __init hyper_sysfs_init(void)
    1.57  	ret = xen_compilation_init();
    1.58  	if (ret)
    1.59  		goto comp_out;
    1.60 +	ret = xen_sysfs_uuid_init();
    1.61 +	if (ret)
    1.62 +		goto uuid_out;
    1.63  	ret = xen_properties_init();
    1.64  	if (!ret)
    1.65  		goto out;
    1.66  
    1.67 +	xen_sysfs_uuid_destroy();
    1.68 +uuid_out:
    1.69  	xen_compilation_destroy();
    1.70  comp_out:
    1.71  	xen_sysfs_version_destroy();
    1.72 @@ -331,6 +369,7 @@ static void hyper_sysfs_exit(void)
    1.73  {
    1.74  	xen_properties_destroy();
    1.75  	xen_compilation_destroy();
    1.76 +	xen_sysfs_uuid_destroy();
    1.77  	xen_sysfs_version_destroy();
    1.78  	xen_sysfs_type_destroy();
    1.79