提交 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,6 +1293,7 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
params[0].type = VIR_TYPED_PARAM_UINT;
params[0].value.ui = op_dom.u.getschedinfo.u.credit.weight;
if (*nparams > 1) {
if (virStrcpyStatic(params[1].field,
VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXenError(VIR_ERR_INTERNAL_ERROR,
......@@ -1307,7 +1303,9 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
}
params[1].type = VIR_TYPED_PARAM_UINT;
params[1].value.ui = op_dom.u.getschedinfo.u.credit.cap;
}
if (*nparams > XEN_SCHED_CRED_NPARAM)
*nparams = XEN_SCHED_CRED_NPARAM;
break;
default:
......
......@@ -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,6 +3636,7 @@ xenDaemonGetSchedulerParameters(virDomainPtr domain,
params[0].type = VIR_TYPED_PARAM_UINT;
params[0].value.ui = sexpr_int(root, "domain/cpu_weight");
if (*nparams > 1) {
if (virStrcpyStatic(params[1].field,
VIR_DOMAIN_SCHEDULER_CAP) == NULL) {
virXendError(VIR_ERR_INTERNAL_ERROR,
......@@ -3651,6 +3646,9 @@ xenDaemonGetSchedulerParameters(virDomainPtr domain,
}
params[1].type = VIR_TYPED_PARAM_UINT;
params[1].value.ui = sexpr_int(root, "domain/cpu_cap");
}
if (*nparams > XEN_SCHED_CRED_NPARAM)
*nparams = XEN_SCHED_CRED_NPARAM;
ret = 0;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册