提交 fbae3d6f 编写于 作者: E Eric Blake

xen: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/xen/xen_hypervisor.c (xenHypervisorGetSchedulerParameters):
Allow fewer than max.
* src/xen/xend_internal.c (xenDaemonGetSchedulerParameters):
Likewise.
上级 6d897fc6
......@@ -1274,11 +1274,6 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
TODO
return(-1);
case XEN_SCHEDULER_CREDIT:
if (*nparams < XEN_SCHED_CRED_NPARAM) {
virXenError(VIR_ERR_INVALID_ARG,
"%s", _("Invalid parameter count"));
return -1;
}
memset(&op_dom, 0, sizeof(op_dom));
op_dom.cmd = XEN_V2_OP_SCHEDULER;
op_dom.domain = (domid_t) domain->id;
......@@ -1298,17 +1293,20 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
params[0].type = VIR_TYPED_PARAM_UINT;
params[0].value.ui = op_dom.u.getschedinfo.u.credit.weight;
if (virStrcpyStatic(params[1].field,
VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXenError(VIR_ERR_INTERNAL_ERROR,
"Cap %s too big for destination",
VIR_DOMAIN_SCHEDULER_CAP);
return -1;
if (*nparams > 1) {
if (virStrcpyStatic(params[1].field,
VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXenError(VIR_ERR_INTERNAL_ERROR,
"Cap %s too big for destination",
VIR_DOMAIN_SCHEDULER_CAP);
return -1;
}
params[1].type = VIR_TYPED_PARAM_UINT;
params[1].value.ui = op_dom.u.getschedinfo.u.credit.cap;
}
params[1].type = VIR_TYPED_PARAM_UINT;
params[1].value.ui = op_dom.u.getschedinfo.u.credit.cap;
*nparams = XEN_SCHED_CRED_NPARAM;
if (*nparams > XEN_SCHED_CRED_NPARAM)
*nparams = XEN_SCHED_CRED_NPARAM;
break;
default:
virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
......
......@@ -3614,12 +3614,6 @@ xenDaemonGetSchedulerParameters(virDomainPtr domain,
TODO
goto error;
case XEN_SCHED_CRED_NPARAM:
if (*nparams < XEN_SCHED_CRED_NPARAM) {
virXendError(VIR_ERR_INVALID_ARG,
"%s", _("Invalid parameter count"));
goto error;
}
/* get cpu_weight/cpu_cap from xend/domain */
if (sexpr_node(root, "domain/cpu_weight") == NULL) {
virXendError(VIR_ERR_INTERNAL_ERROR,
......@@ -3642,16 +3636,20 @@ xenDaemonGetSchedulerParameters(virDomainPtr domain,
params[0].type = VIR_TYPED_PARAM_UINT;
params[0].value.ui = sexpr_int(root, "domain/cpu_weight");
if (virStrcpyStatic(params[1].field,
VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXendError(VIR_ERR_INTERNAL_ERROR,
_("Cap %s too big for destination"),
VIR_DOMAIN_SCHEDULER_CAP);
goto error;
if (*nparams > 1) {
if (virStrcpyStatic(params[1].field,
VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXendError(VIR_ERR_INTERNAL_ERROR,
_("Cap %s too big for destination"),
VIR_DOMAIN_SCHEDULER_CAP);
goto error;
}
params[1].type = VIR_TYPED_PARAM_UINT;
params[1].value.ui = sexpr_int(root, "domain/cpu_cap");
}
params[1].type = VIR_TYPED_PARAM_UINT;
params[1].value.ui = sexpr_int(root, "domain/cpu_cap");
*nparams = XEN_SCHED_CRED_NPARAM;
if (*nparams > XEN_SCHED_CRED_NPARAM)
*nparams = XEN_SCHED_CRED_NPARAM;
ret = 0;
break;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册