[PATCH 24/24] maint: replace remaining virLib*Error with better names

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

 



Finish the cleanup; all uses of virLib*Error have now been
converted to more canonical conventions.

* src/libvirt.c: Use virReportError in remaining errors.
(virLibConnError, virLibDomainError): Delete unused macros.
* cfg.mk (msg_gen_function): Drop unused names.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 cfg.mk        |  10 ----
 src/libvirt.c | 158 +++++++++++++++++++++++++++-------------------------------
 2 files changed, 74 insertions(+), 94 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 5591065..e7515ea 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -585,16 +585,6 @@ msg_gen_function += regerror
 msg_gen_function += vah_error
 msg_gen_function += vah_warning
 msg_gen_function += virGenericReportError
-msg_gen_function += virLibConnError
-msg_gen_function += virLibDomainError
-msg_gen_function += virLibDomainSnapshotError
-msg_gen_function += virLibInterfaceError
-msg_gen_function += virLibNetworkError
-msg_gen_function += virLibNodeDeviceError
-msg_gen_function += virLibNWFilterError
-msg_gen_function += virLibSecretError
-msg_gen_function += virLibStoragePoolError
-msg_gen_function += virLibStorageVolError
 msg_gen_function += virRaiseError
 msg_gen_function += virReportError
 msg_gen_function += virReportErrorHelper
diff --git a/src/libvirt.c b/src/libvirt.c
index 637bfc1..42f1139 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -512,14 +512,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED,
 #endif


-#define virLibConnError(code, ...)                                \
-    virReportErrorHelper(VIR_FROM_NONE, code, __FILE__,           \
-                         __FUNCTION__, __LINE__, __VA_ARGS__)
-#define virLibDomainError(code, ...)                              \
-    virReportErrorHelper(VIR_FROM_DOM, code, __FILE__,            \
-                         __FUNCTION__, __LINE__, __VA_ARGS__)
-
-
 /**
  * virRegisterNetworkDriver:
  * @driver: pointer to a network driver block
@@ -534,9 +526,9 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virNetworkDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -562,9 +554,9 @@ virRegisterInterfaceDriver(virInterfaceDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virInterfaceDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -590,9 +582,9 @@ virRegisterStorageDriver(virStorageDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virStorageDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -618,9 +610,9 @@ virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virNodeDeviceDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -646,9 +638,9 @@ virRegisterSecretDriver(virSecretDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virSecretDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -674,9 +666,9 @@ virRegisterNWFilterDriver(virNWFilterDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virNWFilterDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -704,9 +696,9 @@ virRegisterDriver(virDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -733,9 +725,9 @@ virRegisterStateDriver(virStateDriverPtr driver)
     virCheckNonNullArgReturn(driver, -1);

     if (virStateDriverTabCount >= MAX_DRIVERS) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                        _("Too many drivers, cannot register %s"),
-                        driver->name);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Too many drivers, cannot register %s"),
+                       driver->name);
         return -1;
     }

@@ -970,8 +962,8 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias,
     size_t alias_len;

     if (value->type != VIR_CONF_LIST) {
-        virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                        _("Expected a list for 'uri_aliases' config parameter"));
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Expected a list for 'uri_aliases' config parameter"));
         return -1;
     }

@@ -982,22 +974,22 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias,
         size_t safe;

         if (entry->type != VIR_CONF_STRING) {
-            virLibConnError(VIR_ERR_CONF_SYNTAX, "%s",
-                            _("Expected a string for 'uri_aliases' config parameter list entry"));
+            virReportError(VIR_ERR_CONF_SYNTAX, "%s",
+                           _("Expected a string for 'uri_aliases' config parameter list entry"));
             return -1;
         }

         if (!(offset = strchr(entry->str, '='))) {
-            virLibConnError(VIR_ERR_CONF_SYNTAX,
-                            _("Malformed 'uri_aliases' config entry '%s', expected 'alias=uri://host/path'"),
+            virReportError(VIR_ERR_CONF_SYNTAX,
+                           _("Malformed 'uri_aliases' config entry '%s', expected 'alias=uri://host/path'"),
                             entry->str);
             return -1;
         }

         safe  = strspn(entry->str, URI_ALIAS_CHARS);
         if (safe < (offset - entry->str)) {
-            virLibConnError(VIR_ERR_CONF_SYNTAX,
-                            _("Malformed 'uri_aliases' config entry '%s', aliases may only contain 'a-Z, 0-9, _, -'"),
+            virReportError(VIR_ERR_CONF_SYNTAX,
+                           _("Malformed 'uri_aliases' config entry '%s', aliases may only contain 'a-Z, 0-9, _, -'"),
                             entry->str);
             return -1;
         }
@@ -1048,8 +1040,8 @@ virConnectGetDefaultURI(virConfPtr conf,
         *name = defname;
     } else if ((value = virConfGetValue(conf, "uri_default"))) {
         if (value->type != VIR_CONF_STRING) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("Expected a string for 'uri_default' config parameter"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Expected a string for 'uri_default' config parameter"));
             goto cleanup;
         }
         VIR_DEBUG("Using config file uri '%s'", value->str);
@@ -1194,9 +1186,7 @@ do_open(const char *name,

     if (!ret->driver) {
         /* If we reach here, then all drivers declined the connection. */
-        virLibConnError(VIR_ERR_NO_CONNECT,
-                        "%s",
-                        NULLSTR(name));
+        virReportError(VIR_ERR_NO_CONNECT, "%s", NULLSTR(name));
         goto failed;
     }

@@ -2568,8 +2558,8 @@ virDomainSave(virDomainPtr domain, const char *to)

         /* We must absolutize the file path as the save is done out of process */
         if (virFileAbsPath(to, &absolute_to) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute output file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute output file path"));
             goto error;
         }

@@ -2658,8 +2648,8 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,

         /* We must absolutize the file path as the save is done out of process */
         if (virFileAbsPath(to, &absolute_to) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute output file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute output file path"));
             goto error;
         }

@@ -2708,8 +2698,8 @@ virDomainRestore(virConnectPtr conn, const char *from)

         /* We must absolutize the file path as the restore is done out of process */
         if (virFileAbsPath(from, &absolute_from) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute input file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute input file path"));
             goto error;
         }

@@ -2784,8 +2774,8 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,

         /* We must absolutize the file path as the restore is done out of process */
         if (virFileAbsPath(from, &absolute_from) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute input file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute input file path"));
             goto error;
         }

@@ -2838,8 +2828,8 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
     virCheckNonNullArgGoto(file, error);

     if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
-        virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
-                        _("virDomainSaveImageGetXMLDesc with secure flag"));
+        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
+                       _("virDomainSaveImageGetXMLDesc with secure flag"));
         goto error;
     }

@@ -2849,8 +2839,8 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,

         /* We must absolutize the file path as the read is done out of process */
         if (virFileAbsPath(file, &absolute_file) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute input file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute input file path"));
             goto error;
         }

@@ -2924,8 +2914,8 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file,

         /* We must absolutize the file path as the read is done out of process */
         if (virFileAbsPath(file, &absolute_file) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute input file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute input file path"));
             goto error;
         }

@@ -3011,8 +3001,8 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags)

         /* We must absolutize the file path as the save is done out of process */
         if (virFileAbsPath(to, &absolute_to) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("could not build absolute core file path"));
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("could not build absolute core file path"));
             goto error;
         }

@@ -3471,8 +3461,8 @@ virDomainGetMaxMemory(virDomainPtr domain)
         if (ret == 0)
             goto error;
         if ((unsigned long) ret != ret) {
-            virLibDomainError(VIR_ERR_OVERFLOW, _("result too large: %llu"),
-                              ret);
+            virReportError(VIR_ERR_OVERFLOW, _("result too large: %llu"),
+                           ret);
             goto error;
         }
         return ret;
@@ -4275,8 +4265,8 @@ virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     conn = domain->conn;

     if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
-        virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
-                        _("virDomainGetXMLDesc with secure flag"));
+        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
+                       _("virDomainGetXMLDesc with secure flag"));
         goto error;
     }

@@ -9333,7 +9323,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
     virCheckNonZeroArgGoto(nvcpus, error);

     if ((unsigned short) nvcpus != nvcpus) {
-        virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u"), nvcpus);
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), nvcpus);
         goto error;
     }
     conn = domain->conn;
@@ -9460,7 +9450,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
     virCheckPositiveArgGoto(maplen, error);

     if ((unsigned short) vcpu != vcpu) {
-        virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu);
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu);
         goto error;
     }

@@ -9532,7 +9522,7 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu,
     virCheckPositiveArgGoto(maplen, error);

     if ((unsigned short) vcpu != vcpu) {
-        virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu);
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu);
         goto error;
     }

@@ -9595,8 +9585,8 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps,
     virCheckPositiveArgGoto(maplen, error);

     if (INT_MULTIPLY_OVERFLOW(ncpumaps, maplen)) {
-        virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
-                          ncpumaps, maplen);
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
+                       ncpumaps, maplen);
         goto error;
     }

@@ -9805,8 +9795,8 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
         virCheckZeroArgGoto(maplen, error);

     if (cpumaps && INT_MULTIPLY_OVERFLOW(maxinfo, maplen)) {
-        virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
-                          maxinfo, maplen);
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
+                       maxinfo, maplen);
         goto error;
     }

@@ -15891,8 +15881,8 @@ virStreamSendAll(virStreamPtr stream,
     virCheckNonNullArgGoto(handler, cleanup);

     if (stream->flags & VIR_STREAM_NONBLOCK) {
-        virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
-                        _("data sources cannot be used for non-blocking streams"));
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("data sources cannot be used for non-blocking streams"));
         goto cleanup;
     }

@@ -15984,8 +15974,8 @@ virStreamRecvAll(virStreamPtr stream,
     virCheckNonNullArgGoto(handler, cleanup);

     if (stream->flags & VIR_STREAM_NONBLOCK) {
-        virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
-                        _("data sinks cannot be used for non-blocking streams"));
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("data sinks cannot be used for non-blocking streams"));
         goto cleanup;
     }

@@ -18183,8 +18173,8 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
     conn = snapshot->domain->conn;

     if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
-        virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
-                        _("virDomainSnapshotGetXMLDesc with secure flag"));
+        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
+                       _("virDomainSnapshotGetXMLDesc with secure flag"));
         goto error;
     }

@@ -19919,8 +19909,8 @@ virConnectRegisterCloseCallback(virConnectPtr conn,
     virCheckNonNullArgGoto(cb, error);

     if (conn->closeCallback->callback) {
-        virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
-                        _("A close callback is already registered"));
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("A close callback is already registered"));
         goto error;
     }

@@ -19972,8 +19962,8 @@ virConnectUnregisterCloseCallback(virConnectPtr conn,
     virCheckNonNullArgGoto(cb, error);

     if (conn->closeCallback->callback != cb) {
-        virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
-                        _("A different callback was requested"));
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("A different callback was requested"));
         goto error;
     }

@@ -20261,8 +20251,8 @@ virDomainGetCPUStats(virDomainPtr domain,
         virCheckNullArgGoto(params, error);

     if (nparams && ncpus > UINT_MAX / nparams) {
-        virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u * %u"),
-                          nparams, ncpus);
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %u * %u"),
+                       nparams, ncpus);
         goto error;
     }
     if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
-- 
1.8.4.2

--
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]