mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
node_device: refactor udevProcessCCW
Refactor out CCW address parsing for later reuse. Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
This commit is contained in:
parent
af16e754cd
commit
0e7f8bb6c1
@ -1058,27 +1058,38 @@ udevProcessMediatedDevice(struct udev_device *dev,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udevProcessCCW(struct udev_device *device,
|
udevGetCCWAddress(const char *sysfs_path,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDevCapDataPtr data)
|
||||||
{
|
{
|
||||||
int online;
|
|
||||||
char *p;
|
char *p;
|
||||||
virNodeDevCapDataPtr data = &def->caps->data;
|
|
||||||
|
|
||||||
/* process only online devices to keep the list sane */
|
if ((p = strrchr(sysfs_path, '/')) == NULL ||
|
||||||
if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((p = strrchr(def->sysfs_path, '/')) == NULL ||
|
|
||||||
virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.cssid) < 0 || p == NULL ||
|
virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.cssid) < 0 || p == NULL ||
|
||||||
virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.ssid) < 0 || p == NULL ||
|
virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.ssid) < 0 || p == NULL ||
|
||||||
virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.devno) < 0) {
|
virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.devno) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to parse the CCW address from sysfs path: '%s'"),
|
_("failed to parse the CCW address from sysfs path: '%s'"),
|
||||||
def->sysfs_path);
|
sysfs_path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
udevProcessCCW(struct udev_device *device,
|
||||||
|
virNodeDeviceDefPtr def)
|
||||||
|
{
|
||||||
|
int online;
|
||||||
|
|
||||||
|
/* process only online devices to keep the list sane */
|
||||||
|
if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (udevGenerateDeviceName(device, def, NULL) != 0)
|
if (udevGenerateDeviceName(device, def, NULL) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user