[PATCH v3 4/4] node_device: Replace VIR_ERROR with standard vir*Error in state driver init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/node_device/node_device_hal.c  | 26 +++++++++++++-------
 src/node_device/node_device_udev.c | 49 +++++++++++++++++++++++---------------
 2 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 6ddfad0..7a9c3d9 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -641,24 +641,29 @@ 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 +688,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 +709,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 +760,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 7d111c4..3315153 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,8 @@ 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);
     }
@@ -717,8 +720,9 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
     filename = last_component(def->sysfs_path);
 
     if (!(str = STRSKIP(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;
     }
 
@@ -875,8 +879,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;
 }
@@ -1293,7 +1298,8 @@ 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;
     }
@@ -1459,7 +1465,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;
     }
 
@@ -1539,14 +1546,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;
     }
 
@@ -1584,8 +1593,9 @@ 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'"),
-                      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;
         }
     }
@@ -1691,9 +1701,8 @@ static int udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED)
          * 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)));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Failed to initialize libpciaccess: %s"));
             return -1;
         }
     }
@@ -1721,7 +1730,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);
         return -1;
@@ -1747,7 +1757,8 @@ static int nodeStateInitialize(bool privileged,
 
     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;
     }
 
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]