str = udevGetDeviceProperty(udev_device, property_key);
if (str && virStrToLong_i(str, NULL, base, value) < 0) {
- VIR_ERROR(_("Failed to convert '%s' to int"), str);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to convert '%s' to int"), str);
return -1;
}
return 0;
str = udevGetDeviceProperty(udev_device, property_key);
if (str && virStrToLong_ui(str, NULL, base, value) < 0) {
- VIR_ERROR(_("Failed to convert '%s' to int"), str);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to convert '%s' to int"), str);
return -1;
}
return 0;
str = udevGetDeviceSysfsAttr(udev_device, attr_name);
if (str && virStrToLong_i(str, NULL, base, value) < 0) {
- VIR_ERROR(_("Failed to convert '%s' to int"), str);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to convert '%s' to int"), str);
return -1;
}
str = udevGetDeviceSysfsAttr(udev_device, attr_name);
if (str && virStrToLong_ui(str, NULL, base, value) < 0) {
- VIR_ERROR(_("Failed to convert '%s' to unsigned int"), str);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to convert '%s' to unsigned int"), str);
return -1;
}
str = udevGetDeviceSysfsAttr(udev_device, attr_name);
if (str && virStrToLong_ull(str, NULL, 0, value) < 0) {
- VIR_ERROR(_("Failed to convert '%s' to unsigned long long"), str);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to convert '%s' to unsigned long long"), str);
return -1;
}
out:
if (ret != 0) {
- VIR_ERROR(_("Failed to process SCSI device with sysfs path '%s'"),
- def->sysfs_path);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to process SCSI device with sysfs path '%s'"),
+ def->sysfs_path);
}
return ret;
}
ret = udevProcessSCSIGeneric(device, def);
break;
default:
- VIR_ERROR(_("Unknown device type %d"), def->caps->data.type);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unknown device type %d"), def->caps->data.type);
ret = -1;
break;
}
ret = udev_enumerate_scan_devices(udev_enumerate);
if (0 != ret) {
- VIR_ERROR(_("udev scan devices returned %d"), ret);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("udev scan devices returned %d"),
+ ret);
goto out;
}
nodeDeviceLock();
udev_fd = udev_monitor_get_fd(udev_monitor);
if (fd != udev_fd) {
- VIR_ERROR(_("File descriptor returned by udev %d does not "
- "match node device file descriptor %d"), fd, udev_fd);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("File descriptor returned by udev %d does not "
+ "match node device file descriptor %d"),
+ fd, udev_fd);
goto out;
}
device = udev_monitor_receive_device(udev_monitor);
if (device == NULL) {
- VIR_ERROR(_("udev_monitor_receive_device returned NULL"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("udev_monitor_receive_device returned NULL"));
goto out;
}
if (device == NULL) {
device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK);
if (device == NULL) {
- VIR_ERROR(_("Failed to get udev device for syspath '%s' or '%s'"),
- DMI_DEVPATH, DMI_DEVPATH_FALLBACK);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to get udev device for syspath '%s' or '%s'"),
+ DMI_DEVPATH, DMI_DEVPATH_FALLBACK);
goto out;
}
}
/* On s390(x) system there is no PCI bus.
* Therefore there is nothing to initialize here. */
#else
- int pciret;
+ int rc;
- if ((pciret = pci_system_init()) != 0) {
+ if ((rc = pci_system_init()) != 0) {
/* Ignore failure as non-root; udev is not as helpful in that
* situation, but a non-privileged user won't benefit much
* from udev in the first place. */
if (errno != ENOENT && (privileged || errno != EACCES)) {
- char ebuf[256];
- VIR_ERROR(_("Failed to initialize libpciaccess: %s"),
- virStrerror(pciret, ebuf, sizeof(ebuf)));
+ virReportSystemError(rc, "%s",
+ _("Failed to initialize libpciaccess"));
return -1;
}
}
}
if (virMutexInit(&driver->lock) < 0) {
- VIR_ERROR(_("Failed to initialize mutex for driver"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unable to initialize mutex"));
VIR_FREE(priv);
VIR_FREE(driver);
return -1;
priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (priv->udev_monitor == NULL) {
- VIR_ERROR(_("udev_monitor_new_from_netlink returned NULL"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("udev_monitor_new_from_netlink returned NULL"));
goto out_unlock;
}