Skip to content

Commit 076e2ce

Browse files
joejin00Boris Ostrovsky
authored andcommitted
xen: export device state to sysfs
Export device state to sysfs to allow for easier get device state. Signed-off-by: Joe Jin <joe.jin@oracle.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Juergen Gross <jgross@suse.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
1 parent b2d7a07 commit 076e2ce

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Documentation/ABI/stable/sysfs-bus-xen-backend

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,12 @@ KernelVersion: 3.0
7373
Contact: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7474
Description:
7575
Number of sectors written by the frontend.
76+
77+
What: /sys/bus/xen-backend/devices/*/state
78+
Date: August 2018
79+
KernelVersion: 4.19
80+
Contact: Joe Jin <joe.jin@oracle.com>
81+
Description:
82+
The state of the device. One of: 'Unknown',
83+
'Initialising', 'Initialised', 'Connected', 'Closing',
84+
'Closed', 'Reconfiguring', 'Reconfigured'.

drivers/xen/xenbus/xenbus_probe.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,19 @@ static ssize_t modalias_show(struct device *dev,
402402
}
403403
static DEVICE_ATTR_RO(modalias);
404404

405+
static ssize_t state_show(struct device *dev,
406+
struct device_attribute *attr, char *buf)
407+
{
408+
return sprintf(buf, "%s\n",
409+
xenbus_strstate(to_xenbus_device(dev)->state));
410+
}
411+
static DEVICE_ATTR_RO(state);
412+
405413
static struct attribute *xenbus_dev_attrs[] = {
406414
&dev_attr_nodename.attr,
407415
&dev_attr_devtype.attr,
408416
&dev_attr_modalias.attr,
417+
&dev_attr_state.attr,
409418
NULL,
410419
};
411420

0 commit comments

Comments
 (0)