Re: [PATCH 2/5] libxl: allow getting < max typed parameters

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

 



On 11/02/2011 02:00 PM, Eric Blake wrote:
Allow the user to call with nparams too small, per API documentation.

* src/libxl/libxl_driver.c
(libxlDomainGetSchedulerParametersFlags): Allow fewer than max.
---
  src/libxl/libxl_driver.c |   22 ++++++++++------------
  1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d324632..06dfe0a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3631,11 +3631,6 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
          goto cleanup;
      }

-    if (*nparams<  XEN_SCHED_CREDIT_NPARAM) {
-        libxlError(VIR_ERR_INVALID_ARG, "%s", _("Invalid parameter count"));
-        goto cleanup;
-    }
-
      if (libxl_sched_credit_domain_get(&priv->ctx, dom->id,&sc_info) != 0) {
          libxlError(VIR_ERR_INTERNAL_ERROR,
                     _("Failed to get scheduler parameters for domain '%d'"
@@ -3651,15 +3646,18 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
          goto cleanup;
      }

-    params[1].value.ui = sc_info.cap;
-    params[1].type = VIR_TYPED_PARAM_UINT;
-    if (virStrcpyStatic(params[1].field, "cap") == NULL) {
-        libxlError(VIR_ERR_INTERNAL_ERROR,
-                   "%s", _("Field cap too long for destination"));
-        goto cleanup;
+    if (*nparams>  1) {
+        params[1].value.ui = sc_info.cap;
+        params[1].type = VIR_TYPED_PARAM_UINT;
+        if (virStrcpyStatic(params[1].field, "cap") == NULL) {
I remember this one here:

VIR_DOMAIN_SCHEDULER_CAP

Is this the same one ? If so, maybe you want to replace it.


+            libxlError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("Field cap too long for destination"));
Also, would it be worth doing the same here as you did in the other patches using "%s" in place of 'cap'?
+            goto cleanup;
+        }
      }

-    *nparams = XEN_SCHED_CREDIT_NPARAM;
+    if (*nparams>  XEN_SCHED_CREDIT_NPARAM)
+        *nparams = XEN_SCHED_CREDIT_NPARAM;
      ret = 0;

  cleanup:

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