mirror of https://gitee.com/openkylin/libvirt.git
Replace use of virConfError with virReportError
Update the libvirtd config handling code to use virReportError instead of the virConfError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
47ab34e232
commit
edb768c9ce
1
cfg.mk
1
cfg.mk
|
@ -513,7 +513,6 @@ msg_gen_function += regerror
|
|||
msg_gen_function += statsError
|
||||
msg_gen_function += vah_error
|
||||
msg_gen_function += vah_warning
|
||||
msg_gen_function += virConfError
|
||||
msg_gen_function += virGenericReportError
|
||||
msg_gen_function += virLibConnError
|
||||
msg_gen_function += virLibDomainError
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
|
||||
#define VIR_FROM_THIS VIR_FROM_CONF
|
||||
|
||||
#define virConfError(code, ...) \
|
||||
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
/* Allocate an array of malloc'd strings from the config file, filename
|
||||
* (used only in diagnostics), using handle "conf". Upon error, return -1
|
||||
* and free any allocated memory. Otherwise, save the array in *list_arg
|
||||
|
@ -56,17 +52,17 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
|
|||
switch (p->type) {
|
||||
case VIR_CONF_STRING:
|
||||
if (VIR_ALLOC_N(list, 2) < 0) {
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list"),
|
||||
key);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list"),
|
||||
key);
|
||||
return -1;
|
||||
}
|
||||
list[0] = strdup (p->str);
|
||||
list[1] = NULL;
|
||||
if (list[0] == NULL) {
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list value"),
|
||||
key);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list value"),
|
||||
key);
|
||||
VIR_FREE(list);
|
||||
return -1;
|
||||
}
|
||||
|
@ -78,17 +74,17 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
|
|||
for (pp = p->list; pp; pp = pp->next)
|
||||
len++;
|
||||
if (VIR_ALLOC_N(list, 1+len) < 0) {
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list"),
|
||||
key);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list"),
|
||||
key);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0, pp = p->list; pp; ++i, pp = pp->next) {
|
||||
if (pp->type != VIR_CONF_STRING) {
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s:"
|
||||
" must be a string or list of strings"),
|
||||
filename, key);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s:"
|
||||
" must be a string or list of strings"),
|
||||
filename, key);
|
||||
VIR_FREE(list);
|
||||
return -1;
|
||||
}
|
||||
|
@ -98,9 +94,9 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
|
|||
for (j = 0 ; j < i ; j++)
|
||||
VIR_FREE(list[j]);
|
||||
VIR_FREE(list);
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list value"),
|
||||
key);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("failed to allocate memory for %s config list value"),
|
||||
key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -110,10 +106,10 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
|
|||
}
|
||||
|
||||
default:
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s:"
|
||||
" must be a string or list of strings"),
|
||||
filename, key);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s:"
|
||||
" must be a string or list of strings"),
|
||||
filename, key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -127,11 +123,11 @@ checkType (virConfValuePtr p, const char *filename,
|
|||
const char *key, virConfType required_type)
|
||||
{
|
||||
if (p->type != required_type) {
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s: invalid type:"
|
||||
" got %s; expected %s"), filename, key,
|
||||
virConfTypeName (p->type),
|
||||
virConfTypeName (required_type));
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s: invalid type:"
|
||||
" got %s; expected %s"), filename, key,
|
||||
virConfTypeName (p->type),
|
||||
virConfTypeName (required_type));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -189,9 +185,9 @@ static int remoteConfigGetAuth(virConfPtr conf, const char *key, int *auth, cons
|
|||
} else if (STREQ(p->str, "polkit")) {
|
||||
*auth = VIR_NET_SERVER_SERVICE_AUTH_POLKIT;
|
||||
} else {
|
||||
virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s: unsupported auth %s"),
|
||||
filename, key, p->str);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s: unsupported auth %s"),
|
||||
filename, key, p->str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue