提交 cf8cff03 编写于 作者: D Daniel P. Berrange

Replace use of ESX_ERROR & ESX_VI_ERROR with virReportError

Update the ESX driver to use virReportError instead of
the ESX_ERROR & ESX_VI_ERROR custom macros
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 7f4ed3ec
......@@ -506,8 +506,6 @@ sc_avoid_attribute_unused_in_header:
# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
msg_gen_function =
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
msg_gen_function += HYPERV_ERROR
msg_gen_function += PHYP_ERROR
msg_gen_function += VIR_ERROR
......
此差异已折叠。
......@@ -28,10 +28,6 @@
# include "capabilities.h"
# include "esx_vi.h"
# define ESX_ERROR(code, ...) \
virReportErrorHelper(VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
typedef struct _esxPrivate {
esxVI_Context *primary; /* points to host or vCenter */
esxVI_Context *host;
......
......@@ -84,7 +84,7 @@ esxStoragePoolLookupType(esxVI_Context *ctx, const char *poolName,
} else if (esxVI_VmfsDatastoreInfo_DynamicCast(datastoreInfo) != NULL) {
*poolType = VIR_STORAGE_POOL_FS;
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("DatastoreInfo has unexpected type"));
goto cleanup;
}
......@@ -336,7 +336,7 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
if (datastore == NULL) {
virUUIDFormat(uuid, uuid_string);
ESX_VI_ERROR(VIR_ERR_NO_STORAGE_POOL,
virReportError(VIR_ERR_NO_STORAGE_POOL,
_("Could not find datastore with UUID '%s'"),
uuid_string);
......@@ -557,7 +557,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
} else if (STRCASEEQ(nasInfo->nas->type, "CIFS")) {
def.source.format = VIR_STORAGE_POOL_NETFS_CIFS;
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Datastore has unexpected type '%s'"),
nasInfo->nas->type);
goto cleanup;
......@@ -569,7 +569,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
* VMFS based datastore in libvirt terms
*/
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("DatastoreInfo has unexpected type"));
goto cleanup;
}
......@@ -607,7 +607,7 @@ esxStoragePoolSetAutostart(virStoragePoolPtr pool ATTRIBUTE_UNUSED,
autostart = (autostart != 0);
if (! autostart) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot deactivate storage pool autostart"));
return -1;
}
......@@ -670,7 +670,7 @@ esxStoragePoolListStorageVolumes(virStoragePoolPtr pool, char **const names,
int i;
if (names == NULL || maxnames < 0) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
......@@ -837,7 +837,7 @@ esxStorageVolumeLookupByKey(virConnectPtr conn, const char *key)
}
if (!priv->primary->hasQueryVirtualDiskUuid) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("QueryVirtualDiskUuid not available, cannot lookup storage "
"volume by UUID"));
return NULL;
......@@ -999,7 +999,7 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
}
if (def->type != VIR_STORAGE_VOL_FILE) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
......@@ -1008,14 +1008,14 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
tmp = strrchr(def->name, '/');
if (tmp == NULL || *def->name == '/' || tmp[1] == '\0') {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Volume name '%s' doesn't have expected format "
"'<directory>/<file>'"), def->name);
goto cleanup;
}
if (! virFileHasSuffix(def->name, ".vmdk")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Volume name '%s' has unsupported suffix, expecting '.vmdk'"),
def->name);
goto cleanup;
......@@ -1095,7 +1095,7 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
*/
virtualDiskSpec->diskType = (char *)"thin";
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unsupported capacity-to-allocation relation"));
goto cleanup;
}
......@@ -1122,7 +1122,7 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
}
if (taskInfoState != esxVI_TaskInfoState_Success) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not create volume: %s"),
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not create volume: %s"),
taskInfoErrorMessage);
goto cleanup;
}
......@@ -1149,7 +1149,7 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
}
}
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
......@@ -1233,7 +1233,7 @@ esxStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
}
if (def->type != VIR_STORAGE_VOL_FILE) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
......@@ -1242,14 +1242,14 @@ esxStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
tmp = strrchr(def->name, '/');
if (tmp == NULL || *def->name == '/' || tmp[1] == '\0') {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Volume name '%s' doesn't have expected format "
"'<directory>/<file>'"), def->name);
goto cleanup;
}
if (! virFileHasSuffix(def->name, ".vmdk")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Volume name '%s' has unsupported suffix, expecting '.vmdk'"),
def->name);
goto cleanup;
......@@ -1324,7 +1324,7 @@ esxStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
}
if (taskInfoState != esxVI_TaskInfoState_Success) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not copy volume: %s"),
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not copy volume: %s"),
taskInfoErrorMessage);
goto cleanup;
}
......@@ -1351,7 +1351,7 @@ esxStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
}
}
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
......@@ -1412,7 +1412,7 @@ esxStorageVolumeDelete(virStorageVolPtr volume, unsigned int flags)
}
if (taskInfoState != esxVI_TaskInfoState_Success) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not delete volume: %s"),
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not delete volume: %s"),
taskInfoErrorMessage);
goto cleanup;
}
......@@ -1461,7 +1461,7 @@ esxStorageVolumeWipe(virStorageVolPtr volume, unsigned int flags)
}
if (taskInfoState != esxVI_TaskInfoState_Success) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not wipe volume: %s"),
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not wipe volume: %s"),
taskInfoErrorMessage);
goto cleanup;
}
......@@ -1595,7 +1595,7 @@ esxStorageVolumeGetXMLDesc(virStorageVolPtr volume, unsigned int flags)
def.target.format = VIR_STORAGE_FILE_RAW;
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("File '%s' has unknown type"), datastorePath);
goto cleanup;
}
......
......@@ -50,7 +50,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
char *tmp;
if (parsedUri == NULL || *parsedUri != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
......@@ -74,7 +74,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
if (STRNEQ((*parsedUri)->transport, "http") &&
STRNEQ((*parsedUri)->transport, "https")) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("Query parameter 'transport' has unexpected value "
"'%s' (should be http|https)"),
(*parsedUri)->transport);
......@@ -92,7 +92,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
} else if (STRCASEEQ(queryParam->name, "no_verify")) {
if (virStrToLong_i(queryParam->value, NULL, 10, &noVerify) < 0 ||
(noVerify != 0 && noVerify != 1)) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("Query parameter 'no_verify' has unexpected value "
"'%s' (should be 0 or 1)"), queryParam->value);
goto cleanup;
......@@ -102,7 +102,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
} else if (STRCASEEQ(queryParam->name, "auto_answer")) {
if (virStrToLong_i(queryParam->value, NULL, 10, &autoAnswer) < 0 ||
(autoAnswer != 0 && autoAnswer != 1)) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("Query parameter 'auto_answer' has unexpected "
"value '%s' (should be 0 or 1)"), queryParam->value);
goto cleanup;
......@@ -128,7 +128,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
} else if ((tmp = strstr(queryParam->value, "://")) != NULL) {
*tmp = '\0';
ESX_ERROR(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("Query parameter 'proxy' contains unexpected "
"type '%s' (should be (http|socks(|4|4a|5))"),
queryParam->value);
......@@ -146,7 +146,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
if ((tmp = strchr((*parsedUri)->proxy_hostname, ':')) != NULL) {
if (tmp == (*parsedUri)->proxy_hostname) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Query parameter 'proxy' doesn't contain a "
"hostname"));
goto cleanup;
......@@ -158,7 +158,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
&(*parsedUri)->proxy_port) < 0 ||
(*parsedUri)->proxy_port < 1 ||
(*parsedUri)->proxy_port > 65535) {
ESX_ERROR(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("Query parameter 'proxy' has unexpected port"
"value '%s' (should be [1..65535])"), tmp);
goto cleanup;
......@@ -255,7 +255,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
if ((datastoreName != NULL && *datastoreName != NULL) ||
(directoryName != NULL && *directoryName != NULL) ||
(directoryAndFileName != NULL && *directoryAndFileName != NULL)) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
......@@ -266,7 +266,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
/* Expected format: '[<datastore>] <path>' where <path> is optional */
if ((tmp = STRSKIP(copyOfDatastorePath, "[")) == NULL || *tmp == ']' ||
(preliminaryDatastoreName = strtok_r(tmp, "]", &saveptr)) == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Datastore path '%s' doesn't have expected format "
"'[<datastore>] <path>'"), datastorePath);
goto cleanup;
......@@ -349,14 +349,14 @@ esxUtil_ResolveHostname(const char *hostname,
errcode = getaddrinfo(hostname, NULL, &hints, &result);
if (errcode != 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("IP address lookup for host '%s' failed: %s"), hostname,
gai_strerror(errcode));
return -1;
}
if (result == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No IP address for host '%s' found: %s"), hostname,
gai_strerror(errcode));
return -1;
......@@ -366,7 +366,7 @@ esxUtil_ResolveHostname(const char *hostname,
ipAddress_length, NULL, 0, NI_NUMERICHOST);
if (errcode != 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Formatting IP address for host '%s' failed: %s"), hostname,
gai_strerror(errcode));
freeaddrinfo(result);
......@@ -386,7 +386,7 @@ esxUtil_ReformatUuid(const char *input, char *output)
unsigned char uuid[VIR_UUID_BUFLEN];
if (virUUIDParse(input, uuid) < 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse UUID from string '%s'"),
input);
return -1;
......
此差异已折叠。
......@@ -35,13 +35,6 @@
# include "esx_util.h"
# define ESX_VI_ERROR(code, ...) \
virReportErrorHelper(VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
# define ESX_VI__SOAP__REQUEST_HEADER \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
"<soapenv:Envelope\n" \
......
......@@ -41,7 +41,7 @@
#define ESX_VI__METHOD__CHECK_OUTPUT__NotNone \
if (output == NULL || *output != 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
return -1; \
}
......@@ -162,7 +162,7 @@
esxVI_##_type *_this = NULL; \
\
if (ctx->service == NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call")); \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call")); \
return -1; \
} \
\
......@@ -183,7 +183,7 @@
*/
#define ESX_VI__METHOD__PARAMETER__REQUIRE(_name) \
if (_name == 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
virReportError(VIR_ERR_INTERNAL_ERROR, \
"Required parameter '%s' is missing for call to %s", \
#_name, methodName); \
return -1; \
......@@ -237,7 +237,7 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx,
esxVI_Response *response = NULL;
if (serviceContent == NULL || *serviceContent != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册