]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: improve some of the virErrorNumber used
authorPino Toscano <ptoscano@redhat.com>
Thu, 10 Sep 2020 13:24:02 +0000 (15:24 +0200)
committerPino Toscano <ptoscano@redhat.com>
Mon, 14 Sep 2020 08:22:00 +0000 (10:22 +0200)
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@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/esx/esx_network_driver.c
src/esx/esx_storage_backend_iscsi.c
src/esx/esx_storage_backend_vmfs.c
src/esx/esx_util.c
src/esx/esx_vi.c

index d46fc9253d8de86d33889f687210719444a044fe..88843aae2f9e75a52b6018c54b6d9ed85f20599d 100644 (file)
@@ -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);
index 395a347cf3887393ab7a344e0ef2a73ad6760c7b..017b800f066f5714a1ef0146c838c49374be06bb 100644 (file)
@@ -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;
@@ -699,7 +699,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;
     }
index 4f613bf93b5956aafb3a735e1e3fa4b1ae0c505e..a98001d6b2c3279ce84b75aac1cc42f9098c554e 100644 (file)
@@ -897,7 +897,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;
     }
@@ -913,7 +913,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;
@@ -1032,7 +1032,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;
@@ -1111,7 +1111,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;
     }
@@ -1127,7 +1127,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;
@@ -1212,7 +1212,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;
index 11f43acc19edcbfd2cab1e1783c5b2d953c8fbf7..cd3d8925b94ac95a948bb709fbc52b7f0056a2be 100644 (file)
@@ -226,7 +226,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;
index a4f3be02a4685f5758cffef55a1bc860afca23de..f099716d3e68549c63c761fcfb78895dac660646 100644 (file)
@@ -1390,7 +1390,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;