From 136795470271bf1c89fe9d4ebd2944501920bb04 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 2 Nov 2011 11:42:38 -0600 Subject: [PATCH] libxl: allow getting < max typed parameters 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 | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 8d3547b92c..928d306b02 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'" @@ -3653,16 +3648,20 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom, goto cleanup; } - params[1].value.ui = sc_info.cap; - params[1].type = VIR_TYPED_PARAM_UINT; - if (virStrcpyStatic(params[1].field, VIR_DOMAIN_SCHEDULER_CAP) == NULL) { - libxlError(VIR_ERR_INTERNAL_ERROR, - _("Field name '%s' too long"), - VIR_DOMAIN_SCHEDULER_CAP); - goto cleanup; + if (*nparams > 1) { + params[1].value.ui = sc_info.cap; + params[1].type = VIR_TYPED_PARAM_UINT; + if (virStrcpyStatic(params[1].field, + VIR_DOMAIN_SCHEDULER_CAP) == NULL) { + libxlError(VIR_ERR_INTERNAL_ERROR, + _("Field name '%s' too long"), + VIR_DOMAIN_SCHEDULER_CAP); + goto cleanup; + } } - *nparams = XEN_SCHED_CREDIT_NPARAM; + if (*nparams > XEN_SCHED_CREDIT_NPARAM) + *nparams = XEN_SCHED_CREDIT_NPARAM; ret = 0; cleanup: