Improve virTypedParameterValidateSet

Assume not only domain object will use it.
This commit is contained in:
Osier Yang 2012-09-10 20:08:54 +08:00
parent 615851dd19
commit 1e2864c2cd

View File

@ -3742,15 +3742,15 @@ error:
/* Helper function called to validate incoming client array on any /* Helper function called to validate incoming client array on any
* interface that sets typed parameters in the hypervisor. */ * interface that sets typed parameters in the hypervisor. */
static int static int
virTypedParameterValidateSet(virDomainPtr domain, virTypedParameterValidateSet(virConnectPtr conn,
virTypedParameterPtr params, virTypedParameterPtr params,
int nparams) int nparams)
{ {
bool string_okay; bool string_okay;
int i; int i;
string_okay = VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, string_okay = VIR_DRV_SUPPORTS_FEATURE(conn->driver,
domain->conn, conn,
VIR_DRV_FEATURE_TYPED_PARAM_STRING); VIR_DRV_FEATURE_TYPED_PARAM_STRING);
for (i = 0; i < nparams; i++) { for (i = 0; i < nparams; i++) {
if (strnlen(params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH) == if (strnlen(params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH) ==
@ -3817,7 +3817,7 @@ virDomainSetMemoryParameters(virDomainPtr domain,
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
virCheckPositiveArgGoto(nparams, error); virCheckPositiveArgGoto(nparams, error);
if (virTypedParameterValidateSet(domain, params, nparams) < 0) if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0)
goto error; goto error;
conn = domain->conn; conn = domain->conn;
@ -3958,7 +3958,7 @@ virDomainSetNumaParameters(virDomainPtr domain,
} }
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
virCheckPositiveArgGoto(nparams, error); virCheckPositiveArgGoto(nparams, error);
if (virTypedParameterValidateSet(domain, params, nparams) < 0) if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0)
goto error; goto error;
conn = domain->conn; conn = domain->conn;
@ -4086,7 +4086,7 @@ virDomainSetBlkioParameters(virDomainPtr domain,
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
virCheckNonNegativeArgGoto(nparams, error); virCheckNonNegativeArgGoto(nparams, error);
if (virTypedParameterValidateSet(domain, params, nparams) < 0) if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0)
goto error; goto error;
conn = domain->conn; conn = domain->conn;
@ -6941,7 +6941,7 @@ virDomainSetSchedulerParameters(virDomainPtr domain,
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
virCheckNonNegativeArgGoto(nparams, error); virCheckNonNegativeArgGoto(nparams, error);
if (virTypedParameterValidateSet(domain, params, nparams) < 0) if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0)
goto error; goto error;
conn = domain->conn; conn = domain->conn;
@ -7005,7 +7005,7 @@ virDomainSetSchedulerParametersFlags(virDomainPtr domain,
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
virCheckNonNegativeArgGoto(nparams, error); virCheckNonNegativeArgGoto(nparams, error);
if (virTypedParameterValidateSet(domain, params, nparams) < 0) if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0)
goto error; goto error;
conn = domain->conn; conn = domain->conn;
@ -7286,7 +7286,7 @@ virDomainSetInterfaceParameters(virDomainPtr domain,
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
virCheckPositiveArgGoto(nparams, error); virCheckPositiveArgGoto(nparams, error);
if (virTypedParameterValidateSet(domain, params, nparams) < 0) if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0)
goto error; goto error;
conn = domain->conn; conn = domain->conn;
@ -19246,7 +19246,7 @@ int virDomainSetBlockIoTune(virDomainPtr dom,
virCheckPositiveArgGoto(nparams, error); virCheckPositiveArgGoto(nparams, error);
virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(params, error);
if (virTypedParameterValidateSet(dom, params, nparams) < 0) if (virTypedParameterValidateSet(dom->conn, params, nparams) < 0)
goto error; goto error;
conn = dom->conn; conn = dom->conn;