WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] /sys/hypervisor/uuid

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Re: [PATCH] /sys/hypervisor/uuid
From: Markus Armbruster <armbru@xxxxxxxxxx>
Date: Wed, 24 May 2006 15:00:55 +0200
Delivery-date: Wed, 24 May 2006 06:01:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <87y7wzmeqb.fsf@xxxxxxxxxxxxxxxxx> (Markus Armbruster's message of "Thu, 18 May 2006 19:20:44 +0200")
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <87y7wzmeqb.fsf@xxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)
New /sys/hypervisor/uuid, containing this domain's UUID.

Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>

---
Second try, using the newly available /vm/<UUID>/uuid key.

diff -r ddba92a5cba9 drivers/xen/core/xen_sysfs.c
--- a/drivers/xen/core/xen_sysfs.c      Tue May 09 12:41:38 2006 +0200
+++ b/drivers/xen/core/xen_sysfs.c      Wed May 24 14:53:25 2006 +0200
@@ -8,12 +8,14 @@
  */
 
 #include <linux/config.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <asm/hypervisor.h>
 #include <xen/features.h>
 #include <xen/hypervisor_sysfs.h>
+#include <xen/xenbus.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Mike D. Day <ncmike@xxxxxxxxxx>");
@@ -92,6 +94,37 @@ static void xen_sysfs_version_destroy(vo
 static void xen_sysfs_version_destroy(void)
 {
        sysfs_remove_group(&hypervisor_subsys.kset.kobj, &version_group);
+}
+
+/* UUID */
+
+static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       char *vm, *val;
+       int ret;
+
+       vm = xenbus_read(XBT_NULL, "vm", "", NULL);
+       if (IS_ERR(vm))
+               return PTR_ERR(vm);
+       val = xenbus_read(XBT_NULL, vm, "uuid", NULL);
+       kfree(vm);
+       if (IS_ERR(val))
+               return PTR_ERR(val);
+       ret = sprintf(buffer, "%s\n", val);
+       kfree(val);
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(uuid);
+
+static int __init xen_sysfs_uuid_init(void)
+{
+       return sysfs_create_file(&hypervisor_subsys.kset.kobj, &uuid_attr.attr);
+}
+
+static void xen_sysfs_uuid_destroy(void)
+{
+       sysfs_remove_file(&hypervisor_subsys.kset.kobj, &uuid_attr.attr);
 }
 
 /* xen compilation attributes */
@@ -285,10 +318,15 @@ static int __init hyper_sysfs_init(void)
        ret = xen_compilation_init();
        if (ret)
                goto comp_out;
+       ret = xen_sysfs_uuid_init();
+       if (ret)
+               goto uuid_out;
        ret = xen_properties_init();
        if (!ret)
                goto out;
 
+       xen_sysfs_uuid_destroy();
+uuid_out:
        xen_compilation_destroy();
 comp_out:
        xen_sysfs_version_destroy();
@@ -302,6 +340,7 @@ static void hyper_sysfs_exit(void)
 {
        xen_properties_destroy();
        xen_compilation_destroy();
+       xen_sysfs_uuid_destroy();
        xen_sysfs_version_destroy();
        xen_sysfs_type_destroy();
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel