Replace use of virSecretReportError with virReportError

Update the secret driver to use virReportError instead of the
virSecretReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-07-18 12:40:16 +01:00
parent d8a1c4c49f
commit 54e520d3aa
2 changed files with 33 additions and 38 deletions

1
cfg.mk
View File

@ -547,7 +547,6 @@ msg_gen_function += virRaiseError
msg_gen_function += virReportError msg_gen_function += virReportError
msg_gen_function += virReportErrorHelper msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError msg_gen_function += virReportSystemError
msg_gen_function += virSecretReportError
msg_gen_function += virSecurityReportError msg_gen_function += virSecurityReportError
msg_gen_function += virXenInotifyError msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError msg_gen_function += virXenStoreError

View File

@ -45,10 +45,6 @@
#define VIR_FROM_THIS VIR_FROM_SECRET #define VIR_FROM_THIS VIR_FROM_SECRET
#define virSecretReportError(code, ...) \
virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
enum { SECRET_MAX_XML_FILE = 10*1024*1024 }; enum { SECRET_MAX_XML_FILE = 10*1024*1024 };
/* Internal driver state */ /* Internal driver state */
@ -354,9 +350,9 @@ secretLoadValidateUUID(virSecretDefPtr def,
virUUIDFormat(def->uuid, uuidstr); virUUIDFormat(def->uuid, uuidstr);
if (!virFileMatchesNameSuffix(xml_basename, uuidstr, ".xml")) { if (!virFileMatchesNameSuffix(xml_basename, uuidstr, ".xml")) {
virSecretReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("<uuid> does not match secret file name '%s'"), _("<uuid> does not match secret file name '%s'"),
xml_basename); xml_basename);
return -1; return -1;
} }
@ -390,8 +386,8 @@ secretLoadValue(virSecretDriverStatePtr driver,
goto cleanup; goto cleanup;
} }
if ((size_t)st.st_size != st.st_size) { if ((size_t)st.st_size != st.st_size) {
virSecretReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("'%s' file does not fit in memory"), filename); _("'%s' file does not fit in memory"), filename);
goto cleanup; goto cleanup;
} }
@ -406,8 +402,8 @@ secretLoadValue(virSecretDriverStatePtr driver,
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
if (!base64_decode_alloc(contents, st.st_size, &value, &value_size)) { if (!base64_decode_alloc(contents, st.st_size, &value, &value_size)) {
virSecretReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid base64 in '%s'"), filename); _("invalid base64 in '%s'"), filename);
goto cleanup; goto cleanup;
} }
if (value == NULL) { if (value == NULL) {
@ -637,8 +633,8 @@ secretLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
if (secret == NULL) { if (secret == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr); _("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
} }
@ -664,8 +660,8 @@ secretLookupByUsage(virConnectPtr conn, int usageType, const char *usageID)
secret = secretFindByUsage(driver, usageType, usageID); secret = secretFindByUsage(driver, usageType, usageID);
if (secret == NULL) { if (secret == NULL) {
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching usage '%s'"), usageID); _("no secret with matching usage '%s'"), usageID);
goto cleanup; goto cleanup;
} }
@ -706,9 +702,9 @@ secretDefineXML(virConnectPtr conn, const char *xml,
if (secret) { if (secret) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(secret->def->uuid, uuidstr); virUUIDFormat(secret->def->uuid, uuidstr);
virSecretReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("a secret with UUID %s already defined for use with %s"), _("a secret with UUID %s already defined for use with %s"),
uuidstr, usageID); uuidstr, usageID);
goto cleanup; goto cleanup;
} }
@ -726,15 +722,15 @@ secretDefineXML(virConnectPtr conn, const char *xml,
if (STRNEQ(oldUsageID, newUsageID)) { if (STRNEQ(oldUsageID, newUsageID)) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(secret->def->uuid, uuidstr); virUUIDFormat(secret->def->uuid, uuidstr);
virSecretReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("a secret with UUID %s is already defined for use with %s"), _("a secret with UUID %s is already defined for use with %s"),
uuidstr, oldUsageID); uuidstr, oldUsageID);
goto cleanup; goto cleanup;
} }
if (secret->def->private && !new_attrs->private) { if (secret->def->private && !new_attrs->private) {
virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot change private flag on existing secret")); _("cannot change private flag on existing secret"));
goto cleanup; goto cleanup;
} }
@ -781,8 +777,8 @@ restore_backup:
} else { } else {
/* "secret" was added to the head of the list above */ /* "secret" was added to the head of the list above */
if (listUnlink(&driverState->secrets) != secret) if (listUnlink(&driverState->secrets) != secret)
virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("list of secrets is inconsistent")); _("list of secrets is inconsistent"));
else else
secretFree(secret); secretFree(secret);
} }
@ -809,8 +805,8 @@ secretGetXMLDesc(virSecretPtr obj, unsigned int flags)
if (secret == NULL) { if (secret == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr); virUUIDFormat(obj->uuid, uuidstr);
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr); _("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
} }
@ -845,8 +841,8 @@ secretSetValue(virSecretPtr obj, const unsigned char *value,
if (secret == NULL) { if (secret == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr); virUUIDFormat(obj->uuid, uuidstr);
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr); _("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
} }
@ -900,23 +896,23 @@ secretGetValue(virSecretPtr obj, size_t *value_size, unsigned int flags,
if (secret == NULL) { if (secret == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr); virUUIDFormat(obj->uuid, uuidstr);
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr); _("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
} }
if (secret->value == NULL) { if (secret->value == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr); virUUIDFormat(obj->uuid, uuidstr);
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("secret '%s' does not have a value"), uuidstr); _("secret '%s' does not have a value"), uuidstr);
goto cleanup; goto cleanup;
} }
if ((internalFlags & VIR_SECRET_GET_VALUE_INTERNAL_CALL) == 0 && if ((internalFlags & VIR_SECRET_GET_VALUE_INTERNAL_CALL) == 0 &&
secret->def->private) { secret->def->private) {
virSecretReportError(VIR_ERR_OPERATION_DENIED, "%s", virReportError(VIR_ERR_OPERATION_DENIED, "%s",
_("secret is private")); _("secret is private"));
goto cleanup; goto cleanup;
} }
@ -946,8 +942,8 @@ secretUndefine(virSecretPtr obj)
if (secret == NULL) { if (secret == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr); virUUIDFormat(obj->uuid, uuidstr);
virSecretReportError(VIR_ERR_NO_SECRET, virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr); _("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
} }