From: Shivaprasad G Bhat Date: Tue, 3 Feb 2015 11:55:16 +0000 (-0500) Subject: nodedev: check/add for scsi_host caps for ListDevices X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e8fcac8ecb3fcd5078300b42a4940fb53b42603d;p=libvirt.git 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 --- diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 03b88a2283..a728a0081a 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -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;