]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix misuse of VIR_ERR_INVALID_* error code
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 15 Jan 2011 15:31:29 +0000 (16:31 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 18 Jan 2011 22:14:37 +0000 (23:14 +0100)
VIR_ERR_INVALID_* is meant for invalid pointers only.

src/conf/nwfilter_conf.c
src/conf/storage_conf.c
src/network/bridge_driver.c
src/nwfilter/nwfilter_driver.c
src/nwfilter/nwfilter_ebiptables_driver.c
src/qemu/qemu_driver.c
src/storage/storage_backend.c
src/test/test_driver.c

index 03464716a59b44408e156d46df957b0e198bc07b..dbb72b20ed853644a2f0e275151a7271932f1630 100644 (file)
@@ -2366,7 +2366,7 @@ virNWFilterObjAssignDef(virConnectPtr conn,
 
     if (nwfilter) {
         if (!STREQ(def->name, nwfilter->def->name)) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+            virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
                                    _("filter with same UUID but different name "
                                      "('%s') already exists"),
                                    nwfilter->def->name);
@@ -2377,7 +2377,7 @@ virNWFilterObjAssignDef(virConnectPtr conn,
     }
 
     if (virNWFilterDefLoopDetect(conn, nwfilters, def)) {
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
                               "%s", _("filter would introduce a loop"));
         return NULL;
     }
@@ -2442,7 +2442,7 @@ virNWFilterObjLoad(virConnectPtr conn,
     }
 
     if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_XML_ERROR,
             _("network filter config filename '%s' does not match name '%s'"),
             path, def->name);
         virNWFilterDefFree(def);
index f7f471e630874b0bbdf234541d6ebe1f0064af3f..0c37dc607c2063bff63ae34707ac9e56811dcd90 100644 (file)
@@ -1423,7 +1423,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
     }
 
     if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
-        virStorageReportError(VIR_ERR_INVALID_STORAGE_POOL,
+        virStorageReportError(VIR_ERR_XML_ERROR,
                               _("Storage pool config filename '%s' does not match pool name '%s'"),
                               path, def->name);
         virStoragePoolDefFree(def);
index 4c64a7464377b0223988e8a794b04d05cc28f1b9..3f63afd9f18ce427e30b037084d5fe092510093f 100644 (file)
@@ -2059,13 +2059,13 @@ static int networkUndefine(virNetworkPtr net) {
 
     network = virNetworkFindByUUID(&driver->networks, net->uuid);
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching uuid"));
         goto cleanup;
     }
 
     if (virNetworkObjIsActive(network)) {
-        networkReportError(VIR_ERR_INTERNAL_ERROR,
+        networkReportError(VIR_ERR_OPERATION_INVALID,
                            "%s", _("network is still active"));
         goto cleanup;
     }
@@ -2138,7 +2138,7 @@ static int networkStart(virNetworkPtr net) {
     network = virNetworkFindByUUID(&driver->networks, net->uuid);
 
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching uuid"));
         goto cleanup;
     }
@@ -2161,13 +2161,13 @@ static int networkDestroy(virNetworkPtr net) {
     network = virNetworkFindByUUID(&driver->networks, net->uuid);
 
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching uuid"));
         goto cleanup;
     }
 
     if (!virNetworkObjIsActive(network)) {
-        networkReportError(VIR_ERR_INTERNAL_ERROR,
+        networkReportError(VIR_ERR_OPERATION_INVALID,
                            "%s", _("network is not active"));
         goto cleanup;
     }
@@ -2196,7 +2196,7 @@ static char *networkDumpXML(virNetworkPtr net, int flags ATTRIBUTE_UNUSED) {
     networkDriverUnlock(driver);
 
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching uuid"));
         goto cleanup;
     }
@@ -2219,7 +2219,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
     networkDriverUnlock(driver);
 
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching id"));
         goto cleanup;
     }
@@ -2251,7 +2251,7 @@ static int networkGetAutostart(virNetworkPtr net,
     network = virNetworkFindByUUID(&driver->networks, net->uuid);
     networkDriverUnlock(driver);
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching uuid"));
         goto cleanup;
     }
@@ -2276,13 +2276,13 @@ static int networkSetAutostart(virNetworkPtr net,
     network = virNetworkFindByUUID(&driver->networks, net->uuid);
 
     if (!network) {
-        networkReportError(VIR_ERR_INVALID_NETWORK,
+        networkReportError(VIR_ERR_NO_NETWORK,
                            "%s", _("no network with matching uuid"));
         goto cleanup;
     }
 
     if (!network->persistent) {
-        networkReportError(VIR_ERR_INTERNAL_ERROR,
+        networkReportError(VIR_ERR_OPERATION_INVALID,
                            "%s", _("cannot set autostart for transient network"));
         goto cleanup;
     }
index fa72a5f7c939b711569bb631b7c9779b369ecd64..f9033117e8bd79ec41bed112a66547d131432543 100644 (file)
@@ -372,13 +372,13 @@ nwfilterUndefine(virNWFilterPtr obj) {
 
     nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
     if (!nwfilter) {
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_NO_NWFILTER,
                                "%s", _("no nwfilter with matching uuid"));
         goto cleanup;
     }
 
     if (virNWFilterTestUnassignDef(obj->conn, nwfilter)) {
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_OPERATION_INVALID,
                                "%s",
                                _("nwfilter is in use"));
         goto cleanup;
@@ -417,7 +417,7 @@ nwfilterDumpXML(virNWFilterPtr obj,
     nwfilterDriverUnlock(driver);
 
     if (!nwfilter) {
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_NO_NWFILTER,
                                "%s", _("no nwfilter with matching uuid"));
         goto cleanup;
     }
index 9b7a7c8b07f65076a1ee6708432302a8cddb89f6..91a91590a66a90963cf55b3aeb79b3092a8120bb 100644 (file)
@@ -157,14 +157,14 @@ printVar(virNWFilterHashTablePtr vars,
     if ((item->flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
         char *val = (char *)virHashLookup(vars->hashTable, item->var);
         if (!val) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot find value for '%s'"),
                                    item->var);
             return 1;
         }
 
         if (!virStrcpy(buf, val, bufsize)) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("Buffer to small to print MAC address "
                                    "'%s' into"),
                                    item->var);
@@ -223,7 +223,7 @@ _printDataType(virNWFilterHashTablePtr vars,
     case DATATYPE_MACADDR:
     case DATATYPE_MACMASK:
         if (bufsize < VIR_MAC_STRING_BUFLEN) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                    _("Buffer too small for MAC address"));
             return 1;
         }
@@ -235,7 +235,7 @@ _printDataType(virNWFilterHashTablePtr vars,
     case DATATYPE_IPMASK:
         if (snprintf(buf, bufsize, "%d",
                      item->u.u8) >= bufsize) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                    _("Buffer too small for uint8 type"));
             return 1;
         }
@@ -245,7 +245,7 @@ _printDataType(virNWFilterHashTablePtr vars,
     case DATATYPE_UINT16_HEX:
         if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
                      item->u.u16) >= bufsize) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                    _("Buffer too small for uint16 type"));
             return 1;
         }
@@ -255,14 +255,14 @@ _printDataType(virNWFilterHashTablePtr vars,
     case DATATYPE_UINT8_HEX:
         if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
                      item->u.u8) >= bufsize) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                    _("Buffer too small for uint8 type"));
             return 1;
         }
     break;
 
     default:
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Unhandled datatype %x"), item->datatype);
         return 1;
     break;
@@ -2356,7 +2356,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
     case VIR_NWFILTER_RULE_PROTOCOL_IGMP:
     case VIR_NWFILTER_RULE_PROTOCOL_ALL:
         if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+            virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
                           _("'%s' protocol not support for net type '%s'"),
                           virNWFilterRuleProtocolTypeToString(rule->prtclType),
                           virDomainNetTypeToString(nettype));
@@ -2380,7 +2380,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
     case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6:
     case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6:
         if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
-            virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+            virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
                           _("'%s' protocol not support for net type '%s'"),
                           virNWFilterRuleProtocolTypeToString(rule->prtclType),
                           virDomainNetTypeToString(nettype));
@@ -2396,7 +2396,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
     break;
 
     case VIR_NWFILTER_RULE_PROTOCOL_LAST:
-        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+        virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
                                "%s", _("illegal protocol type"));
         rc = 1;
     break;
index fb821a59377bf2fbb805e5616056ba6d101c10a5..824e77602ea51f650d965b907344f4efcac2493f 100644 (file)
@@ -467,7 +467,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
         enc->nsecrets != 1 ||
         enc->secrets[0]->type !=
         VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE) {
-        qemuReportError(VIR_ERR_INVALID_DOMAIN,
+        qemuReportError(VIR_ERR_XML_ERROR,
                         _("invalid <encryption> for volume %s"), disk->src);
         goto cleanup;
     }
@@ -485,7 +485,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
     if (memchr(data, '\0', size) != NULL) {
         memset(data, 0, size);
         VIR_FREE(data);
-        qemuReportError(VIR_ERR_INVALID_SECRET,
+        qemuReportError(VIR_ERR_XML_ERROR,
                         _("format='qcow' passphrase for %s must not contain a "
                           "'\\0'"), disk->src);
         goto cleanup;
index ee08a4a1a0b20f631badbec6eb6e86b1edc5d6c5..bfe1172c0087ba64c90f18e699bb3360f4ebd27d 100644 (file)
@@ -713,7 +713,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
             return -1;
         }
         if (enc->nsecrets > 1) {
-            virStorageReportError(VIR_ERR_INVALID_STORAGE_VOL, "%s",
+            virStorageReportError(VIR_ERR_XML_ERROR, "%s",
                                   _("too many secrets for qcow encryption"));
             return -1;
         }
index ddff160e2e54e4191a7fcd8b0c55ae45d7cc033a..601ecf84b4719f86720f6b56fdfbb93d3b3149ce 100644 (file)
@@ -4356,7 +4356,7 @@ testStorageVolumeLookupByName(virStoragePoolPtr pool,
     privvol = virStorageVolDefFindByName(privpool, name);
 
     if (!privvol) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching name '%s'"), name);
         goto cleanup;
     }
@@ -4399,7 +4399,7 @@ testStorageVolumeLookupByKey(virConnectPtr conn,
     testDriverUnlock(privconn);
 
     if (!ret)
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching key '%s'"), key);
 
     return ret;
@@ -4433,7 +4433,7 @@ testStorageVolumeLookupByPath(virConnectPtr conn,
     testDriverUnlock(privconn);
 
     if (!ret)
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching path '%s'"), path);
 
     return ret;
@@ -4469,7 +4469,7 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool,
         goto cleanup;
 
     if (virStorageVolDefFindByName(privpool, privvol->name)) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_OPERATION_FAILED,
                   "%s", _("storage vol already exists"));
         goto cleanup;
     }
@@ -4550,14 +4550,14 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
         goto cleanup;
 
     if (virStorageVolDefFindByName(privpool, privvol->name)) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_OPERATION_FAILED,
                   "%s", _("storage vol already exists"));
         goto cleanup;
     }
 
     origvol = virStorageVolDefFindByName(privpool, clonevol->name);
     if (!origvol) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching name '%s'"),
                   clonevol->name);
         goto cleanup;
@@ -4633,7 +4633,7 @@ testStorageVolumeDelete(virStorageVolPtr vol,
     privvol = virStorageVolDefFindByName(privpool, vol->name);
 
     if (privvol == NULL) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching name '%s'"),
                   vol->name);
         goto cleanup;
@@ -4711,7 +4711,7 @@ testStorageVolumeGetInfo(virStorageVolPtr vol,
     privvol = virStorageVolDefFindByName(privpool, vol->name);
 
     if (privvol == NULL) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching name '%s'"),
                   vol->name);
         goto cleanup;
@@ -4756,7 +4756,7 @@ testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
     privvol = virStorageVolDefFindByName(privpool, vol->name);
 
     if (privvol == NULL) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching name '%s'"),
                   vol->name);
         goto cleanup;
@@ -4796,7 +4796,7 @@ testStorageVolumeGetPath(virStorageVolPtr vol) {
     privvol = virStorageVolDefFindByName(privpool, vol->name);
 
     if (privvol == NULL) {
-        testError(VIR_ERR_INVALID_STORAGE_VOL,
+        testError(VIR_ERR_NO_STORAGE_VOL,
                   _("no storage vol with matching name '%s'"),
                   vol->name);
         goto cleanup;