[libvirt] [PATCHv1 3/3] virsh: Update only changed scheduler tunables

Peter Krempa pkrempa at redhat.com
Wed Sep 5 13:11:45 UTC 2012


When setting the cpu tunables in virsh you are able to update only one
of them. Virsh while doing the update updated all of the tunables with
old values except for the one changed. This is unfortunate as it:
 a) might overwrite some other change by a race condition (unprobable)
 b) fails with range checking as some of the old values saved might be
    out of range

This patch changes the update procedure so that only the changed value
is updated on the host.
---
New in series.
---
 tools/virsh-domain.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index dcf2b8c..2abb457 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3390,7 +3390,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     virTypedParameterPtr params = NULL;
     int nparams = 0;
-    int update = 0;
+    int update = -1;
     int i, ret;
     bool ret_val = false;
     unsigned int flags = 0;
@@ -3450,16 +3450,18 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
                 goto cleanup;

             if (ret == 1)
-                update = 1;
+                update = i;
         }

         /* Update parameters & refresh data */
-        if (update) {
+        if (update >= 0) {
             if (flags || current)
-                ret = virDomainSetSchedulerParametersFlags(dom, params,
-                                                           nparams, flags);
+                ret = virDomainSetSchedulerParametersFlags(dom,
+                                                           &(params[update]),
+                                                           1, flags);
             else
-                ret = virDomainSetSchedulerParameters(dom, params, nparams);
+                ret = virDomainSetSchedulerParameters(dom,
+                                                      &(params[update]), 1);
             if (ret == -1)
                 goto cleanup;

-- 
1.7.12




More information about the libvir-list mailing list