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

Re: [Xen-devel] [PATCH 2.6.12.6-xen] sysfs attributes for xen

To: "Mike D. Day" <ncmike@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 2.6.12.6-xen] sysfs attributes for xen
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Fri, 27 Jan 2006 21:03:17 -0600
Cc: Greg KH <greg@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, lkml <linux-kernel@xxxxxxxxxxxxxxx>
Delivery-date: Sat, 28 Jan 2006 03:12:34 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <43DAD4DB.4090708@xxxxxxxxxx>
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: <43DAD4DB.4090708@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051013)
Comments inlined.

Mike D. Day wrote:

Creates /sys/hypervisor/xen and populates that dir with xen version, changeset, compilation, and capabilities info. Intended for the xen merge tree and later upstream.

<snip>

+    if( 0 ==  (err = subsystem_register(&hypervisor_subsys)) ) {

This formatting is off. You want a space after the if and no space after the (. See CodingStyle. It could be your mailer (it munged the newlines) but it appears you've got 4 space tabs? Linux style is 8.

+ if( ! HYPERVISOR_xen_version(XENVER_extraversion, + extra_version) ) {
+            page[PAGE_SIZE - 1] = 0x00;
+ return snprintf(page, PAGE_SIZE - 1, + "xen-%ld.%ld%s\n",
+                    major, minor, extra_version);

snprintf takes into account the terminating byte so you don't have to.

<snip>

+/* xen compile info */
+static ssize_t xen_compile_show(struct kobject * kobj, + struct attribute * attr, + char * page)
+{
+    struct xen_compile_info info;
+ + if( 0 == HYPERVISOR_xen_version(XENVER_compile_info, &info) ) {
+        page[PAGE_SIZE - 1] = 0x00;
+ return snprintf(page, PAGE_SIZE - 1, + "compiled by %s, using %s, on %s\n", + info.compile_by, + info.compile_date, + info.compiler);
+    }
+    return 0;
+}

I'm not the best person to speak to this but I'm pretty sure sysfs prefers single values per file so you probably want to split this up into compile_by, compile_date, compiler.

+int __init
+sysfs_xen_version_init(void)
+{
+    __label__  out;
+ + struct kset * parent = get_xen_kset();
+    if ( parent != NULL ) {
+        kobject_init(&xen_ver_obj);
+ xen_ver_obj.parent = &parent->kobj; + xen_ver_obj.dentry = parent->kobj.dentry;
+        kobject_get(&parent->kobj);
+        if ( sysfs_create_file(&xen_ver_obj, &xen_ver_attr.attr) )
+            goto out;

I reckon you want to use default attributes here instead of immediately calling sysfs_create_file().

Regards,

Anthony Liguori

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