]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: check/add for scsi_host caps for ListDevices
authorShivaprasad G Bhat <shivaprasadbhat@gmail.com>
Tue, 3 Feb 2015 11:55:16 +0000 (06:55 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 5 Feb 2015 12:50:24 +0000 (07:50 -0500)
Commit id '652a2ec6' introduced two new node device capability flags
and the ability to use those flags as a way to search for a specific
subset of a 'scsi_host' device - namely a 'fc_host' and/or 'vports'.
The code modified the virNodeDeviceCapMatch whichs allows for searching
using the 'virsh nodedev-list [cap]' via virConnectListAllNodeDevices.

However, the original patches did not account for other searches for
the same capability key from virNodeListDevices using virNodeDeviceHasCap.
Since 'fc_host' and 'vports' are self defined bits of a 'scsi_host'
device mere string comparison against the basic/root type is not
sufficient.

This patch adds the check for the 'fc_host' and 'vports' bits within
a 'scsi_host' device and allows the following python code to find the
capabilities for the device:

import libvirt
conn = libvirt.openReadOnly('qemu:///system')
fc = conn.listDevices('fc_host', 0)
print(fc)
fc = conn.listDevices('vports', 0)
print(fc)

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
src/conf/node_device_conf.c

index 03b88a22834f32855df635f0911132900cef933c..a728a0081ab6e064abb8638939f6006961d923bb 100644 (file)
@@ -78,6 +78,14 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, const char *cap)
     while (caps) {
         if (STREQ(cap, virNodeDevCapTypeToString(caps->type)))
             return 1;
+        else if (caps->type == VIR_NODE_DEV_CAP_SCSI_HOST)
+            if ((STREQ(cap, "fc_host") &&
+                (caps->data.scsi_host.flags &
+                 VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)) ||
+                (STREQ(cap, "vports") &&
+                (caps->data.scsi_host.flags &
+                 VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)))
+                return 1;
         caps = caps->next;
     }
     return 0;