]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxcSetSchedulerParameters: reverse order of tests; diagnose a failure
authorJim Meyering <jim@meyering.net>
Tue, 11 May 2010 13:51:46 +0000 (15:51 +0200)
committerEric Blake <eblake@redhat.com>
Mon, 24 May 2010 21:55:04 +0000 (15:55 -0600)
* src/lxc/lxc_driver.c (lxcSetSchedulerParameters): Ensure that
"->field" is "cpu_shares" before possibly giving a diagnostic about
a type for a "cpu_shares" value.
Also, virCgroupSetCpuShares could fail without evoking a diagnostic.
Add one.

src/lxc/lxc_driver.c

index 8c3bbd312ee6dce3b7e07e60ce160f01d3271307..14a8b2abaa331c7de76315a269c52e7f832995a9 100644 (file)
@@ -2054,18 +2054,23 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
 
     for (i = 0; i < nparams; i++) {
         virSchedParameterPtr param = &params[i];
+
+        if (STRNEQ(param->field, "cpu_shares")) {
+            lxcError(VIR_ERR_INVALID_ARG,
+                     _("Invalid parameter `%s'"), param->field);
+            goto cleanup;
+        }
+
         if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) {
             lxcError(VIR_ERR_INVALID_ARG, "%s",
-                     _("Invalid type for cpu_shares tunable, expected a 'ullong'"));
+                 _("Invalid type for cpu_shares tunable, expected a 'ullong'"));
             goto cleanup;
         }
 
-        if (STREQ(param->field, "cpu_shares")) {
-            if (virCgroupSetCpuShares(group, params[i].value.ul) != 0)
-                goto cleanup;
-        } else {
-            lxcError(VIR_ERR_INVALID_ARG,
-                     _("Invalid parameter `%s'"), param->field);
+        int rc = virCgroupSetCpuShares(group, params[i].value.ul);
+        if (rc != 0) {
+            virReportSystemError(-rc, _("failed to set cpu_shares=%llu"),
+                                 params[i].value.ul);
             goto cleanup;
         }
     }