Re: [PATCH] virsh: forbid negative vcpu argument to vcpupin.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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


Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]