Directories in /sys/jailhouse/cells/ formerly represented cell names.

This patch changes the structure. From now on, /sys/jailhouse/cells/
will contain cell ids. The name of a specific cell is provided through
/sys/jailhouse/cells/<id>/name.

This makes the sysfs interface easier to be parsed by applications.

Additionally, amend documentation and jailhouse-cell-list.

Signed-off-by: Ralf Ramsauer <r...@ramses-pyramidenbau.de>

diff --git a/Documentation/sysfs-entries.txt b/Documentation/sysfs-entries.txt
index 2845220..0fc315a 100644
--- a/Documentation/sysfs-entries.txt
+++ b/Documentation/sysfs-entries.txt
@@ -11,8 +11,8 @@ can be used for monitoring the state of the hypervisor and 
its cells.
 |- remap_pool_size              - number of pages in hypervisor remapping pool
 |- remap_pool_used              - used pages of hypervisor remapping pool
 `- cells
-   |- <name of cell>
-   |  |- id                     - unique numerical ID
+   |- <id>                      - unique numerical ID
+   |  |- name                   - cell name
    |  |- state                  - "running", "running/locked", "shut down", or
    |  |                           "failed"
    |  |- cpus_assigned          - bitmask of assigned logical CPUs
diff --git a/driver/sysfs.c b/driver/sysfs.c
index a18c2b9..960c7b3 100644
--- a/driver/sysfs.c
+++ b/driver/sysfs.c
@@ -139,12 +139,12 @@ static struct attribute_group stats_attr_group = {
        .name = "statistics"
 };
 
-static ssize_t id_show(struct kobject *kobj, struct kobj_attribute *attr,
-                      char *buffer)
+static ssize_t name_show(struct kobject *kobj, struct kobj_attribute *attr,
+                               char *buffer)
 {
        struct cell *cell = container_of(kobj, struct cell, kobj);
 
-       return sprintf(buffer, "%u\n", cell->id);
+       return sprintf(buffer, "%s\n", cell->name);
 }
 
 static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
@@ -212,14 +212,14 @@ static ssize_t cpus_failed_show(struct kobject *kobj,
        return written;
 }
 
-static struct kobj_attribute cell_id_attr = __ATTR_RO(id);
+static struct kobj_attribute cell_name_attr = __ATTR_RO(name);
 static struct kobj_attribute cell_state_attr = __ATTR_RO(state);
 static struct kobj_attribute cell_cpus_assigned_attr =
        __ATTR_RO(cpus_assigned);
 static struct kobj_attribute cell_cpus_failed_attr = __ATTR_RO(cpus_failed);
 
 static struct attribute *cell_attrs[] = {
-       &cell_id_attr.attr,
+       &cell_name_attr.attr,
        &cell_state_attr.attr,
        &cell_cpus_assigned_attr.attr,
        &cell_cpus_failed_attr.attr,
@@ -236,8 +236,8 @@ int jailhouse_sysfs_cell_create(struct cell *cell)
 {
        int err;
 
-       err = kobject_init_and_add(&cell->kobj, &cell_type, cells_dir, "%s",
-                                  cell->name);
+       err = kobject_init_and_add(&cell->kobj, &cell_type, cells_dir, "%u",
+                                  cell->id);
        if (err) {
                jailhouse_cell_kobj_release(&cell->kobj);
                return err;
diff --git a/tools/jailhouse-cell-list b/tools/jailhouse-cell-list
index 3b5bc20..d4123f6 100755
--- a/tools/jailhouse-cell-list
+++ b/tools/jailhouse-cell-list
@@ -54,8 +54,8 @@ if len(sys.argv) > 1:
 cells = []
 for cell_path in glob.glob('/sys/devices/jailhouse/cells/*'):
     cells.append({
-        'name': os.path.basename(cell_path),
-        'id': open(cell_path + "/id").readline().strip(),
+        'id': os.path.basename(cell_path),
+        'name': open(cell_path + "/name").readline().strip(),
         'state': open(cell_path + "/state").readline().strip(),
         'cpus_assigned': read_cpus(cell_path + "/cpus_assigned"),
         'cpus_failed': read_cpus(cell_path + "/cpus_failed")
-- 
2.9.2

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to