mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virsh: Display an error when passing count <= 0 to setvcpus
The number of vCPUs for a guest must be between 1 and the maximum value configured in the domain XML. This commit introduces checks to make sure that passing count <= 0 results in an error. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248277 Signed-off-by: Luyao Huang <lhuang@redhat.com>
This commit is contained in:
parent
4527b2ae50
commit
c62c59a984
@ -6873,7 +6873,7 @@ static bool
|
||||
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virDomainPtr dom;
|
||||
int count = 0;
|
||||
unsigned int count = 0;
|
||||
bool ret = false;
|
||||
bool maximum = vshCommandOptBool(cmd, "maximum");
|
||||
bool config = vshCommandOptBool(cmd, "config");
|
||||
@ -6900,9 +6900,14 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
|
||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||
return false;
|
||||
|
||||
if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0)
|
||||
if (vshCommandOptUInt(ctl, cmd, "count", &count) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (count == 0) {
|
||||
vshError(ctl, _("Can't set 0 processors for a VM"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* none of the options were specified */
|
||||
if (!current && flags == 0) {
|
||||
if (virDomainSetVcpus(dom, count) != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user