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: Bjoern Walk <bw...@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiu...@linux.ibm.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 4b2b350fd8..f7f517b548 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>
@@ -659,6 +660,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 f6a91165c9..a9a03ad6c2 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,
@@ -602,6 +603,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
             virNodeDeviceCapMdevDefFormat(&buf, data);
             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",
@@ -1904,6 +1906,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:
@@ -2228,6 +2231,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;
@@ -2281,6 +2285,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 9b8c7aadea..47669d4294 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -64,6 +64,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 bfd524121c..e234432b6f 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -710,6 +710,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 d478a673fd..38906f5f96 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 e9414f429f..d497fa9797 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.25.1

Reply via email to