mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
nodedev: check/add for scsi_host caps for ListDevices
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>
This commit is contained in:
parent
1b2c9ce752
commit
e8fcac8ecb
@ -78,6 +78,14 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, const char *cap)
|
|||||||
while (caps) {
|
while (caps) {
|
||||||
if (STREQ(cap, virNodeDevCapTypeToString(caps->type)))
|
if (STREQ(cap, virNodeDevCapTypeToString(caps->type)))
|
||||||
return 1;
|
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;
|
caps = caps->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user