]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Exit on first error in qemuDomainGetMemoryParameters
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 20 Oct 2010 12:28:45 +0000 (14:28 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 20 Oct 2010 17:33:11 +0000 (19:33 +0200)
There is no point in trying to fill params beyond the first error,
because when qemuDomainGetMemoryParameters returns -1 then the caller
cannot detect which values in params are valid.

src/qemu/qemu_driver.c

index 6395c93871141fbb97f80fe1bb3f2e01deecb94b..ae1d833d3aac5875a852b93cb0727a9883fa6c03 100644 (file)
@@ -9676,7 +9676,6 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
         goto cleanup;
     }
 
-    ret = 0;
     for (i = 0; i < *nparams; i++) {
         virMemoryParameterPtr param = &params[i];
         val = 0;
@@ -9689,14 +9688,12 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
             if (rc != 0) {
                 virReportSystemError(-rc, "%s",
                                      _("unable to get memory hard limit"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) {
                 qemuReportError(VIR_ERR_INTERNAL_ERROR,
                                 "%s", _("Field memory hard limit too long for destination"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             param->value.ul = val;
             break;
@@ -9706,14 +9703,12 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
             if (rc != 0) {
                 virReportSystemError(-rc, "%s",
                                      _("unable to get memory soft limit"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) {
                 qemuReportError(VIR_ERR_INTERNAL_ERROR,
                                 "%s", _("Field memory soft limit too long for destination"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             param->value.ul = val;
             break;
@@ -9723,14 +9718,12 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
             if (rc != 0) {
                 virReportSystemError(-rc, "%s",
                                      _("unable to get swap hard limit"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT) == NULL) {
                 qemuReportError(VIR_ERR_INTERNAL_ERROR,
                                 "%s", _("Field swap hard limit too long for destination"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             param->value.ul = val;
             break;
@@ -9741,6 +9734,8 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
         }
     }
 
+    ret = 0;
+
 cleanup:
     if (group)
         virCgroupFree(&group);