Replace VIR_ERROR with virReportError and virReportSystemError --- src/node_device/node_device_hal.c | 24 ++++++++++++-------- src/node_device/node_device_udev.c | 45 ++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index 6ddfad0..fd26692 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -641,24 +641,27 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED, dbus_error_init(&err); if (!(sysbus = virDBusGetSystemBus())) { - VIR_ERROR(_("DBus not available, disabling HAL driver: %s"), - virGetLastErrorMessage()); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("DBus not available, disabling HAL driver: %s"), + virGetLastErrorMessage()); ret = 0; goto failure; } hal_ctx = libhal_ctx_new(); if (hal_ctx == NULL) { - VIR_ERROR(_("libhal_ctx_new returned NULL")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("libhal_ctx_new returned NULL")); goto failure; } if (!libhal_ctx_set_dbus_connection(hal_ctx, sysbus)) { - VIR_ERROR(_("libhal_ctx_set_dbus_connection failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libhal_ctx_set_dbus_connection failed")); goto failure; } if (!libhal_ctx_init(hal_ctx, &err)) { - VIR_ERROR(_("libhal_ctx_init failed, haldaemon is probably not running")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libhal_ctx_init failed, haldaemon is probably not running")); /* We don't want to show a fatal error here, otherwise entire libvirtd shuts down when hald isn't running */ @@ -683,13 +686,15 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED, !libhal_ctx_set_device_lost_capability(hal_ctx, device_cap_lost) || !libhal_ctx_set_device_property_modified(hal_ctx, device_prop_modified) || !libhal_device_property_watch_all(hal_ctx, &err)) { - VIR_ERROR(_("setting up HAL callbacks failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("setting up HAL callbacks failed")); goto failure; } udi = libhal_get_all_devices(hal_ctx, &num_devs, &err); if (udi == NULL) { - VIR_ERROR(_("libhal_get_all_devices failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libhal_get_all_devices failed")); goto failure; } for (i = 0; i < num_devs; i++) { @@ -702,7 +707,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED, failure: if (dbus_error_is_set(&err)) { - VIR_ERROR(_("%s: %s"), err.name, err.message); + virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: %s"), err.name, err.message); dbus_error_free(&err); } virNodeDeviceObjListFree(&driver->devs); @@ -753,7 +758,8 @@ nodeStateReload(void) dbus_error_init(&err); udi = libhal_get_all_devices(hal_ctx, &num_devs, &err); if (udi == NULL) { - VIR_ERROR(_("libhal_get_all_devices failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libhal_get_all_devices failed")); return -1; } for (i = 0; i < num_devs; i++) { diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 6bff5ba..05253b6 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -66,7 +66,8 @@ static int udevStrToLong_ull(char const *s, ret = virStrToLong_ull(s, end_ptr, base, result); if (ret != 0) { - VIR_ERROR(_("Failed to convert '%s' to unsigned long long"), s); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to convert '%s' to unsigned long long"), s); } else { VIR_DEBUG("Converted '%s' to unsigned long %llu", s, *result); } @@ -84,7 +85,8 @@ static int udevStrToLong_ui(char const *s, ret = virStrToLong_ui(s, end_ptr, base, result); if (ret != 0) { - VIR_ERROR(_("Failed to convert '%s' to unsigned int"), s); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to convert '%s' to unsigned int"), s); } else { VIR_DEBUG("Converted '%s' to unsigned int %u", s, *result); } @@ -101,7 +103,7 @@ static int udevStrToLong_i(char const *s, ret = virStrToLong_i(s, end_ptr, base, result); if (ret != 0) { - VIR_ERROR(_("Failed to convert '%s' to int"), s); + virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to convert '%s' to int"), s); } else { VIR_DEBUG("Converted '%s' to int %u", s, *result); } @@ -716,8 +718,8 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED, filename = last_component(def->sysfs_path); if (!STRPREFIX(filename, "host")) { - VIR_ERROR(_("SCSI host found, but its udev name '%s' does " - "not begin with 'host'"), filename); + virReportError(VIR_ERR_INTERNAL_ERROR, _("SCSI host found, but its udev name '%s' " + "does not begin with 'host'"), filename); goto out; } @@ -874,8 +876,9 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, 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; } @@ -1292,7 +1295,9 @@ static int udevGetDeviceDetails(struct udev_device *device, 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; } @@ -1458,7 +1463,8 @@ static int udevEnumerateDevices(struct udev *udev) 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; } @@ -1533,14 +1539,16 @@ static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED, 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; } @@ -1579,7 +1587,8 @@ udevGetDMIData(virNodeDevCapDataPtr data) 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'"), + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to get udev device for syspath '%s' or '%s'"), DMI_DEVPATH, DMI_DEVPATH_FALLBACK); goto out; } @@ -1694,8 +1703,8 @@ static int nodeStateInitialize(bool privileged, * 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(errno, _("Failed to initialize libpciaccess: %s"), + virStrerror(pciret, ebuf, sizeof(ebuf))); ret = -1; goto out; } @@ -1717,7 +1726,8 @@ static int nodeStateInitialize(bool privileged, } if (virMutexInit(&driver->lock) < 0) { - VIR_ERROR(_("Failed to initialize mutex for driver")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialize mutex for driver")); VIR_FREE(priv); VIR_FREE(driver); ret = -1; @@ -1741,7 +1751,8 @@ static int nodeStateInitialize(bool privileged, priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev"); if (priv->udev_monitor == NULL) { VIR_FREE(priv); - VIR_ERROR(_("udev_monitor_new_from_netlink returned NULL")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("udev_monitor_new_from_netlink returned NULL")); ret = -1; goto out_unlock; } -- 2.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list