[libvirt] [PATCH 4/7] virsh: nodedev: ability to filter CCW capabilities

Bjoern Walk posted 7 patches 8 years, 8 months ago
[libvirt] [PATCH 4/7] virsh: nodedev: ability to filter CCW capabilities
Posted by Bjoern Walk 8 years, 8 months ago
Now that the node_device driver is aware of CCW devices, let's hook up
virsh so that we can filter them properly.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
---
 docs/formatnode.html.in           | 12 ++++++++++++
 include/libvirt/libvirt-nodedev.h |  1 +
 src/conf/node_device_conf.h       |  3 ++-
 src/conf/virnodedeviceobj.c       |  3 ++-
 src/libvirt-nodedev.c             |  1 +
 tools/virsh-nodedev.c             |  3 ++-
 tools/virsh.pod                   |  2 +-
 7 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index a368ffc07..32451d557 100644
--- a/docs/formatnode.html.in
+++ b/docs/formatnode.html.in
@@ -324,6 +324,18 @@
               <code>render</code>.</dd>
             </dl>
           </dd>
+          <dt><code>ccw</code></dt>
+          <dd>Describes a Command Channel Word (CCW) device commonly found on
+          the S390 architecture. Sub-elements include:
+            <dl>
+              <dt><code>cssid</code></dt>
+              <dd>The channel subsystem identifier.</dd>
+              <dt><code>ssid</code></dt>
+              <dd>The subchannel-set identifier.</dd>
+              <dt><code>devno</code></dt>
+              <dd>The device number.</dd>
+            </dl>
+          </dd>
         </dl>
       </dd>
     </dl>
diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h
index 1e3043787..cd3f2372b 100644
--- a/include/libvirt/libvirt-nodedev.h
+++ b/include/libvirt/libvirt-nodedev.h
@@ -81,6 +81,7 @@ typedef enum {
     VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM           = 1 << 12, /* DRM device */
     VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES    = 1 << 13, /* Capable of mediated devices */
     VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV          = 1 << 14, /* Mediated device */
+    VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV       = 1 << 15, /* CCW device */
 } virConnectListAllNodeDeviceFlags;
 
 int                     virConnectListAllNodeDevices (virConnectPtr conn,
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index bf9d5fce5..285841edc 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -388,7 +388,8 @@ virNodeDevCapMdevTypeFree(virNodeDevCapMdevTypePtr type);
                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC  | \
                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM           | \
                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES    | \
-                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV)
+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV          | \
+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV)
 
 char *
 virNodeDeviceGetParentName(virConnectPtr conn,
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 02ac54437..d460f26ec 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -568,7 +568,8 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
               MATCH(SCSI_GENERIC)  ||
               MATCH(DRM)           ||
               MATCH(MDEV_TYPES)    ||
-              MATCH(MDEV)))
+              MATCH(MDEV)          ||
+              MATCH(CCW_DEV)))
             return false;
     }
 
diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
index 44e2b4efd..f85c16bbc 100644
--- a/src/libvirt-nodedev.c
+++ b/src/libvirt-nodedev.c
@@ -100,6 +100,7 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags)
  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM
  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES
  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV
+ *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV
  *
  * Returns the number of node devices found or -1 and sets @devices to NULL in
  * case of error.  On success, the array stored into @devices is guaranteed to
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 1822d3dce..c7ef6bfde 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -461,7 +461,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
             flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV;
             break;
         case VIR_NODE_DEV_CAP_CCW_DEV:
-            /* enable next patch */
+            flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV;
+            break;
         case VIR_NODE_DEV_CAP_LAST:
             break;
         }
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e7c513b98..aee964689 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -3181,7 +3181,7 @@ I<cap> is used to filter the list by capability types, the types must be
 separated by comma, e.g. --cap pci,scsi. Valid capability types include
 'system', 'pci', 'usb_device', 'usb', 'net', 'scsi_host', 'scsi_target',
 'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev',
-'mdev_types'.
+'mdev_types', 'ccw'.
 If I<--tree> is used, the output is formatted in a tree representing parents of each
 node.  I<cap> and I<--tree> are mutually exclusive.
 
-- 
2.11.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] virsh: nodedev: ability to filter CCW capabilities
Posted by John Ferlan 8 years, 8 months ago

On 05/22/2017 02:38 AM, Bjoern Walk wrote:
> Now that the node_device driver is aware of CCW devices, let's hook up
> virsh so that we can filter them properly.
> 
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
> Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
> ---
>  docs/formatnode.html.in           | 12 ++++++++++++
>  include/libvirt/libvirt-nodedev.h |  1 +
>  src/conf/node_device_conf.h       |  3 ++-
>  src/conf/virnodedeviceobj.c       |  3 ++-
>  src/libvirt-nodedev.c             |  1 +
>  tools/virsh-nodedev.c             |  3 ++-
>  tools/virsh.pod                   |  2 +-
>  7 files changed, 21 insertions(+), 4 deletions(-)
> 


...

> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
> index 02ac54437..d460f26ec 100644
> --- a/src/conf/virnodedeviceobj.c
> +++ b/src/conf/virnodedeviceobj.c
> @@ -568,7 +568,8 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
>                MATCH(SCSI_GENERIC)  ||
>                MATCH(DRM)           ||
>                MATCH(MDEV_TYPES)    ||
> -              MATCH(MDEV)))
> +              MATCH(MDEV)          ||
> +              MATCH(CCW_DEV)))
>              return false;
>      }
>  

But you didn't modify virNodeDeviceCapMatch in order perform the match
that the MATCH does.

Also, another well hidden gem that either Erik Skultety or myself will
fix "eventually" is virNodeDeviceObjHasCap.  See commit id 'e8fcac8ec'
for some context.  Essentially, the virNodeDeviceMatch only matches for
the virNodeDeviceObjListExport API.

If you want to send something to squash in or just a v2 of this patch -
I can handle either.

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] virsh: nodedev: ability to filter CCW capabilities
Posted by Bjoern Walk 8 years, 8 months ago
John Ferlan <jferlan@redhat.com> [2017-05-25, 03:21PM -0400]:
>
>
>On 05/22/2017 02:38 AM, Bjoern Walk wrote:
>> Now that the node_device driver is aware of CCW devices, let's hook up
>> virsh so that we can filter them properly.
>>
>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
>> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>> Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
>> ---
>>  docs/formatnode.html.in           | 12 ++++++++++++
>>  include/libvirt/libvirt-nodedev.h |  1 +
>>  src/conf/node_device_conf.h       |  3 ++-
>>  src/conf/virnodedeviceobj.c       |  3 ++-
>>  src/libvirt-nodedev.c             |  1 +
>>  tools/virsh-nodedev.c             |  3 ++-
>>  tools/virsh.pod                   |  2 +-
>>  7 files changed, 21 insertions(+), 4 deletions(-)
>>
>
>
>...
>
>> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
>> index 02ac54437..d460f26ec 100644
>> --- a/src/conf/virnodedeviceobj.c
>> +++ b/src/conf/virnodedeviceobj.c
>> @@ -568,7 +568,8 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
>>                MATCH(SCSI_GENERIC)  ||
>>                MATCH(DRM)           ||
>>                MATCH(MDEV_TYPES)    ||
>> -              MATCH(MDEV)))
>> +              MATCH(MDEV)          ||
>> +              MATCH(CCW_DEV)))
>>              return false;
>>      }
>>
>
>But you didn't modify virNodeDeviceCapMatch in order perform the match
>that the MATCH does.
>

Damn, there's a lot that you can miss with these capabilities.

>Also, another well hidden gem that either Erik Skultety or myself will
>fix "eventually" is virNodeDeviceObjHasCap.  See commit id 'e8fcac8ec'
>for some context.  Essentially, the virNodeDeviceMatch only matches for
>the virNodeDeviceObjListExport API.
>

And even more. Thanks for the pointers.

>If you want to send something to squash in or just a v2 of this patch -
>I can handle either.
>
>Reviewed-by: John Ferlan <jferlan@redhat.com>

Thanks.

>
>John
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
>

-- 
IBM Systems
Linux on z Systems & Virtualization Development
------------------------------------------------------------------------
IBM Deutschland
Schönaicher Str. 220
71032 Böblingen
Phone: +49 7031 16 1819
E-Mail: bwalk@de.ibm.com
------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294 
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] virsh: nodedev: ability to filter CCW capabilities
Posted by John Ferlan 8 years, 8 months ago

On 05/26/2017 03:00 AM, Bjoern Walk wrote:
> John Ferlan <jferlan@redhat.com> [2017-05-25, 03:21PM -0400]:
>>
>>
>> On 05/22/2017 02:38 AM, Bjoern Walk wrote:
>>> Now that the node_device driver is aware of CCW devices, let's hook up
>>> virsh so that we can filter them properly.
>>>
>>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
>>> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>>> Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
>>> ---
>>>  docs/formatnode.html.in           | 12 ++++++++++++
>>>  include/libvirt/libvirt-nodedev.h |  1 +
>>>  src/conf/node_device_conf.h       |  3 ++-
>>>  src/conf/virnodedeviceobj.c       |  3 ++-
>>>  src/libvirt-nodedev.c             |  1 +
>>>  tools/virsh-nodedev.c             |  3 ++-
>>>  tools/virsh.pod                   |  2 +-
>>>  7 files changed, 21 insertions(+), 4 deletions(-)
>>>
>>
>>
>> ...
>>
>>> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
>>> index 02ac54437..d460f26ec 100644
>>> --- a/src/conf/virnodedeviceobj.c
>>> +++ b/src/conf/virnodedeviceobj.c
>>> @@ -568,7 +568,8 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
>>>                MATCH(SCSI_GENERIC)  ||
>>>                MATCH(DRM)           ||
>>>                MATCH(MDEV_TYPES)    ||
>>> -              MATCH(MDEV)))
>>> +              MATCH(MDEV)          ||
>>> +              MATCH(CCW_DEV)))
>>>              return false;
>>>      }
>>>
>>
>> But you didn't modify virNodeDeviceCapMatch in order perform the match
>> that the MATCH does.
>>
> 
> Damn, there's a lot that you can miss with these capabilities.
> 

I sent a patch which should cover this for the future:

https://www.redhat.com/archives/libvir-list/2017-May/msg01003.html


>> Also, another well hidden gem that either Erik Skultety or myself will
>> fix "eventually" is virNodeDeviceObjHasCap.  See commit id 'e8fcac8ec'
>> for some context.  Essentially, the virNodeDeviceMatch only matches for
>> the virNodeDeviceObjListExport API.
>>
> 
> And even more. Thanks for the pointers.
> 

In rethinking this - it doesn't necessarily seem as though this device
would have the same issues as NPIV (a SCSI_HOST device parent that has
capabilities of either "fc_host" or "vports" to describe a capable
child) or MDEV (a PCI device that a parent mediated device with "mdev"
capabilities to describe the children).

As long as you're comfortable that the match can be done - I'm good. The
mdev changes were recently reviewed by me so it was fresh in my mind.

John


>> If you want to send something to squash in or just a v2 of this patch -
>> I can handle either.
>>
>> Reviewed-by: John Ferlan <jferlan@redhat.com>
> 
> Thanks.
> 
>>
>> John
>>
>> -- 
>> libvir-list mailing list
>> libvir-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/libvir-list
>>
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list