[PATCH] Use VIR_ERR_OPERATION_INVALID when appropriated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



VIR_ERR_OPERATION_INVALID means that the operation is not valid
for the current state of the involved object.
---
 src/esx/esx_driver.c        |    1 -
 src/lxc/lxc_driver.c        |    2 +-
 src/network/bridge_driver.c |    2 +-
 src/opennebula/one_driver.c |    2 +-
 src/openvz/openvz_driver.c  |    2 +-
 src/qemu/qemu_driver.c      |    4 ++--
 src/test/test_driver.c      |   34 +++++++++++++++++-----------------
 src/uml/uml_driver.c        |   10 +++++-----
 src/vmware/vmware_driver.c  |    2 +-
 9 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index de3e49f..26f029c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1660,7 +1660,6 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
         goto cleanup;
     }
 
-
     if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, uuid) < 0 ||
         esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
         goto cleanup;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c4fe936..df693ec 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2491,7 +2491,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
     }
 
     if (!vm->persistent) {
-        lxcError(VIR_ERR_INTERNAL_ERROR,
+        lxcError(VIR_ERR_OPERATION_INVALID,
                  "%s", _("Cannot set autostart for transient domain"));
         goto cleanup;
     }
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3f63afd..c098ab5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1537,7 +1537,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
     virNetworkIpDefPtr ipdef;
 
     if (virNetworkObjIsActive(network)) {
-        networkReportError(VIR_ERR_INTERNAL_ERROR,
+        networkReportError(VIR_ERR_OPERATION_INVALID,
                            "%s", _("network is already active"));
         return -1;
     }
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index b88f44f..4febb46 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -291,7 +291,7 @@ static int oneDomainUndefine(virDomainPtr dom)
     }
 
     if (!vm->persistent) {
-        oneError(VIR_ERR_INTERNAL_ERROR, "%s",
+        oneError(VIR_ERR_OPERATION_INVALID, "%s",
                  _("cannot undefine transient domain"));
         goto return_point;
     }
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 7728981..fc6ae29 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1079,7 +1079,7 @@ openvzDomainUndefine(virDomainPtr dom)
     }
 
     if (virDomainObjIsActive(vm)) {
-        openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
+        openvzError(VIR_ERR_OPERATION_INVALID, "%s",
                     _("cannot delete active domain"));
         goto cleanup;
     }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index be0c231..b2c99a1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6402,7 +6402,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
     }
 
     if (!vm->persistent) {
-        qemuReportError(VIR_ERR_INTERNAL_ERROR,
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
                         "%s", _("cannot undefine transient domain"));
         goto cleanup;
     }
@@ -6849,7 +6849,7 @@ static int qemudDomainSetAutostart(virDomainPtr dom,
     }
 
     if (!vm->persistent) {
-        qemuReportError(VIR_ERR_INTERNAL_ERROR,
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
                         "%s", _("cannot set autostart for transient domain"));
         goto cleanup;
     }
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 601ecf8..7b07780 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3061,7 +3061,7 @@ static int testNetworkUndefine(virNetworkPtr network) {
     }
 
     if (virNetworkObjIsActive(privnet)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("Network '%s' is still running"), network->name);
         goto cleanup;
     }
@@ -3094,7 +3094,7 @@ static int testNetworkStart(virNetworkPtr network) {
     }
 
     if (virNetworkObjIsActive(privnet)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("Network '%s' is already running"), network->name);
         goto cleanup;
     }
@@ -3817,7 +3817,7 @@ testStoragePoolStart(virStoragePoolPtr pool,
     }
 
     if (virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
     }
@@ -3982,7 +3982,7 @@ testStoragePoolUndefine(virStoragePoolPtr pool) {
     }
 
     if (virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
     }
@@ -4015,7 +4015,7 @@ testStoragePoolBuild(virStoragePoolPtr pool,
     }
 
     if (virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
     }
@@ -4044,7 +4044,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool) {
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4083,7 +4083,7 @@ testStoragePoolDelete(virStoragePoolPtr pool,
     }
 
     if (virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
     }
@@ -4115,7 +4115,7 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4267,7 +4267,7 @@ testStoragePoolNumVolumes(virStoragePoolPtr pool) {
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4302,7 +4302,7 @@ testStoragePoolListVolumes(virStoragePoolPtr pool,
 
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4348,7 +4348,7 @@ testStorageVolumeLookupByName(virStoragePoolPtr pool,
 
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4459,7 +4459,7 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool,
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4540,7 +4540,7 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
@@ -4640,7 +4640,7 @@ testStorageVolumeDelete(virStorageVolPtr vol,
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), vol->pool);
         goto cleanup;
     }
@@ -4718,7 +4718,7 @@ testStorageVolumeGetInfo(virStorageVolPtr vol,
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), vol->pool);
         goto cleanup;
     }
@@ -4763,7 +4763,7 @@ testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), vol->pool);
         goto cleanup;
     }
@@ -4803,7 +4803,7 @@ testStorageVolumeGetPath(virStorageVolPtr vol) {
     }
 
     if (!virStoragePoolObjIsActive(privpool)) {
-        testError(VIR_ERR_INTERNAL_ERROR,
+        testError(VIR_ERR_OPERATION_INVALID,
                   _("storage pool '%s' is not active"), vol->pool);
         goto cleanup;
     }
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c6df0a1..57f50f6 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -819,7 +819,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
     virCommandPtr cmd = NULL;
 
     if (virDomainObjIsActive(vm)) {
-        umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("VM is already active"));
         return -1;
     }
@@ -1462,7 +1462,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
     }
 
     if (virDomainObjIsActive(vm)) {
-        umlReportError(VIR_ERR_NO_SUPPORT, "%s",
+        umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("cannot set memory of an active domain"));
         goto cleanup;
     }
@@ -1656,13 +1656,13 @@ static int umlDomainUndefine(virDomainPtr dom) {
     }
 
     if (virDomainObjIsActive(vm)) {
-        umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("cannot delete active domain"));
         goto cleanup;
     }
 
     if (!vm->persistent) {
-        umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("cannot undefine transient domain"));
         goto cleanup;
     }
@@ -1954,7 +1954,7 @@ static int umlDomainSetAutostart(virDomainPtr dom,
     }
 
     if (!vm->persistent) {
-        umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("cannot set autostart for transient domain"));
         goto cleanup;
     }
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 47314f8..f176c2f 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -622,7 +622,7 @@ vmwareDomainUndefine(virDomainPtr dom)
     }
 
     if (!vm->persistent) {
-        vmwareError(VIR_ERR_INTERNAL_ERROR,
+        vmwareError(VIR_ERR_OPERATION_INVALID,
                     "%s", _("cannot undefine transient domain"));
         goto cleanup;
     }
-- 
1.7.0.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]