sys-hypervisor.c (0cce284537fb42d9c28b9b31038ffc9b464555f5) sys-hypervisor.c (4a4c29c96dde0eefd69054fd9e6b4255d4717799)
1/*
2 * copyright (c) 2006 IBM Corporation
3 * Authored by: Mike D. Day <ncmike@us.ibm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */

--- 36 unchanged lines hidden (view full) ---

45
46HYPERVISOR_ATTR_RO(type);
47
48static int __init xen_sysfs_type_init(void)
49{
50 return sysfs_create_file(hypervisor_kobj, &type_attr.attr);
51}
52
1/*
2 * copyright (c) 2006 IBM Corporation
3 * Authored by: Mike D. Day <ncmike@us.ibm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */

--- 36 unchanged lines hidden (view full) ---

45
46HYPERVISOR_ATTR_RO(type);
47
48static int __init xen_sysfs_type_init(void)
49{
50 return sysfs_create_file(hypervisor_kobj, &type_attr.attr);
51}
52
53static ssize_t guest_type_show(struct hyp_sysfs_attr *attr, char *buffer)
54{
55 const char *type;
56
57 switch (xen_domain_type) {
58 case XEN_NATIVE:
59 /* ARM only. */
60 type = "Xen";
61 break;
62 case XEN_PV_DOMAIN:
63 type = "PV";
64 break;
65 case XEN_HVM_DOMAIN:
66 type = xen_pvh_domain() ? "PVH" : "HVM";
67 break;
68 default:
69 return -EINVAL;
70 }
71
72 return sprintf(buffer, "%s\n", type);
73}
74
75HYPERVISOR_ATTR_RO(guest_type);
76
77static int __init xen_sysfs_guest_type_init(void)
78{
79 return sysfs_create_file(hypervisor_kobj, &guest_type_attr.attr);
80}
81
53/* xen version attributes */
54static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
55{
56 int version = HYPERVISOR_xen_version(XENVER_version, NULL);
57 if (version)
58 return sprintf(buffer, "%d\n", version >> 16);
59 return -ENODEV;
60}

--- 405 unchanged lines hidden (view full) ---

466 int ret;
467
468 if (!xen_domain())
469 return -ENODEV;
470
471 ret = xen_sysfs_type_init();
472 if (ret)
473 goto out;
82/* xen version attributes */
83static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
84{
85 int version = HYPERVISOR_xen_version(XENVER_version, NULL);
86 if (version)
87 return sprintf(buffer, "%d\n", version >> 16);
88 return -ENODEV;
89}

--- 405 unchanged lines hidden (view full) ---

495 int ret;
496
497 if (!xen_domain())
498 return -ENODEV;
499
500 ret = xen_sysfs_type_init();
501 if (ret)
502 goto out;
503 ret = xen_sysfs_guest_type_init();
504 if (ret)
505 goto guest_type_out;
474 ret = xen_sysfs_version_init();
475 if (ret)
476 goto version_out;
477 ret = xen_sysfs_compilation_init();
478 if (ret)
479 goto comp_out;
480 ret = xen_sysfs_uuid_init();
481 if (ret)

--- 15 unchanged lines hidden (view full) ---

497
498prop_out:
499 sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr);
500uuid_out:
501 sysfs_remove_group(hypervisor_kobj, &xen_compilation_group);
502comp_out:
503 sysfs_remove_group(hypervisor_kobj, &version_group);
504version_out:
506 ret = xen_sysfs_version_init();
507 if (ret)
508 goto version_out;
509 ret = xen_sysfs_compilation_init();
510 if (ret)
511 goto comp_out;
512 ret = xen_sysfs_uuid_init();
513 if (ret)

--- 15 unchanged lines hidden (view full) ---

529
530prop_out:
531 sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr);
532uuid_out:
533 sysfs_remove_group(hypervisor_kobj, &xen_compilation_group);
534comp_out:
535 sysfs_remove_group(hypervisor_kobj, &version_group);
536version_out:
537 sysfs_remove_file(hypervisor_kobj, &guest_type_attr.attr);
538guest_type_out:
505 sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
506out:
507 return ret;
508}
509device_initcall(hyper_sysfs_init);
510
511static ssize_t hyp_sysfs_show(struct kobject *kobj,
512 struct attribute *attr,

--- 39 unchanged lines hidden ---
539 sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
540out:
541 return ret;
542}
543device_initcall(hyper_sysfs_init);
544
545static ssize_t hyp_sysfs_show(struct kobject *kobj,
546 struct attribute *attr,

--- 39 unchanged lines hidden ---