virNodeDevCapsDefPtr cap = dev->def->caps;
while (cap) {
- if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) {
+ 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;
dev = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0);
- if (dev != NULL) {
+ if (dev != NULL)
break;
- }
sleep(5);
- if (get_time(&now) == -1) {
+ if (get_time(&now) == -1)
break;
- }
}
nodeDeviceLock(driver);
nodeDeviceLock(driver);
def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, virt_type);
- if (def == NULL) {
+ if (def == NULL)
goto cleanup;
- }
if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0)
goto cleanup;
- if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) {
+ if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1)
goto cleanup;
- }
if (virNodeDeviceGetParentHost(&driver->devs,
def->name,
/* We don't check the return value, because one way or another,
* we're returning what we get... */
- if (dev == NULL) {
+ if (dev == NULL)
virReportError(VIR_ERR_NO_NODE_DEVICE, NULL);
- }
cleanup:
nodeDeviceUnlock(driver);
if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0)
goto out;
- if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) {
+ if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1)
goto out;
- }
/* virNodeDeviceGetParentHost will cause the device object's lock to be
ret = udevGetDeviceProperty(udev_device, property_key, &udev_value);
if (ret == PROPERTY_FOUND) {
- if (udevStrToLong_i(udev_value, NULL, base, value) != 0) {
+ if (udevStrToLong_i(udev_value, NULL, base, value) != 0)
ret = PROPERTY_ERROR;
- }
}
VIR_FREE(udev_value);
ret = udevGetDeviceProperty(udev_device, property_key, &udev_value);
if (ret == PROPERTY_FOUND) {
- if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) {
+ if (udevStrToLong_ui(udev_value, NULL, base, value) != 0)
ret = PROPERTY_ERROR;
- }
}
VIR_FREE(udev_value);
ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value);
if (ret == PROPERTY_FOUND) {
- if (udevStrToLong_i(udev_value, NULL, base, value) != 0) {
+ if (udevStrToLong_i(udev_value, NULL, base, value) != 0)
ret = PROPERTY_ERROR;
- }
}
VIR_FREE(udev_value);
ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value);
if (ret == PROPERTY_FOUND) {
- if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) {
+ if (udevStrToLong_ui(udev_value, NULL, base, value) != 0)
ret = PROPERTY_ERROR;
- }
}
VIR_FREE(udev_value);
ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value);
if (ret == PROPERTY_FOUND) {
- if (udevStrToLong_ull(udev_value, NULL, 0, value) != 0) {
+ if (udevStrToLong_ull(udev_value, NULL, 0, value) != 0)
ret = PROPERTY_ERROR;
- }
}
VIR_FREE(udev_value);
udev_device_get_subsystem(device),
udev_device_get_sysname(device));
- if (s != NULL) {
+ if (s != NULL)
virBufferAsprintf(&buf, "_%s", s);
- }
if (virBufferCheckError(&buf) < 0)
return -1;
def->name = virBufferContentAndReset(&buf);
for (i = 0; i < strlen(def->name); i++) {
- if (!(c_isalnum(*(def->name + i)))) {
+ if (!(c_isalnum(*(def->name + i))))
*(def->name + i) = '_';
- }
}
return ret;
goto out;
}
- if (udevGenerateDeviceName(device, def, NULL) != 0) {
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
- }
rc = udevGetIntSysfsAttr(device,
"numa_node",
}
}
- if (udevGenerateDeviceName(device, def, NULL) != 0) {
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
- }
ret = 0;
goto out;
}
- if (udevGenerateDeviceName(device, def, NULL) != 0) {
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
- }
ret = 0;
goto out;
}
- if (udevGenerateDeviceName(device, def, data->net.address) != 0) {
+ if (udevGenerateDeviceName(device, def, data->net.address) != 0)
goto out;
- }
if (virNetDevGetLinkInfo(data->net.ifname, &data->net.lnk) < 0)
goto out;
detect_scsi_host_caps(&def->caps->data);
- if (udevGenerateDeviceName(device, def, NULL) != 0) {
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
- }
ret = 0;
if (VIR_STRDUP(data->scsi_target.name, sysname) < 0)
goto out;
- if (udevGenerateDeviceName(device, def, NULL) != 0) {
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
- }
ret = 0;
filename = last_component(def->sysfs_path);
- if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1) {
+ if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1)
goto out;
- }
if ((p == NULL) || (udevStrToLong_ui(p+1,
&p,
switch (udevGetUintSysfsAttr(device, "type", &tmp, 0)) {
case PROPERTY_FOUND:
- if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1) {
+ if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1)
goto out;
- }
break;
case PROPERTY_MISSING:
break; /* No type is not an error */
break;
}
- if (udevGenerateDeviceName(device, def, NULL) != 0) {
+ if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
- }
ret = 0;
static void udevStripSpaces(char *s)
{
- if (s == NULL) {
+ if (s == NULL)
return;
- }
while (virFileStripSuffix(s, " ")) {
/* do nothing */
} else {
/* If udev doesn't have it, perhaps we can guess it. */
- if (udevKludgeStorageType(def) != 0) {
+ if (udevKludgeStorageType(def) != 0)
goto out;
- }
}
}
goto out;
}
- if (udevGenerateDeviceName(device, def, data->storage.serial) != 0) {
+ if (udevGenerateDeviceName(device, def, data->storage.serial) != 0)
goto out;
- }
out:
VIR_DEBUG("Storage ret=%d", ret);
do {
parent_device = udev_device_get_parent(parent_device);
- if (parent_device == NULL) {
+ if (parent_device == NULL)
break;
- }
parent_sysfs_path = udev_device_get_syspath(parent_device);
if (parent_sysfs_path == NULL) {
if (VIR_ALLOC(def->caps) != 0)
goto out;
- if (udevGetDeviceType(device, &def->caps->type) != 0) {
+ if (udevGetDeviceType(device, &def->caps->type) != 0)
goto out;
- }
- if (udevGetDeviceDetails(device, def) != 0) {
+ if (udevGetDeviceDetails(device, def) != 0)
goto out;
- }
- if (udevSetParent(device, def) != 0) {
+ if (udevSetParent(device, def) != 0)
goto out;
- }
/* If this is a device change, the old definition will be freed
* and the current definition will take its place. */
udev_monitor_unref(udev_monitor);
}
- if (udev != NULL) {
+ if (udev != NULL)
udev_unref(udev);
- }
virNodeDeviceObjListFree(&driverState->devs);
nodeDeviceUnlock(driverState);
out:
VIR_FREE(tmp);
- if (device != NULL) {
+ if (device != NULL)
udev_device_unref(device);
- }
return;
}
#endif
ret = 0;
out:
- if (ret == -1) {
+ if (ret == -1)
virNodeDeviceDefFree(def);
- }
return ret;
}
nodeDeviceUnlock(driverState);
out:
- if (ret == -1) {
+ if (ret == -1)
nodeStateCleanup();
- }
return ret;
}
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (driverState == NULL) {
+ if (driverState == NULL)
return VIR_DRV_OPEN_DECLINED;
- }
conn->nodeDevicePrivateData = driverState;
{
VIR_DEBUG("Registering udev node device backend");
- if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) {
+ if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0)
return -1;
- }
return virRegisterStateDriver(&udevStateDriver);
}