[PATCH 05/12] virsh: Use virTypedParams* APIs in schedinfo

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

 



---
 tools/virsh-domain.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 10b0a11..20a7a17 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3386,11 +3386,10 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
     const char *set_arg;
     char *set_field = NULL;
     char *set_val = NULL;
-
     virTypedParameterPtr param;
     virTypedParameterPtr params = NULL;
     int nparams = 0;
-    size_t params_size = 0;
+    int maxparams = 0;
     int ret = -1;
     int rv;
     int val;
@@ -3409,10 +3408,6 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
 
     for (i = 0; i < nsrc_params; i++) {
         param = &(src_params[i]);
-        if (VIR_RESIZE_N(params, params_size, nparams, 1) < 0) {
-            virReportOOMError();
-            goto cleanup;
-        }
 
         /* Legacy 'weight' and 'cap'  parameter */
         if (param->type == VIR_TYPED_PARAM_UINT &&
@@ -3423,10 +3418,8 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
                 goto cleanup;
             }
 
-            if (virTypedParameterAssign(&(params[nparams++]),
-                                        param->field,
-                                        param->type,
-                                        val) < 0) {
+            if (virTypedParamsAddUInt(&params, &nparams, &maxparams,
+                                      param->field, val) < 0) {
                 vshSaveLibvirtError();
                 goto cleanup;
             }
@@ -3434,12 +3427,10 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
             continue;
         }
 
-
         if (set_field && STREQ(set_field, param->field)) {
-            if (virTypedParameterAssignFromStr(&(params[nparams++]),
-                                               param->field,
-                                               param->type,
-                                               set_val) < 0) {
+            if (virTypedParamsAddFromString(&params, &nparams, &maxparams,
+                                            set_field, param->type,
+                                            set_val) < 0) {
                 vshSaveLibvirtError();
                 goto cleanup;
             }
@@ -3454,8 +3445,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
 
 cleanup:
     VIR_FREE(set_field);
-    virTypedParameterArrayClear(params, nparams);
-    VIR_FREE(params);
+    virTypedParamsFree(params, nparams);
     return ret;
 }
 
@@ -3571,10 +3561,8 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     }
 
  cleanup:
-    virTypedParameterArrayClear(params, nparams);
-    virTypedParameterArrayClear(updates, nupdates);
-    VIR_FREE(params);
-    VIR_FREE(updates);
+    virTypedParamsFree(params, nparams);
+    virTypedParamsFree(updates, nupdates);
     virDomainFree(dom);
     return ret_val;
 }
-- 
1.8.1.1

--
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]