mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
maint: replace remaining virLib*Error with better names
Finish the cleanup of libvirt.c; 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@redhat.com>
This commit is contained in:
parent
323c2cc46c
commit
42358e3a0a
10
cfg.mk
10
cfg.mk
@ -585,16 +585,6 @@ msg_gen_function += regerror
|
|||||||
msg_gen_function += vah_error
|
msg_gen_function += vah_error
|
||||||
msg_gen_function += vah_warning
|
msg_gen_function += vah_warning
|
||||||
msg_gen_function += virGenericReportError
|
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 += virRaiseError
|
||||||
msg_gen_function += virReportError
|
msg_gen_function += virReportError
|
||||||
msg_gen_function += virReportErrorHelper
|
msg_gen_function += virReportErrorHelper
|
||||||
|
@ -532,14 +532,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED,
|
|||||||
#endif
|
#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:
|
* virRegisterNetworkDriver:
|
||||||
* @driver: pointer to a network driver block
|
* @driver: pointer to a network driver block
|
||||||
@ -944,7 +936,7 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias,
|
|||||||
size_t alias_len;
|
size_t alias_len;
|
||||||
|
|
||||||
if (value->type != VIR_CONF_LIST) {
|
if (value->type != VIR_CONF_LIST) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Expected a list for 'uri_aliases' config parameter"));
|
_("Expected a list for 'uri_aliases' config parameter"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -956,13 +948,13 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias,
|
|||||||
size_t safe;
|
size_t safe;
|
||||||
|
|
||||||
if (entry->type != VIR_CONF_STRING) {
|
if (entry->type != VIR_CONF_STRING) {
|
||||||
virLibConnError(VIR_ERR_CONF_SYNTAX, "%s",
|
virReportError(VIR_ERR_CONF_SYNTAX, "%s",
|
||||||
_("Expected a string for 'uri_aliases' config parameter list entry"));
|
_("Expected a string for 'uri_aliases' config parameter list entry"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(offset = strchr(entry->str, '='))) {
|
if (!(offset = strchr(entry->str, '='))) {
|
||||||
virLibConnError(VIR_ERR_CONF_SYNTAX,
|
virReportError(VIR_ERR_CONF_SYNTAX,
|
||||||
_("Malformed 'uri_aliases' config entry '%s', expected 'alias=uri://host/path'"),
|
_("Malformed 'uri_aliases' config entry '%s', expected 'alias=uri://host/path'"),
|
||||||
entry->str);
|
entry->str);
|
||||||
return -1;
|
return -1;
|
||||||
@ -970,7 +962,7 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias,
|
|||||||
|
|
||||||
safe = strspn(entry->str, URI_ALIAS_CHARS);
|
safe = strspn(entry->str, URI_ALIAS_CHARS);
|
||||||
if (safe < (offset - entry->str)) {
|
if (safe < (offset - entry->str)) {
|
||||||
virLibConnError(VIR_ERR_CONF_SYNTAX,
|
virReportError(VIR_ERR_CONF_SYNTAX,
|
||||||
_("Malformed 'uri_aliases' config entry '%s', aliases may only contain 'a-Z, 0-9, _, -'"),
|
_("Malformed 'uri_aliases' config entry '%s', aliases may only contain 'a-Z, 0-9, _, -'"),
|
||||||
entry->str);
|
entry->str);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1022,7 +1014,7 @@ virConnectGetDefaultURI(virConfPtr conf,
|
|||||||
*name = defname;
|
*name = defname;
|
||||||
} else if ((value = virConfGetValue(conf, "uri_default"))) {
|
} else if ((value = virConfGetValue(conf, "uri_default"))) {
|
||||||
if (value->type != VIR_CONF_STRING) {
|
if (value->type != VIR_CONF_STRING) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Expected a string for 'uri_default' config parameter"));
|
_("Expected a string for 'uri_default' config parameter"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1168,9 +1160,7 @@ do_open(const char *name,
|
|||||||
|
|
||||||
if (!ret->driver) {
|
if (!ret->driver) {
|
||||||
/* If we reach here, then all drivers declined the connection. */
|
/* If we reach here, then all drivers declined the connection. */
|
||||||
virLibConnError(VIR_ERR_NO_CONNECT,
|
virReportError(VIR_ERR_NO_CONNECT, "%s", NULLSTR(name));
|
||||||
"%s",
|
|
||||||
NULLSTR(name));
|
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2539,7 +2529,7 @@ virDomainSave(virDomainPtr domain, const char *to)
|
|||||||
|
|
||||||
/* We must absolutize the file path as the save is done out of process */
|
/* We must absolutize the file path as the save is done out of process */
|
||||||
if (virFileAbsPath(to, &absolute_to) < 0) {
|
if (virFileAbsPath(to, &absolute_to) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute output file path"));
|
_("could not build absolute output file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2630,7 +2620,7 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
|
|||||||
|
|
||||||
/* We must absolutize the file path as the save is done out of process */
|
/* We must absolutize the file path as the save is done out of process */
|
||||||
if (virFileAbsPath(to, &absolute_to) < 0) {
|
if (virFileAbsPath(to, &absolute_to) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute output file path"));
|
_("could not build absolute output file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2680,7 +2670,7 @@ virDomainRestore(virConnectPtr conn, const char *from)
|
|||||||
|
|
||||||
/* We must absolutize the file path as the restore is done out of process */
|
/* We must absolutize the file path as the restore is done out of process */
|
||||||
if (virFileAbsPath(from, &absolute_from) < 0) {
|
if (virFileAbsPath(from, &absolute_from) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute input file path"));
|
_("could not build absolute input file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2757,7 +2747,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
|
|||||||
|
|
||||||
/* We must absolutize the file path as the restore is done out of process */
|
/* We must absolutize the file path as the restore is done out of process */
|
||||||
if (virFileAbsPath(from, &absolute_from) < 0) {
|
if (virFileAbsPath(from, &absolute_from) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute input file path"));
|
_("could not build absolute input file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2811,7 +2801,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
|
|||||||
virCheckNonNullArgGoto(file, error);
|
virCheckNonNullArgGoto(file, error);
|
||||||
|
|
||||||
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
_("virDomainSaveImageGetXMLDesc with secure flag"));
|
_("virDomainSaveImageGetXMLDesc with secure flag"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2822,7 +2812,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
|
|||||||
|
|
||||||
/* We must absolutize the file path as the read is done out of process */
|
/* We must absolutize the file path as the read is done out of process */
|
||||||
if (virFileAbsPath(file, &absolute_file) < 0) {
|
if (virFileAbsPath(file, &absolute_file) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute input file path"));
|
_("could not build absolute input file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2898,7 +2888,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file,
|
|||||||
|
|
||||||
/* We must absolutize the file path as the read is done out of process */
|
/* We must absolutize the file path as the read is done out of process */
|
||||||
if (virFileAbsPath(file, &absolute_file) < 0) {
|
if (virFileAbsPath(file, &absolute_file) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute input file path"));
|
_("could not build absolute input file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -2985,7 +2975,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags)
|
|||||||
|
|
||||||
/* We must absolutize the file path as the save is done out of process */
|
/* We must absolutize the file path as the save is done out of process */
|
||||||
if (virFileAbsPath(to, &absolute_to) < 0) {
|
if (virFileAbsPath(to, &absolute_to) < 0) {
|
||||||
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not build absolute core file path"));
|
_("could not build absolute core file path"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -3445,7 +3435,7 @@ virDomainGetMaxMemory(virDomainPtr domain)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto error;
|
goto error;
|
||||||
if ((unsigned long) ret != ret) {
|
if ((unsigned long) ret != ret) {
|
||||||
virLibDomainError(VIR_ERR_OVERFLOW, _("result too large: %llu"),
|
virReportError(VIR_ERR_OVERFLOW, _("result too large: %llu"),
|
||||||
ret);
|
ret);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -4252,7 +4242,7 @@ virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
conn = domain->conn;
|
conn = domain->conn;
|
||||||
|
|
||||||
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
_("virDomainGetXMLDesc with secure flag"));
|
_("virDomainGetXMLDesc with secure flag"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -9313,7 +9303,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
|
|||||||
virCheckNonZeroArgGoto(nvcpus, error);
|
virCheckNonZeroArgGoto(nvcpus, error);
|
||||||
|
|
||||||
if ((unsigned short) nvcpus != nvcpus) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
conn = domain->conn;
|
conn = domain->conn;
|
||||||
@ -9440,7 +9430,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
|
|||||||
virCheckPositiveArgGoto(maplen, error);
|
virCheckPositiveArgGoto(maplen, error);
|
||||||
|
|
||||||
if ((unsigned short) vcpu != vcpu) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9512,7 +9502,7 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu,
|
|||||||
virCheckPositiveArgGoto(maplen, error);
|
virCheckPositiveArgGoto(maplen, error);
|
||||||
|
|
||||||
if ((unsigned short) vcpu != vcpu) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9575,7 +9565,7 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps,
|
|||||||
virCheckPositiveArgGoto(maplen, error);
|
virCheckPositiveArgGoto(maplen, error);
|
||||||
|
|
||||||
if (INT_MULTIPLY_OVERFLOW(ncpumaps, maplen)) {
|
if (INT_MULTIPLY_OVERFLOW(ncpumaps, maplen)) {
|
||||||
virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
|
virReportError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
|
||||||
ncpumaps, maplen);
|
ncpumaps, maplen);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -9787,7 +9777,7 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
|
|||||||
virCheckZeroArgGoto(maplen, error);
|
virCheckZeroArgGoto(maplen, error);
|
||||||
|
|
||||||
if (cpumaps && INT_MULTIPLY_OVERFLOW(maxinfo, maplen)) {
|
if (cpumaps && INT_MULTIPLY_OVERFLOW(maxinfo, maplen)) {
|
||||||
virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
|
virReportError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"),
|
||||||
maxinfo, maplen);
|
maxinfo, maplen);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -15889,7 +15879,7 @@ virStreamSendAll(virStreamPtr stream,
|
|||||||
virCheckNonNullArgGoto(handler, cleanup);
|
virCheckNonNullArgGoto(handler, cleanup);
|
||||||
|
|
||||||
if (stream->flags & VIR_STREAM_NONBLOCK) {
|
if (stream->flags & VIR_STREAM_NONBLOCK) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("data sources cannot be used for non-blocking streams"));
|
_("data sources cannot be used for non-blocking streams"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -15982,7 +15972,7 @@ virStreamRecvAll(virStreamPtr stream,
|
|||||||
virCheckNonNullArgGoto(handler, cleanup);
|
virCheckNonNullArgGoto(handler, cleanup);
|
||||||
|
|
||||||
if (stream->flags & VIR_STREAM_NONBLOCK) {
|
if (stream->flags & VIR_STREAM_NONBLOCK) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("data sinks cannot be used for non-blocking streams"));
|
_("data sinks cannot be used for non-blocking streams"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -18191,7 +18181,7 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||||||
conn = snapshot->domain->conn;
|
conn = snapshot->domain->conn;
|
||||||
|
|
||||||
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
_("virDomainSnapshotGetXMLDesc with secure flag"));
|
_("virDomainSnapshotGetXMLDesc with secure flag"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -19931,7 +19921,7 @@ virConnectRegisterCloseCallback(virConnectPtr conn,
|
|||||||
virCheckNonNullArgGoto(cb, error);
|
virCheckNonNullArgGoto(cb, error);
|
||||||
|
|
||||||
if (conn->closeCallback->callback) {
|
if (conn->closeCallback->callback) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("A close callback is already registered"));
|
_("A close callback is already registered"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -19984,7 +19974,7 @@ virConnectUnregisterCloseCallback(virConnectPtr conn,
|
|||||||
virCheckNonNullArgGoto(cb, error);
|
virCheckNonNullArgGoto(cb, error);
|
||||||
|
|
||||||
if (conn->closeCallback->callback != cb) {
|
if (conn->closeCallback->callback != cb) {
|
||||||
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("A different callback was requested"));
|
_("A different callback was requested"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -20274,7 +20264,7 @@ virDomainGetCPUStats(virDomainPtr domain,
|
|||||||
virCheckNullArgGoto(params, error);
|
virCheckNullArgGoto(params, error);
|
||||||
|
|
||||||
if (nparams && ncpus > UINT_MAX / nparams) {
|
if (nparams && ncpus > UINT_MAX / nparams) {
|
||||||
virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u * %u"),
|
virReportError(VIR_ERR_OVERFLOW, _("input too large: %u * %u"),
|
||||||
nparams, ncpus);
|
nparams, ncpus);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user