virNodeDevicePtr nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, const char *wwnn, const char *wwpn, unsigned int flags) { size_t i; virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData; virNodeDeviceObjListPtr devs = &driver->devs; virNodeDevCapsDefPtr cap = NULL; virNodeDeviceObjPtr obj = NULL; virNodeDevicePtr dev = NULL; virCheckFlags(0, NULL); nodeDeviceLock(driver); for (i = 0; i < devs->count; i++) { obj = devs->objs[i]; virNodeDeviceObjLock(obj); cap = obj->def->caps; while (cap) { if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { detect_scsi_host_caps(&cap->data); if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { if (STREQ(cap->data.scsi_host.wwnn, wwnn) && STREQ(cap->data.scsi_host.wwpn, wwpn)) { if (virNodeDeviceLookupSCSIHostByWWNEnsureACL(conn, obj->def) < 0) goto out; dev = virGetNodeDevice(conn, obj->def->name); virNodeDeviceObjUnlock(obj); goto out; } } } cap = cap->next; } virNodeDeviceObjUnlock(obj); } out: nodeDeviceUnlock(driver); return dev; }
static int gather_scsi_host_cap(LibHalContext *ctx, const char *udi, union _virNodeDevCapData *d) { int retval = 0; (void)get_int_prop(ctx, udi, "scsi_host.host", (int *)&d->scsi_host.host); retval = detect_scsi_host_caps(d); if (retval == -1) { goto out; } out: return retval; }
static int update_caps(virNodeDeviceObjPtr dev) { virNodeDevCapsDefPtr cap = dev->def->caps; while (cap) { if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { detect_scsi_host_caps(&dev->def->caps->data); } if (cap->type == VIR_NODE_DEV_CAP_NET && virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0) return -1; cap = cap->next; } return 0; }