2ba5aa
From 09ce043fb64e92147992898ccdfc9a6c31c6051e Mon Sep 17 00:00:00 2001
2ba5aa
Message-Id: <09ce043fb64e92147992898ccdfc9a6c31c6051e@dist-git>
2ba5aa
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
2ba5aa
Date: Thu, 8 Oct 2020 11:06:58 -0400
2ba5aa
Subject: [PATCH] virsh: nodedev: ability to filter CSS capabilities
2ba5aa
2ba5aa
Allow to filter for CSS devices.
2ba5aa
2ba5aa
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
2ba5aa
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2ba5aa
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2ba5aa
(cherry picked from commit ab655afa186a81ddfd247d2c187c160dd05740e5)
2ba5aa
https://bugzilla.redhat.com/show_bug.cgi?id=1853289
2ba5aa
https://bugzilla.redhat.com/show_bug.cgi?id=1865932
2ba5aa
Message-Id: <20201008150700.52157-4-bfiuczyn@redhat.com>
2ba5aa
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2ba5aa
---
2ba5aa
 docs/formatnode.html.in           | 12 ++++++++++++
2ba5aa
 docs/manpages/virsh.rst           |  2 +-
2ba5aa
 include/libvirt/libvirt-nodedev.h |  1 +
2ba5aa
 src/conf/node_device_conf.h       |  3 ++-
2ba5aa
 src/conf/virnodedeviceobj.c       |  3 ++-
2ba5aa
 src/libvirt-nodedev.c             |  1 +
2ba5aa
 tools/virsh-nodedev.c             |  2 ++
2ba5aa
 7 files changed, 21 insertions(+), 3 deletions(-)
2ba5aa
2ba5aa
diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
2ba5aa
index c2a8f8fb7a..0e9658fd29 100644
2ba5aa
--- a/docs/formatnode.html.in
2ba5aa
+++ b/docs/formatnode.html.in
2ba5aa
@@ -341,6 +341,18 @@
2ba5aa
               
The device number.
2ba5aa
             
2ba5aa
           
2ba5aa
+          
css
2ba5aa
+          
Describes a Channel SubSystem (CSS) device commonly found on
2ba5aa
+          the S390 architecture. Sub-elements include:
2ba5aa
+            
2ba5aa
+              
cssid
2ba5aa
+              
The channel subsystem identifier.
2ba5aa
+              
ssid
2ba5aa
+              
The subchannel-set identifier.
2ba5aa
+              
devno
2ba5aa
+              
The device number.
2ba5aa
+            
2ba5aa
+          
2ba5aa
         
2ba5aa
       
2ba5aa
     
2ba5aa
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
2ba5aa
index c637caa583..0804465d44 100644
2ba5aa
--- a/docs/manpages/virsh.rst
2ba5aa
+++ b/docs/manpages/virsh.rst
2ba5aa
@@ -4886,7 +4886,7 @@ List all of the devices available on the node that are known by libvirt.
2ba5aa
 separated by comma, e.g. --cap pci,scsi. Valid capability types include
2ba5aa
 'system', 'pci', 'usb_device', 'usb', 'net', 'scsi_host', 'scsi_target',
2ba5aa
 'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev',
2ba5aa
-'mdev_types', 'ccw'.
2ba5aa
+'mdev_types', 'ccw', 'css'.
2ba5aa
 If *--tree* is used, the output is formatted in a tree representing parents of each
2ba5aa
 node.  *cap* and *--tree* are mutually exclusive.
2ba5aa
 
2ba5aa
diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h
2ba5aa
index a2ad61ac6d..dd2ffd5782 100644
2ba5aa
--- a/include/libvirt/libvirt-nodedev.h
2ba5aa
+++ b/include/libvirt/libvirt-nodedev.h
2ba5aa
@@ -81,6 +81,7 @@ typedef enum {
2ba5aa
     VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES    = 1 << 13, /* Capable of mediated devices */
2ba5aa
     VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV          = 1 << 14, /* Mediated device */
2ba5aa
     VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV       = 1 << 15, /* CCW device */
2ba5aa
+    VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV       = 1 << 16, /* CSS device */
2ba5aa
 } virConnectListAllNodeDeviceFlags;
2ba5aa
 
2ba5aa
 int                     virConnectListAllNodeDevices (virConnectPtr conn,
2ba5aa
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
2ba5aa
index 19ea3fc7c2..6fe51ed04c 100644
2ba5aa
--- a/src/conf/node_device_conf.h
2ba5aa
+++ b/src/conf/node_device_conf.h
2ba5aa
@@ -364,7 +364,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
2ba5aa
                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM           | \
2ba5aa
                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES    | \
2ba5aa
                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV          | \
2ba5aa
-                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV)
2ba5aa
+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV       | \
2ba5aa
+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV)
2ba5aa
 
2ba5aa
 int
2ba5aa
 virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host);
2ba5aa
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
2ba5aa
index 8c8ffd6d24..a27a84355a 100644
2ba5aa
--- a/src/conf/virnodedeviceobj.c
2ba5aa
+++ b/src/conf/virnodedeviceobj.c
2ba5aa
@@ -827,7 +827,8 @@ virNodeDeviceObjMatch(virNodeDeviceObjPtr obj,
2ba5aa
               MATCH(DRM)           ||
2ba5aa
               MATCH(MDEV_TYPES)    ||
2ba5aa
               MATCH(MDEV)          ||
2ba5aa
-              MATCH(CCW_DEV)))
2ba5aa
+              MATCH(CCW_DEV)       ||
2ba5aa
+              MATCH(CSS_DEV)))
2ba5aa
             return false;
2ba5aa
     }
2ba5aa
 
2ba5aa
diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
2ba5aa
index dce46b7181..71d81f6278 100644
2ba5aa
--- a/src/libvirt-nodedev.c
2ba5aa
+++ b/src/libvirt-nodedev.c
2ba5aa
@@ -101,6 +101,7 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags)
2ba5aa
  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES
2ba5aa
  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV
2ba5aa
  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV
2ba5aa
+ *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV
2ba5aa
  *
2ba5aa
  * Returns the number of node devices found or -1 and sets @devices to NULL in
2ba5aa
  * case of error.  On success, the array stored into @devices is guaranteed to
2ba5aa
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
2ba5aa
index 26b3acc608..f4e402c35d 100644
2ba5aa
--- a/tools/virsh-nodedev.c
2ba5aa
+++ b/tools/virsh-nodedev.c
2ba5aa
@@ -462,6 +462,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
2ba5aa
             flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV;
2ba5aa
             break;
2ba5aa
         case VIR_NODE_DEV_CAP_CSS_DEV:
2ba5aa
+            flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV;
2ba5aa
+            break;
2ba5aa
         case VIR_NODE_DEV_CAP_LAST:
2ba5aa
             break;
2ba5aa
         }
2ba5aa
-- 
2ba5aa
2.28.0
2ba5aa