[libvirt] [PATCH] virsh: forbid negative vcpu argument to vcpupin.
Peter Krempa
pkrempa at redhat.com
Wed May 28 09:40:45 UTC 2014
On 05/28/14 11:33, Jincheng Miao wrote:
> vcpupin will allow argument --vcpu as a signed number,
> and pass it to virDomainPinVcpu directlly without
> checking if this value is positive(valid).
>
>> virsh vcpupin r7 -1 0
> error: numerical overflow: input too large: 4294967295
>
> This message is inaccurate, and the negative vcpu is
> non-valuable. So forbid vcpu argument as a negative.
>
> Signed-off-by: Jincheng Miao <jmiao at redhat.com>
> ---
> tools/virsh-domain.c | 24 ++++++++++--------------
> 1 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 84a6706..d9804cc 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -5797,7 +5797,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
> {
> virDomainInfo info;
> virDomainPtr dom;
> - int vcpu = -1;
> + unsigned int vcpu;
> const char *cpulist = NULL;
> bool ret = false;
> unsigned char *cpumap = NULL;
This change will break the output code that is present later that relies
on vcpu being set to -1 if it wasn't specified by the user:
for (i = 0; i < ncpus; i++) {
if (vcpu != -1 && i != vcpu)
continue;
vshPrint(ctl, "%4zu: ", i);
ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, i);
vshPrint(ctl, "\n");
if (!ret)
break;
}
Also breaks the output:
$ virsh vcpupin gl
VCPU: CPU Affinity
----------------------------------
0: 0-3
1: 0-3
After patching:
$ tools/virsh vcpupin gl
error: vcpupin: Invalid vCPU number.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140528/5c09c6e0/attachment-0001.sig>
More information about the libvir-list
mailing list