libvirt/SOURCES/libvirt-node_device-detect-CSS-devices.patch
2021-09-10 11:58:37 +00:00

262 lines
9.2 KiB
Diff

From 7604b24349c47ff008b1366eb19fc2959614fb71 Mon Sep 17 00:00:00 2001
Message-Id: <7604b24349c47ff008b1366eb19fc2959614fb71@dist-git>
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date: Thu, 8 Oct 2020 11:06:57 -0400
Subject: [PATCH] node_device: detect CSS devices
Make channel subsystem (CSS) devices available in the node_device driver.
The CCS devices reside in the computer system and provide CCW devices, e.g.:
+- css_0_0_003a
|
+- ccw_0_0_1a2b
|
+- scsi_host0
|
+- scsi_target0_0_0
|
+- scsi_0_0_0_0
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
(cherry picked from commit 05e6cdafa6e083a1d83e1f2e34b6472c60cc67ac)
https://bugzilla.redhat.com/show_bug.cgi?id=1853289
https://bugzilla.redhat.com/show_bug.cgi?id=1865932
Message-Id: <20201008150700.52157-3-bfiuczyn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
docs/schemas/nodedev.rng | 16 ++++++++++++++
src/conf/node_device_conf.c | 5 +++++
src/conf/node_device_conf.h | 1 +
src/conf/virnodedeviceobj.c | 1 +
src/node_device/node_device_udev.c | 22 +++++++++++++++++++
.../ccw_0_0_10000-invalid.xml | 4 ++--
tests/nodedevschemadata/ccw_0_0_ffff.xml | 4 ++--
tests/nodedevschemadata/css_0_0_ffff.xml | 10 +++++++++
tests/nodedevxml2xmltest.c | 1 +
tools/virsh-nodedev.c | 1 +
10 files changed, 61 insertions(+), 4 deletions(-)
create mode 100644 tests/nodedevschemadata/css_0_0_ffff.xml
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index fe6ffa0b53..6ac5804bfb 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -85,6 +85,7 @@
<ref name="capdrm"/>
<ref name="capmdev"/>
<ref name="capccwdev"/>
+ <ref name="capcssdev"/>
</choice>
</element>
</define>
@@ -651,6 +652,21 @@
</element>
</define>
+ <define name='capcssdev'>
+ <attribute name='type'>
+ <value>css</value>
+ </attribute>
+ <element name='cssid'>
+ <ref name='ccwCssidRange'/>
+ </element>
+ <element name='ssid'>
+ <ref name='ccwSsidRange'/>
+ </element>
+ <element name='devno'>
+ <ref name='ccwDevnoRange'/>
+ </element>
+ </define>
+
<define name='address'>
<element name='address'>
<attribute name='domain'><ref name='hexuint'/></attribute>
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 4cf5b6e3d7..0a34faa29a 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -65,6 +65,7 @@ VIR_ENUM_IMPL(virNodeDevCap,
"mdev_types",
"mdev",
"ccw",
+ "css",
);
VIR_ENUM_IMPL(virNodeDevNetCap,
@@ -588,6 +589,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
data->mdev.iommuGroupNumber);
break;
case VIR_NODE_DEV_CAP_CCW_DEV:
+ case VIR_NODE_DEV_CAP_CSS_DEV:
virBufferAsprintf(&buf, "<cssid>0x%x</cssid>\n",
data->ccw_dev.cssid);
virBufferAsprintf(&buf, "<ssid>0x%x</ssid>\n",
@@ -1893,6 +1895,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
ret = virNodeDevCapMdevParseXML(ctxt, def, node, &caps->data.mdev);
break;
case VIR_NODE_DEV_CAP_CCW_DEV:
+ case VIR_NODE_DEV_CAP_CSS_DEV:
ret = virNodeDevCapCCWParseXML(ctxt, def, node, &caps->data.ccw_dev);
break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
@@ -2211,6 +2214,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_CCW_DEV:
+ case VIR_NODE_DEV_CAP_CSS_DEV:
case VIR_NODE_DEV_CAP_LAST:
/* This case is here to shutup the compiler */
break;
@@ -2264,6 +2268,7 @@ virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def)
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_CCW_DEV:
+ case VIR_NODE_DEV_CAP_CSS_DEV:
case VIR_NODE_DEV_CAP_LAST:
break;
}
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index bf7939fbb3..19ea3fc7c2 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -65,6 +65,7 @@ typedef enum {
VIR_NODE_DEV_CAP_MDEV_TYPES, /* Device capable of mediated devices */
VIR_NODE_DEV_CAP_MDEV, /* Mediated device */
VIR_NODE_DEV_CAP_CCW_DEV, /* s390 CCW device */
+ VIR_NODE_DEV_CAP_CSS_DEV, /* s390 channel subsystem device */
VIR_NODE_DEV_CAP_LAST
} virNodeDevCapType;
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 3a34a324ca..8c8ffd6d24 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -676,6 +676,7 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *obj,
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_CCW_DEV:
+ case VIR_NODE_DEV_CAP_CSS_DEV:
case VIR_NODE_DEV_CAP_LAST:
break;
}
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9667a042bd..efe3cebd6a 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1097,6 +1097,24 @@ udevProcessCCW(struct udev_device *device,
}
+static int
+udevProcessCSS(struct udev_device *device,
+ virNodeDeviceDefPtr def)
+{
+ /* only process IO subchannel and vfio-ccw devices to keep the list sane */
+ if (STRNEQ(def->driver, "io_subchannel") &&
+ STRNEQ(def->driver, "vfio_ccw"))
+ return -1;
+
+ if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0)
+ return -1;
+
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
+ return -1;
+
+ return 0;
+}
+
static int
udevGetDeviceNodes(struct udev_device *device,
virNodeDeviceDefPtr def)
@@ -1175,6 +1193,8 @@ udevGetDeviceType(struct udev_device *device,
*type = VIR_NODE_DEV_CAP_MDEV;
else if (STREQ_NULLABLE(subsystem, "ccw"))
*type = VIR_NODE_DEV_CAP_CCW_DEV;
+ else if (STREQ_NULLABLE(subsystem, "css"))
+ *type = VIR_NODE_DEV_CAP_CSS_DEV;
VIR_FREE(subsystem);
}
@@ -1219,6 +1239,8 @@ udevGetDeviceDetails(struct udev_device *device,
return udevProcessMediatedDevice(device, def);
case VIR_NODE_DEV_CAP_CCW_DEV:
return udevProcessCCW(device, def);
+ case VIR_NODE_DEV_CAP_CSS_DEV:
+ return udevProcessCSS(device, def);
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_SYSTEM:
case VIR_NODE_DEV_CAP_FC_HOST:
diff --git a/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml b/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml
index d840555c09..f3cf0c1c66 100644
--- a/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml
+++ b/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml
@@ -1,7 +1,7 @@
<device>
<name>ccw_0_0_10000</name>
- <path>/sys/devices/css0/0.0.0000/0.0.10000</path>
- <parent>computer</parent>
+ <path>/sys/devices/css0/0.0.0070/0.0.10000</path>
+ <parent>css_0_0_0070</parent>
<capability type='ccw'>
<cssid>0x0</cssid>
<ssid>0x0</ssid>
diff --git a/tests/nodedevschemadata/ccw_0_0_ffff.xml b/tests/nodedevschemadata/ccw_0_0_ffff.xml
index 5ecd0b0aae..3b8ea46e37 100644
--- a/tests/nodedevschemadata/ccw_0_0_ffff.xml
+++ b/tests/nodedevschemadata/ccw_0_0_ffff.xml
@@ -1,7 +1,7 @@
<device>
<name>ccw_0_0_ffff</name>
- <path>/sys/devices/css0/0.0.0000/0.0.ffff</path>
- <parent>computer</parent>
+ <path>/sys/devices/css0/0.0.0070/0.0.ffff</path>
+ <parent>css_0_0_0070</parent>
<capability type='ccw'>
<cssid>0x0</cssid>
<ssid>0x0</ssid>
diff --git a/tests/nodedevschemadata/css_0_0_ffff.xml b/tests/nodedevschemadata/css_0_0_ffff.xml
new file mode 100644
index 0000000000..312e07fe65
--- /dev/null
+++ b/tests/nodedevschemadata/css_0_0_ffff.xml
@@ -0,0 +1,10 @@
+<device>
+ <name>css_0_0_ffff</name>
+ <path>/sys/devices/css0/0.0.ffff</path>
+ <parent>computer</parent>
+ <capability type='css'>
+ <cssid>0x0</cssid>
+ <ssid>0x0</ssid>
+ <devno>0xffff</devno>
+ </capability>
+</device>
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index 6168c29c70..3cb23b1df4 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -123,6 +123,7 @@ mymain(void)
DO_TEST("pci_0000_02_10_7_mdev_types");
DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b");
DO_TEST("ccw_0_0_ffff");
+ DO_TEST("css_0_0_ffff");
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index cb2fc26d1a..26b3acc608 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -461,6 +461,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
case VIR_NODE_DEV_CAP_CCW_DEV:
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV;
break;
+ case VIR_NODE_DEV_CAP_CSS_DEV:
case VIR_NODE_DEV_CAP_LAST:
break;
}
--
2.28.0