diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 41915481be17ed1c87aed2304fd17e872c9f6f27..3f032f419a52585acf8e26956b6845383b717b7c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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)