mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Clarify semantic of nparams argument of virDomainGetSchedulerType
Some drivers assumed it can be NULL (e.g. qemu and lxc) and check it before assigning to it, other drivers assumed it must be non-NULL (e.g. test and esx) and just assigned to it. Unify this to nparams being optional and document it.
This commit is contained in:
parent
ed97be6176
commit
7b2f20b10b
@ -3513,7 +3513,9 @@ esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*nparams = 3; /* reservation, limit, shares */
|
||||
if (nparams != NULL) {
|
||||
*nparams = 3; /* reservation, limit, shares */
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
@ -4973,9 +4973,10 @@ error:
|
||||
/**
|
||||
* virDomainGetSchedulerType:
|
||||
* @domain: pointer to domain object
|
||||
* @nparams: number of scheduler parameters(return value)
|
||||
* @nparams: pointer to number of scheduler parameters, can be NULL
|
||||
* (return value)
|
||||
*
|
||||
* Get the scheduler type.
|
||||
* Get the scheduler type and the number of scheduler parameters.
|
||||
*
|
||||
* Returns NULL in case of error. The caller must free the returned string.
|
||||
*/
|
||||
|
@ -2396,14 +2396,16 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*nparams = 0;
|
||||
if (nparams)
|
||||
*nparams = 0;
|
||||
switch(sched_id) {
|
||||
case XEN_SCHEDULER_SEDF:
|
||||
ret = strdup("sedf");
|
||||
break;
|
||||
case XEN_SCHEDULER_CREDIT:
|
||||
ret = strdup("credit");
|
||||
*nparams = XEN_SCHED_CREDIT_NPARAM;
|
||||
if (nparams)
|
||||
*nparams = XEN_SCHED_CREDIT_NPARAM;
|
||||
break;
|
||||
case XEN_SCHEDULER_CREDIT2:
|
||||
ret = strdup("credit2");
|
||||
|
@ -2624,7 +2624,9 @@ static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
|
||||
{
|
||||
char *type = NULL;
|
||||
|
||||
*nparams = 1;
|
||||
if (nparams)
|
||||
*nparams = 1;
|
||||
|
||||
type = strdup("fair");
|
||||
if (!type)
|
||||
virReportOOMError();
|
||||
|
@ -3531,8 +3531,7 @@ xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams)
|
||||
const char *ret = NULL;
|
||||
char *schedulertype = NULL;
|
||||
|
||||
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
|
||||
|| (nparams == NULL)) {
|
||||
if (domain->conn == NULL || domain->name == NULL) {
|
||||
virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
@ -3562,14 +3561,16 @@ xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams)
|
||||
virReportOOMError();
|
||||
goto error;
|
||||
}
|
||||
*nparams = XEN_SCHED_CRED_NPARAM;
|
||||
if (nparams)
|
||||
*nparams = XEN_SCHED_CRED_NPARAM;
|
||||
} else if (STREQ (ret, "sedf")) {
|
||||
schedulertype = strdup("sedf");
|
||||
if (schedulertype == NULL){
|
||||
virReportOOMError();
|
||||
goto error;
|
||||
}
|
||||
*nparams = XEN_SCHED_SEDF_NPARAM;
|
||||
if (nparams)
|
||||
*nparams = XEN_SCHED_SEDF_NPARAM;
|
||||
} else {
|
||||
virXendError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unknown scheduler"));
|
||||
goto error;
|
||||
|
@ -1767,7 +1767,9 @@ static char *
|
||||
xenapiDomainGetSchedulerType (virDomainPtr dom ATTRIBUTE_UNUSED, int *nparams)
|
||||
{
|
||||
char *result = NULL;
|
||||
*nparams = 0;
|
||||
|
||||
if (nparams)
|
||||
*nparams = 0;
|
||||
if (!(result = strdup("credit")))
|
||||
virReportOOMError();
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user