[PATCH 2/5] node_device: detect CSS devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>

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 <bwalk@xxxxxxxxxxxxx>
Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 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 4b2b350f..f7f517b5 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 851ef0a8..8694df4b 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 9b8c7aad..47669d42 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 bfd52412..e234432b 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 d478a673..1c4df709 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)
+{
+    /* do not process EADM and CHSC devices to keep the list sane */
+    if (STREQ(def->driver, "eadm_subchannel") ||
+        STREQ(def->driver, "chsc_subchannel"))
+        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 d840555c..f3cf0c1c 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 5ecd0b0a..3b8ea46e 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 00000000..312e07fe
--- /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 6168c29c..3cb23b1d 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 e576b3c8..ff4b7441 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.24.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux