mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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.
This commit is contained in:
parent
8a3b74e770
commit
191e1ec65c
@ -3051,7 +3051,7 @@ error:
|
|||||||
* @nparams: pointer to number of memory parameters
|
* @nparams: pointer to number of memory parameters
|
||||||
* @flags: currently unused, for future extension
|
* @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
|
* equal to the number of parameters suggested by @nparams
|
||||||
*
|
*
|
||||||
* As the value of @nparams is dynamic, call the API setting @nparams to 0 and
|
* As the value of @nparams is dynamic, call the API setting @nparams to 0 and
|
||||||
@ -3094,7 +3094,8 @@ virDomainGetMemoryParameters(virDomainPtr domain,
|
|||||||
virDispatchError(NULL);
|
virDispatchError(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((nparams == NULL) || (*nparams < 0)) {
|
if ((nparams == NULL) || (*nparams < 0) ||
|
||||||
|
(params == NULL && *nparams != 0)) {
|
||||||
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -3177,8 +3178,9 @@ error:
|
|||||||
* @nparams: pointer to number of blkio parameters
|
* @nparams: pointer to number of blkio parameters
|
||||||
* @flags: currently unused, for future extension
|
* @flags: currently unused, for future extension
|
||||||
*
|
*
|
||||||
* Get the blkio parameters, the @params array will be filled with the values
|
* Get all blkio parameters, the @params array will be filled with the values
|
||||||
* equal to the number of parameters suggested by @nparams
|
* 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
|
* This function requires privileged access to the hypervisor. This function
|
||||||
* expects the caller to allocate the @params.
|
* expects the caller to allocate the @params.
|
||||||
@ -3202,7 +3204,8 @@ virDomainGetBlkioParameters(virDomainPtr domain,
|
|||||||
virDispatchError(NULL);
|
virDispatchError(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((nparams == NULL) || (*nparams < 0)) {
|
if ((nparams == NULL) || (*nparams < 0) ||
|
||||||
|
(params == NULL && *nparams != 0)) {
|
||||||
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -871,7 +871,7 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((*nparams) != LXC_NB_MEM_PARAM) {
|
if ((*nparams) < LXC_NB_MEM_PARAM) {
|
||||||
lxcError(VIR_ERR_INVALID_ARG,
|
lxcError(VIR_ERR_INVALID_ARG,
|
||||||
"%s", _("Invalid parameter count"));
|
"%s", _("Invalid parameter count"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -883,7 +883,7 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < *nparams; i++) {
|
for (i = 0; i < LXC_NB_MEM_PARAM; i++) {
|
||||||
virMemoryParameterPtr param = ¶ms[i];
|
virMemoryParameterPtr param = ¶ms[i];
|
||||||
val = 0;
|
val = 0;
|
||||||
param->value.ul = 0;
|
param->value.ul = 0;
|
||||||
@ -941,6 +941,7 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*nparams = LXC_NB_MEM_PARAM;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -4957,7 +4957,7 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*nparams) != QEMU_NB_MEM_PARAM) {
|
if ((*nparams) < QEMU_NB_MEM_PARAM) {
|
||||||
qemuReportError(VIR_ERR_INVALID_ARG,
|
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||||
"%s", _("Invalid parameter count"));
|
"%s", _("Invalid parameter count"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4969,7 +4969,7 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < *nparams; i++) {
|
for (i = 0; i < QEMU_NB_MEM_PARAM; i++) {
|
||||||
virMemoryParameterPtr param = ¶ms[i];
|
virMemoryParameterPtr param = ¶ms[i];
|
||||||
val = 0;
|
val = 0;
|
||||||
param->value.ul = 0;
|
param->value.ul = 0;
|
||||||
@ -5027,6 +5027,7 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*nparams = QEMU_NB_MEM_PARAM;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user