提交 191e1ec6 编写于 作者: M Matthias Bolte

Clarify that virDomainGet(Memory|Blkio)Parameters doesn't support subsets

Improve invalid argument checks in the size query case. The drivers already
relied on this unchecked behavior.

Relax the implementation of virDomainGet(Memory|Blkio)MemoryParameters
in the drivers and allow to pass more memory than necessary for all
parameters.
上级 8a3b74e7
......@@ -3051,7 +3051,7 @@ error:
* @nparams: pointer to number of memory parameters
* @flags: currently unused, for future extension
*
* Get the memory parameters, the @params array will be filled with the values
* Get all memory parameters, the @params array will be filled with the values
* equal to the number of parameters suggested by @nparams
*
* As the value of @nparams is dynamic, call the API setting @nparams to 0 and
......@@ -3094,7 +3094,8 @@ virDomainGetMemoryParameters(virDomainPtr domain,
virDispatchError(NULL);
return -1;
}
if ((nparams == NULL) || (*nparams < 0)) {
if ((nparams == NULL) || (*nparams < 0) ||
(params == NULL && *nparams != 0)) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
......@@ -3177,8 +3178,9 @@ error:
* @nparams: pointer to number of blkio parameters
* @flags: currently unused, for future extension
*
* Get the blkio parameters, the @params array will be filled with the values
* equal to the number of parameters suggested by @nparams
* Get all blkio parameters, the @params array will be filled with the values
* equal to the number of parameters suggested by @nparams.
* See virDomainGetMemoryParameters for an equivalent usage example.
*
* This function requires privileged access to the hypervisor. This function
* expects the caller to allocate the @params.
......@@ -3202,7 +3204,8 @@ virDomainGetBlkioParameters(virDomainPtr domain,
virDispatchError(NULL);
return -1;
}
if ((nparams == NULL) || (*nparams < 0)) {
if ((nparams == NULL) || (*nparams < 0) ||
(params == NULL && *nparams != 0)) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
......
......@@ -871,7 +871,7 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
ret = 0;
goto cleanup;
}
if ((*nparams) != LXC_NB_MEM_PARAM) {
if ((*nparams) < LXC_NB_MEM_PARAM) {
lxcError(VIR_ERR_INVALID_ARG,
"%s", _("Invalid parameter count"));
goto cleanup;
......@@ -883,7 +883,7 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
for (i = 0; i < *nparams; i++) {
for (i = 0; i < LXC_NB_MEM_PARAM; i++) {
virMemoryParameterPtr param = &params[i];
val = 0;
param->value.ul = 0;
......@@ -941,6 +941,7 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
}
}
*nparams = LXC_NB_MEM_PARAM;
ret = 0;
cleanup:
......
......@@ -4957,7 +4957,7 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
if ((*nparams) != QEMU_NB_MEM_PARAM) {
if ((*nparams) < QEMU_NB_MEM_PARAM) {
qemuReportError(VIR_ERR_INVALID_ARG,
"%s", _("Invalid parameter count"));
goto cleanup;
......@@ -4969,7 +4969,7 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
for (i = 0; i < *nparams; i++) {
for (i = 0; i < QEMU_NB_MEM_PARAM; i++) {
virMemoryParameterPtr param = &params[i];
val = 0;
param->value.ul = 0;
......@@ -5027,6 +5027,7 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
}
}
*nparams = QEMU_NB_MEM_PARAM;
ret = 0;
cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册