提交 028db0bf 编写于 作者: M Matthias Bolte

esx: Mark error messages for translation

Also define ESX_ERROR and ESX_VI_ERROR in a central place, instead of
defining them in each source file.

Add ESX_ERROR and ESX_VI_ERROR to the msg_gen_function list in cfg.mk.

Update po/POTFILES.in accordingly.
上级 dbfa2ff5
...@@ -172,6 +172,8 @@ msg_gen_function += DEBUG0 ...@@ -172,6 +172,8 @@ msg_gen_function += DEBUG0
msg_gen_function += DISABLE_fprintf msg_gen_function += DISABLE_fprintf
msg_gen_function += ERROR msg_gen_function += ERROR
msg_gen_function += ERROR0 msg_gen_function += ERROR0
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
msg_gen_function += REMOTE_DEBUG msg_gen_function += REMOTE_DEBUG
msg_gen_function += ReportError msg_gen_function += ReportError
msg_gen_function += VIR_FREE msg_gen_function += VIR_FREE
......
...@@ -18,6 +18,12 @@ src/cpu/cpu_generic.c ...@@ -18,6 +18,12 @@ src/cpu/cpu_generic.c
src/cpu/cpu_map.c src/cpu/cpu_map.c
src/cpu/cpu_x86.c src/cpu/cpu_x86.c
src/datatypes.c src/datatypes.c
src/esx/esx_driver.c
src/esx/esx_util.c
src/esx/esx_vi.c
src/esx/esx_vi_methods.c
src/esx/esx_vi_types.c
src/esx/esx_vmx.c
src/interface/netcf_driver.c src/interface/netcf_driver.c
src/libvirt.c src/libvirt.c
src/lxc/lxc_container.c src/lxc/lxc_container.c
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <config.h> #include <config.h>
#include "internal.h" #include "internal.h"
#include "virterror_internal.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
...@@ -38,10 +37,6 @@ ...@@ -38,10 +37,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_ERROR(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
static virDrvOpenStatus static virDrvOpenStatus
......
此差异已折叠。
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <config.h> #include <config.h>
#include "internal.h" #include "internal.h"
#include "virterror_internal.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
...@@ -38,10 +37,6 @@ ...@@ -38,10 +37,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_ERROR(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
static virDrvOpenStatus static virDrvOpenStatus
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <config.h> #include <config.h>
#include "internal.h" #include "internal.h"
#include "virterror_internal.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
...@@ -38,10 +37,6 @@ ...@@ -38,10 +37,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_ERROR(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
static virDrvOpenStatus static virDrvOpenStatus
......
...@@ -24,9 +24,14 @@ ...@@ -24,9 +24,14 @@
# define __ESX_PRIVATE_H__ # define __ESX_PRIVATE_H__
# include "internal.h" # include "internal.h"
# include "virterror_internal.h"
# include "capabilities.h" # include "capabilities.h"
# include "esx_vi.h" # include "esx_vi.h"
# define ESX_ERROR(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
typedef struct _esxPrivate { typedef struct _esxPrivate {
esxVI_Context *host; esxVI_Context *host;
esxVI_Context *vCenter; esxVI_Context *vCenter;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <config.h> #include <config.h>
#include "internal.h" #include "internal.h"
#include "virterror_internal.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
...@@ -37,10 +36,6 @@ ...@@ -37,10 +36,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_ERROR(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
static virDrvOpenStatus static virDrvOpenStatus
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <config.h> #include <config.h>
#include "internal.h" #include "internal.h"
#include "virterror_internal.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
...@@ -38,10 +37,6 @@ ...@@ -38,10 +37,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_ERROR(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
static virDrvOpenStatus static virDrvOpenStatus
......
...@@ -27,21 +27,17 @@ ...@@ -27,21 +27,17 @@
#include <netdb.h> #include <netdb.h>
#include "internal.h" #include "internal.h"
#include "virterror_internal.h"
#include "datatypes.h" #include "datatypes.h"
#include "qparams.h" #include "qparams.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
#include "uuid.h" #include "uuid.h"
#include "esx_private.h"
#include "esx_util.h" #include "esx_util.h"
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_ERROR(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
/* AI_ADDRCONFIG is missing on some systems. */ /* AI_ADDRCONFIG is missing on some systems. */
#ifndef AI_ADDRCONFIG #ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0 # define AI_ADDRCONFIG 0
...@@ -101,8 +97,8 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter, ...@@ -101,8 +97,8 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
if (STRNEQ(*transport, "http") && STRNEQ(*transport, "https")) { if (STRNEQ(*transport, "http") && STRNEQ(*transport, "https")) {
ESX_ERROR(VIR_ERR_INVALID_ARG, ESX_ERROR(VIR_ERR_INVALID_ARG,
"Query parameter 'transport' has unexpected value " _("Query parameter 'transport' has unexpected value "
"'%s' (should be http|https)", *transport); "'%s' (should be http|https)"), *transport);
goto failure; goto failure;
} }
} else if (STRCASEEQ(queryParam->name, "vcenter")) { } else if (STRCASEEQ(queryParam->name, "vcenter")) {
...@@ -124,8 +120,8 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter, ...@@ -124,8 +120,8 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 || if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 ||
(*noVerify != 0 && *noVerify != 1)) { (*noVerify != 0 && *noVerify != 1)) {
ESX_ERROR(VIR_ERR_INVALID_ARG, ESX_ERROR(VIR_ERR_INVALID_ARG,
"Query parameter 'no_verify' has unexpected value " _("Query parameter 'no_verify' has unexpected value "
"'%s' (should be 0 or 1)", queryParam->value); "'%s' (should be 0 or 1)"), queryParam->value);
goto failure; goto failure;
} }
} else if (STRCASEEQ(queryParam->name, "auto_answer")) { } else if (STRCASEEQ(queryParam->name, "auto_answer")) {
...@@ -136,8 +132,8 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter, ...@@ -136,8 +132,8 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
if (virStrToLong_i(queryParam->value, NULL, 10, autoAnswer) < 0 || if (virStrToLong_i(queryParam->value, NULL, 10, autoAnswer) < 0 ||
(*autoAnswer != 0 && *autoAnswer != 1)) { (*autoAnswer != 0 && *autoAnswer != 1)) {
ESX_ERROR(VIR_ERR_INVALID_ARG, ESX_ERROR(VIR_ERR_INVALID_ARG,
"Query parameter 'auto_answer' has unexpected value " _("Query parameter 'auto_answer' has unexpected "
"'%s' (should be 0 or 1)", queryParam->value); "value '%s' (should be 0 or 1)"), queryParam->value);
goto failure; goto failure;
} }
} else { } else {
...@@ -213,7 +209,7 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath, ...@@ -213,7 +209,7 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath,
if (datastoreName == NULL || *datastoreName != NULL || if (datastoreName == NULL || *datastoreName != NULL ||
directoryName == NULL || *directoryName != NULL || directoryName == NULL || *directoryName != NULL ||
fileName == NULL || *fileName != NULL) { fileName == NULL || *fileName != NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -234,8 +230,8 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath, ...@@ -234,8 +230,8 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath,
if (sscanf(datastoreRelatedPath, "[%a[^]%]] %a[^\n]", datastoreName, if (sscanf(datastoreRelatedPath, "[%a[^]%]] %a[^\n]", datastoreName,
&directoryAndFileName) != 2) { &directoryAndFileName) != 2) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Datastore related path '%s' doesn't have expected format " _("Datastore related path '%s' doesn't have expected format "
"'[<datastore>] <path>'", datastoreRelatedPath); "'[<datastore>] <path>'"), datastoreRelatedPath);
goto failure; goto failure;
} }
...@@ -250,7 +246,7 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath, ...@@ -250,7 +246,7 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath,
if (*separator == '\0') { if (*separator == '\0') {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Datastore related path '%s' doesn't reference a file", _("Datastore related path '%s' doesn't reference a file"),
datastoreRelatedPath); datastoreRelatedPath);
goto failure; goto failure;
} }
...@@ -302,14 +298,14 @@ esxUtil_ResolveHostname(const char *hostname, ...@@ -302,14 +298,14 @@ esxUtil_ResolveHostname(const char *hostname,
if (errcode != 0) { if (errcode != 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"IP address lookup for host '%s' failed: %s", hostname, _("IP address lookup for host '%s' failed: %s"), hostname,
gai_strerror(errcode)); gai_strerror(errcode));
return -1; return -1;
} }
if (result == NULL) { if (result == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"No IP address for host '%s' found: %s", hostname, _("No IP address for host '%s' found: %s"), hostname,
gai_strerror(errcode)); gai_strerror(errcode));
return -1; return -1;
} }
...@@ -319,7 +315,7 @@ esxUtil_ResolveHostname(const char *hostname, ...@@ -319,7 +315,7 @@ esxUtil_ResolveHostname(const char *hostname,
if (errcode != 0) { if (errcode != 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Formating IP address for host '%s' failed: %s", hostname, _("Formating IP address for host '%s' failed: %s"), hostname,
gai_strerror(errcode)); gai_strerror(errcode));
freeaddrinfo(result); freeaddrinfo(result);
return -1; return -1;
...@@ -347,13 +343,13 @@ esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string, ...@@ -347,13 +343,13 @@ esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string,
} }
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
if (value->type != VIR_CONF_STRING) { if (value->type != VIR_CONF_STRING) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Config entry '%s' must be a string", name); _("Config entry '%s' must be a string"), name);
return -1; return -1;
} }
...@@ -363,7 +359,7 @@ esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string, ...@@ -363,7 +359,7 @@ esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string,
} }
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
...@@ -392,14 +388,14 @@ esxUtil_GetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid, ...@@ -392,14 +388,14 @@ esxUtil_GetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid,
return 0; return 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
} }
if (value->type != VIR_CONF_STRING) { if (value->type != VIR_CONF_STRING) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Config entry '%s' must be a string", name); _("Config entry '%s' must be a string"), name);
return -1; return -1;
} }
...@@ -408,14 +404,14 @@ esxUtil_GetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid, ...@@ -408,14 +404,14 @@ esxUtil_GetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid,
return 0; return 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
} }
if (virUUIDParse(value->str, uuid) < 0) { if (virUUIDParse(value->str, uuid) < 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Could not parse UUID from string '%s'", value->str); _("Could not parse UUID from string '%s'"), value->str);
return -1; return -1;
} }
...@@ -438,7 +434,7 @@ esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number, ...@@ -438,7 +434,7 @@ esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number,
return 0; return 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
} }
...@@ -449,7 +445,7 @@ esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number, ...@@ -449,7 +445,7 @@ esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number,
return 0; return 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
} }
...@@ -458,13 +454,13 @@ esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number, ...@@ -458,13 +454,13 @@ esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number,
*number = -1; *number = -1;
} else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) { } else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Config entry '%s' must represent an integer value", _("Config entry '%s' must represent an integer value"),
name); name);
return -1; return -1;
} }
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Config entry '%s' must be a string", name); _("Config entry '%s' must be a string"), name);
return -1; return -1;
} }
...@@ -487,7 +483,7 @@ esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, int *boolean_, ...@@ -487,7 +483,7 @@ esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, int *boolean_,
return 0; return 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
} }
...@@ -498,7 +494,7 @@ esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, int *boolean_, ...@@ -498,7 +494,7 @@ esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, int *boolean_,
return 0; return 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Missing essential config entry '%s'", name); _("Missing essential config entry '%s'"), name);
return -1; return -1;
} }
} }
...@@ -509,13 +505,13 @@ esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, int *boolean_, ...@@ -509,13 +505,13 @@ esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, int *boolean_,
*boolean_ = 0; *boolean_ = 0;
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Config entry '%s' must represent a boolean value " _("Config entry '%s' must represent a boolean value "
"(true|false)", name); "(true|false)"), name);
return -1; return -1;
} }
} else { } else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Config entry '%s' must be a string", name); _("Config entry '%s' must be a string"), name);
return -1; return -1;
} }
......
此差异已折叠。
...@@ -28,9 +28,18 @@ ...@@ -28,9 +28,18 @@
# include <curl/curl.h> # include <curl/curl.h>
# include "internal.h" # include "internal.h"
# include "virterror_internal.h"
# include "datatypes.h" # include "datatypes.h"
# include "esx_vi_types.h" # include "esx_vi_types.h"
# define ESX_VI_ERROR(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
typedef enum _esxVI_APIVersion esxVI_APIVersion; typedef enum _esxVI_APIVersion esxVI_APIVersion;
typedef enum _esxVI_ProductVersion esxVI_ProductVersion; typedef enum _esxVI_ProductVersion esxVI_ProductVersion;
typedef enum _esxVI_Occurrence esxVI_Occurrence; typedef enum _esxVI_Occurrence esxVI_Occurrence;
......
...@@ -27,15 +27,12 @@ ...@@ -27,15 +27,12 @@
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
#include "uuid.h" #include "uuid.h"
#include "virterror_internal.h"
#include "esx_vi_methods.h" #include "esx_vi_methods.h"
#include "esx_util.h" #include "esx_util.h"
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_VI_ERROR(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
#define ESX_VI__SOAP__REQUEST_HEADER \ #define ESX_VI__SOAP__REQUEST_HEADER \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
...@@ -46,6 +43,8 @@ ...@@ -46,6 +43,8 @@
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" \ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" \
"<soapenv:Body>" "<soapenv:Body>"
#define ESX_VI__SOAP__REQUEST_FOOTER \ #define ESX_VI__SOAP__REQUEST_FOOTER \
"</soapenv:Body>" \ "</soapenv:Body>" \
"</soapenv:Envelope>" "</soapenv:Envelope>"
...@@ -109,7 +108,7 @@ ...@@ -109,7 +108,7 @@
#define ESX_VI__METHOD__CHECK_SERVICE() \ #define ESX_VI__METHOD__CHECK_SERVICE() \
if (ctx->service == NULL) { \ if (ctx->service == NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call")); \
return -1; \ return -1; \
} }
...@@ -117,7 +116,7 @@ ...@@ -117,7 +116,7 @@
#define ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(_name) \ #define ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(_name) \
if (_name == NULL || *_name != NULL) { \ if (_name == NULL || *_name != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
return -1; \ return -1; \
} }
...@@ -198,7 +197,7 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx, ...@@ -198,7 +197,7 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx,
esxVI_Response *response = NULL; esxVI_Response *response = NULL;
if (serviceContent == NULL || *serviceContent != NULL) { if (serviceContent == NULL || *serviceContent != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -276,7 +275,7 @@ ESX_VI__METHOD(SessionIsActive, ...@@ -276,7 +275,7 @@ ESX_VI__METHOD(SessionIsActive,
ESX_VI__METHOD__CHECK_SERVICE() ESX_VI__METHOD__CHECK_SERVICE()
if (active == NULL) { if (active == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
}, },
......
...@@ -32,16 +32,11 @@ ...@@ -32,16 +32,11 @@
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
#include "util.h" #include "util.h"
#include "virterror_internal.h"
#include "esx_vi.h" #include "esx_vi.h"
#include "esx_vi_types.h" #include "esx_vi_types.h"
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
#define ESX_VI_ERROR(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
#define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \ #define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \
...@@ -123,7 +118,8 @@ ...@@ -123,7 +118,8 @@
esxVI_##_type##_DeepCopy(esxVI_##_type **dest, esxVI_##_type *src) \ esxVI_##_type##_DeepCopy(esxVI_##_type **dest, esxVI_##_type *src) \
{ \ { \
if (dest == NULL || *dest != NULL) { \ if (dest == NULL || *dest != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \ return -1; \
} \ } \
\ \
...@@ -213,7 +209,8 @@ ...@@ -213,7 +209,8 @@
esxVI_##_type **ptrptr) \ esxVI_##_type **ptrptr) \
{ \ { \
if (anyType == NULL || ptrptr == NULL || *ptrptr != NULL) { \ if (anyType == NULL || ptrptr == NULL || *ptrptr != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \ return -1; \
} \ } \
\ \
...@@ -236,7 +233,8 @@ ...@@ -236,7 +233,8 @@
const char *element, virBufferPtr output) \ const char *element, virBufferPtr output) \
{ \ { \
if (element == NULL || output == NULL ) { \ if (element == NULL || output == NULL ) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \ return -1; \
} \ } \
\ \
...@@ -274,7 +272,8 @@ ...@@ -274,7 +272,8 @@
xmlNodePtr childNode = NULL; \ xmlNodePtr childNode = NULL; \
\ \
if (ptrptr == NULL || *ptrptr != NULL) { \ if (ptrptr == NULL || *ptrptr != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \ return -1; \
} \ } \
\ \
...@@ -318,7 +317,8 @@ ...@@ -318,7 +317,8 @@
long long value; \ long long value; \
\ \
if (number == NULL || *number != NULL) { \ if (number == NULL || *number != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \ return -1; \
} \ } \
\ \
...@@ -565,7 +565,8 @@ ...@@ -565,7 +565,8 @@
esxVI_##__type##_DynamicCast(void *item) \ esxVI_##__type##_DynamicCast(void *item) \
{ \ { \
if (item == NULL) { \ if (item == NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return NULL; \ return NULL; \
} \ } \
\ \
...@@ -709,7 +710,7 @@ esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type) ...@@ -709,7 +710,7 @@ esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type)
{ {
if (anyType->type != type) { if (anyType->type != type) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"Expecting type '%s' but found '%s'", _("Expecting type '%s' but found '%s'"),
esxVI_Type_ToString(type), esxVI_Type_ToString(type),
anyType->type != esxVI_Type_Other anyType->type != esxVI_Type_Other
? esxVI_Type_ToString(anyType->type) ? esxVI_Type_ToString(anyType->type)
...@@ -724,7 +725,7 @@ int ...@@ -724,7 +725,7 @@ int
esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
{ {
if (dest == NULL || *dest != NULL) { if (dest == NULL || *dest != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -740,7 +741,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) ...@@ -740,7 +741,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
(*dest)->node = xmlCopyNode(src->node, 1); (*dest)->node = xmlCopyNode(src->node, 1);
if ((*dest)->node == NULL) { if ((*dest)->node == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Could not copy an XML node"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not copy an XML node"));
goto failure; goto failure;
} }
...@@ -790,7 +792,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -790,7 +792,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
long long int number; long long int number;
if (anyType == NULL || *anyType != NULL) { if (anyType == NULL || *anyType != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -801,7 +803,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -801,7 +803,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
(*anyType)->node = xmlCopyNode(node, 1); (*anyType)->node = xmlCopyNode(node, 1);
if ((*anyType)->node == NULL) { if ((*anyType)->node == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Could not copy an XML node"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not copy an XML node"));
goto failure; goto failure;
} }
...@@ -811,8 +814,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -811,8 +814,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
BAD_CAST "http://www.w3.org/2001/XMLSchema-instance"); BAD_CAST "http://www.w3.org/2001/XMLSchema-instance");
if ((*anyType)->other == NULL) { if ((*anyType)->other == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
"AnyType is missing 'type' property"); _("AnyType is missing 'type' property"));
goto failure; goto failure;
} }
...@@ -820,7 +823,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -820,7 +823,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
if ((*anyType)->type == esxVI_Type_Undefined) { if ((*anyType)->type == esxVI_Type_Undefined) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"Unknown value '%s' for AnyType 'type' property", _("Unknown value '%s' for AnyType 'type' property"),
(*anyType)->other); (*anyType)->other);
goto failure; goto failure;
} }
...@@ -837,19 +840,19 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -837,19 +840,19 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
} }
} }
#define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \ #define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \
do { \ do { \
if (virStrToLong_ll((*anyType)->value, NULL, 10, &number) < 0) { \ if (virStrToLong_ll((*anyType)->value, NULL, 10, &number) < 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
"Unknown value '%s' for "_xsdType, \ _("Unknown value '%s' for %s"), \
(*anyType)->value); \ (*anyType)->value, _xsdType); \
goto failure; \ goto failure; \
} \ } \
\ \
if (number < (_min) || number > (_max)) { \ if (number < (_min) || number > (_max)) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
"Value '%s' is out of "_xsdType" range", \ _("Value '%s' is out of %s range"), \
(*anyType)->value); \ (*anyType)->value, _xsdType); \
goto failure; \ goto failure; \
} \ } \
\ \
...@@ -864,7 +867,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -864,7 +867,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
(*anyType)->boolean = esxVI_Boolean_False; (*anyType)->boolean = esxVI_Boolean_False;
} else { } else {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"Unknown value '%s' for xsd:boolean", _("Unknown value '%s' for xsd:boolean"),
(*anyType)->value); (*anyType)->value);
goto failure; goto failure;
} }
...@@ -995,7 +998,7 @@ int ...@@ -995,7 +998,7 @@ int
esxVI_String_DeepCopyValue(char **dest, const char *src) esxVI_String_DeepCopyValue(char **dest, const char *src)
{ {
if (dest == NULL || *dest != NULL) { if (dest == NULL || *dest != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -1029,7 +1032,7 @@ esxVI_String_SerializeValue(const char *value, const char *element, ...@@ -1029,7 +1032,7 @@ esxVI_String_SerializeValue(const char *value, const char *element,
virBufferPtr output) virBufferPtr output)
{ {
if (element == NULL || output == NULL) { if (element == NULL || output == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -1059,7 +1062,7 @@ int ...@@ -1059,7 +1062,7 @@ int
esxVI_String_DeserializeValue(xmlNodePtr node, char **value) esxVI_String_DeserializeValue(xmlNodePtr node, char **value)
{ {
if (value == NULL || *value != NULL) { if (value == NULL || *value != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -1184,7 +1187,7 @@ int ...@@ -1184,7 +1187,7 @@ int
esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime) esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
{ {
if (dateTime == NULL || *dateTime != NULL) { if (dateTime == NULL || *dateTime != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -1196,9 +1199,9 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime) ...@@ -1196,9 +1199,9 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
(char *)xmlNodeListGetString(node->doc, node->children, 1); (char *)xmlNodeListGetString(node->doc, node->children, 1);
if ((*dateTime)->value == NULL) { if ((*dateTime)->value == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
"XML node doesn't contain text, expecting an " _("XML node doesn't contain text, expecting an "
"xsd:dateTime value"); "xsd:dateTime value"));
goto failure; goto failure;
} }
...@@ -1281,7 +1284,7 @@ esxVI_ManagedObjectReference_Serialize ...@@ -1281,7 +1284,7 @@ esxVI_ManagedObjectReference_Serialize
const char *element, virBufferPtr output) const char *element, virBufferPtr output)
{ {
if (element == NULL || output == NULL) { if (element == NULL || output == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -1311,7 +1314,7 @@ esxVI_ManagedObjectReference_Deserialize ...@@ -1311,7 +1314,7 @@ esxVI_ManagedObjectReference_Deserialize
(xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference) (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference)
{ {
if (managedObjectReference == NULL || *managedObjectReference != NULL) { if (managedObjectReference == NULL || *managedObjectReference != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1; return -1;
} }
...@@ -1323,8 +1326,8 @@ esxVI_ManagedObjectReference_Deserialize ...@@ -1323,8 +1326,8 @@ esxVI_ManagedObjectReference_Deserialize
(char *)xmlGetNoNsProp(node, BAD_CAST "type"); (char *)xmlGetNoNsProp(node, BAD_CAST "type");
if ((*managedObjectReference)->type == NULL) { if ((*managedObjectReference)->type == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
"ManagedObjectReference is missing 'type' property"); _("ManagedObjectReference is missing 'type' property"));
goto failure; goto failure;
} }
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册