mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virsh: avoid missing zero value judgement in cmdBlkiotune
* tools/virsh.c: fix missing zero value judgement in cmdBlkiotune and correct vshError information. when weight is equal to 0, the cmdBlkiotune will not raise any error information when judge weight value first time, and execute else branch to judge weight value again, strncpy(temp->field, VIR_DOMAIN_BLKIO_WEIGHT, sizeof(temp->field)) will be not executed for ever. However, if and only if param->field is equal to VIR_DOMAIN_BLKIO_WEIGHT, underlying qemuDomainSetBlkioParameters function will check whether weight value is in range [100, 1000]. * how to reproduce? % virsh blkiotune ${guestname} --weight 0 Signed-off-by: Alex Jia <ajia@redhat.com>
This commit is contained in:
parent
b240f966d9
commit
3f39a0bf27
@ -4004,6 +4004,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|||||||
virDomainPtr dom;
|
virDomainPtr dom;
|
||||||
int weight = 0;
|
int weight = 0;
|
||||||
int nparams = 0;
|
int nparams = 0;
|
||||||
|
int rv = 0;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
virTypedParameterPtr params = NULL, temp = NULL;
|
virTypedParameterPtr params = NULL, temp = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@ -4031,15 +4032,15 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptInt(cmd, "weight", &weight) < 0) {
|
if ((rv = vshCommandOptInt(cmd, "weight", &weight)) < 0) {
|
||||||
vshError(ctl, "%s",
|
vshError(ctl, "%s",
|
||||||
_("Unable to parse integer parameter"));
|
_("Unable to parse integer parameter"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weight) {
|
if (rv > 0) {
|
||||||
nparams++;
|
nparams++;
|
||||||
if (weight < 0) {
|
if (weight <= 0) {
|
||||||
vshError(ctl, _("Invalid value of %d for I/O weight"), weight);
|
vshError(ctl, _("Invalid value of %d for I/O weight"), weight);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user