A lot of virReportError() calls use VIR_ERR_INTERNAL_ERROR to represent
the number of the error, even in cases where there is one fitting more.
Hence, replace some of them with better virErrorNumber values.
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
src/esx/esx_network_driver.c | 4 ++--
src/esx/esx_storage_backend_iscsi.c | 4 ++--
src/esx/esx_storage_backend_vmfs.c | 12 +++++-----
src/esx/esx_util.c | 4 ++--
src/esx/esx_vi.c | 36 ++++++++++++++---------------
5 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index f14d309293..2a76831606 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -355,7 +355,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
for (hostPortGroup = hostPortGroupList; hostPortGroup;
hostPortGroup = hostPortGroup->_next) {
if (STREQ(def->portGroups[i].name, hostPortGroup->spec->name))
{
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NETWORK_EXIST,
_("HostPortGroup with name '%s' exists
already"),
def->portGroups[i].name);
goto cleanup;
@@ -388,7 +388,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
if (def->forward.ifs[i].type !=
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("unsupported device type in network %s "
"interface pool"),
def->name);
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index cd83a0fbfd..1e54cef948 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -321,7 +321,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
if (!target) {
/* pool not found */
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_STORAGE_POOL,
_("Could not find storage pool with name
'%s'"),
pool->name);
goto cleanup;
@@ -701,7 +701,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
}
if (!scsiLun) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_STORAGE_VOL,
_("Could find volume with name: %s"), volume->name);
goto cleanup;
}
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 70005717cb..d4b23c6d51 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -906,7 +906,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
if (def->type != VIR_STORAGE_VOL_FILE) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
@@ -922,7 +922,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
if (!virStringHasCaseSuffix(def->name, ".vmdk")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Volume name '%s' has unsupported suffix, "
"expecting '.vmdk'"), def->name);
goto cleanup;
@@ -1041,7 +1041,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
key = g_strdup(datastorePath);
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
@@ -1120,7 +1120,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
if (def->type != VIR_STORAGE_VOL_FILE) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
@@ -1136,7 +1136,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if (!virStringHasCaseSuffix(def->name, ".vmdk")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Volume name '%s' has unsupported suffix, "
"expecting '.vmdk'"), def->name);
goto cleanup;
@@ -1221,7 +1221,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
key = g_strdup(datastorePath);
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index c265528056..dc0983a47d 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -218,7 +218,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char
**datastoreName,
if ((datastoreName && *datastoreName) ||
(directoryName && *directoryName) ||
(directoryAndFileName && *directoryAndFileName)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
@@ -227,7 +227,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char
**datastoreName,
/* Expected format: '[<datastore>] <path>' where <path> is
optional */
if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' ||
!(preliminaryDatastoreName = strtok_r(tmp, "]", &saveptr))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INVALID_ARG,
_("Datastore path '%s' doesn't have expected
format "
"'[<datastore>] <path>'"),
datastorePath);
goto cleanup;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 4e67d76bfe..3c5a994848 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -435,7 +435,7 @@ esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char
*content)
int responseCode = 0;
if (!content) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
@@ -552,13 +552,13 @@ esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_CURL *curl)
size_t i;
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot share uninitialized CURL handle"));
return -1;
}
if (curl->shared) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot share CURL handle that is already shared"));
return -1;
}
@@ -607,19 +607,19 @@ int
esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl)
{
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot unshare uninitialized CURL handle"));
return -1;
}
if (!curl->shared) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot unshare CURL handle that is not shared"));
return -1;
}
if (curl->shared != shared) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (share)
mismatch"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (share)
mismatch"));
return -1;
}
@@ -727,13 +727,13 @@ int
esxVI_MultiCURL_Add(esxVI_MultiCURL *multi, esxVI_CURL *curl)
{
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot add uninitialized CURL handle to a multi
handle"));
return -1;
}
if (curl->multi) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot add CURL handle to a multi handle twice"));
return -1;
}
@@ -773,21 +773,21 @@ int
esxVI_MultiCURL_Remove(esxVI_MultiCURL *multi, esxVI_CURL *curl)
{
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot remove uninitialized CURL handle from a "
"multi handle"));
return -1;
}
if (!curl->multi) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot remove CURL handle from a multi handle when it
"
"wasn't added before"));
return -1;
}
if (curl->multi != multi) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (multi)
mismatch"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (multi)
mismatch"));
return -1;
}
@@ -994,7 +994,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
if (!ctx || !url || !ipAddress || !username ||
!password || ctx->url || ctx->service || ctx->curl) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
@@ -1405,7 +1405,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
xmlNodePtr responseNode = NULL;
if (!request || !response || *response) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
@@ -1548,7 +1548,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
}
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_HTTP_ERROR,
_("HTTP response code %d for call to '%s'"),
(*response)->responseCode, methodName);
goto cleanup;
@@ -1599,14 +1599,14 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration
*enumeration,
size_t i;
if (!anyType || !value) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
*value = 0; /* undefined */
if (anyType->type != enumeration->type) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INVALID_ARG,
_("Expecting type '%s' but found
'%s'"),
esxVI_Type_ToString(enumeration->type),
esxVI_AnyType_TypeToString(anyType));
@@ -1635,7 +1635,7 @@ esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
const char *name = NULL;
if (!element || !output) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
@@ -1674,7 +1674,7 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
char *name = NULL;
if (!value) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
return -1;
}
--
2.24.1