[PATCH] virsh: report error if vcpu number exceed the guest maxvcpu number

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

 



If usr pass a vcpu which exceed guest maxvcpu number, virsh client
will only output an header like this:

 # virsh vcpupin test3 1000
 VCPU: CPU Affinity
 ----------------------------------

After this patch:

 # virsh vcpupin test3 1000
 error: vcpu 1000 is out of range of cpu count 2

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 tools/virsh-domain.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 27d62e9..681fc1a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6497,6 +6497,11 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
         }
 
+        if (got_vcpu && vcpu >= ncpus) {
+            vshError(ctl, _("vcpu %d is out of range of cpu count %d"), vcpu, ncpus);
+            goto cleanup;
+        }
+
         cpumaplen = VIR_CPU_MAPLEN(maxcpu);
         cpumap = vshMalloc(ctl, ncpus * cpumaplen);
         if ((ncpus = virDomainGetVcpuPinInfo(dom, ncpus, cpumap,
-- 
1.8.3.1

--
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]