xen/sysfs: Use XENVER_guest_handle to query UUID
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 16 Aug 2012 20:40:26 +0000 (16:40 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 23 Aug 2012 14:16:18 +0000 (10:16 -0400)
This hypercall has been present since Xen 3.1, and is the preferred
method for a domain to obtain its UUID. Fall back to the xenstore method
if using an older version of Xen (which returns -ENOSYS).

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/sys-hypervisor.c
include/xen/interface/version.h

index fdb6d22..5e5ad7e 100644 (file)
@@ -114,7 +114,7 @@ static void xen_sysfs_version_destroy(void)
 
 /* UUID */
 
-static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
+static ssize_t uuid_show_fallback(struct hyp_sysfs_attr *attr, char *buffer)
 {
        char *vm, *val;
        int ret;
@@ -135,6 +135,17 @@ static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
        return ret;
 }
 
+static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       xen_domain_handle_t uuid;
+       int ret;
+       ret = HYPERVISOR_xen_version(XENVER_guest_handle, uuid);
+       if (ret)
+               return uuid_show_fallback(attr, buffer);
+       ret = sprintf(buffer, "%pU\n", uuid);
+       return ret;
+}
+
 HYPERVISOR_ATTR_RO(uuid);
 
 static int __init xen_sysfs_uuid_init(void)
index e8b6519..dd58cf5 100644 (file)
@@ -60,4 +60,7 @@ struct xen_feature_info {
 /* arg == NULL; returns host memory page size. */
 #define XENVER_pagesize 7
 
+/* arg == xen_domain_handle_t. */
+#define XENVER_guest_handle 8
+
 #endif /* __XEN_PUBLIC_VERSION_H__ */