[Libvir] [PATCH] virsh vcpupin guards CPU not existing.

Hi When CPU not existing is set to virsh vcpupin, CPU affinity is set to all CPU. -------------------------------------------------------------------------------- # virsh vcpuinfo 0 VCPU: 0 CPU: 0 State: blocked CPU time: 428.8s CPU Affinity: y- # virsh vcpupin 0 0 100 libvir: Xen error : failed Xen syscall ioctl -1208339792 # virsh vcpuinfo 0 VCPU: 0 CPU: 0 State: blocked CPU time: 429.6s CPU Affinity: yy -------------------------------------------------------------------------------- This patch returns an error, when CPU not existing is set to virsh vcpupin. -------------------------------------------------------------------------------- # virsh vcpupin 0 0 100 error: Physical CPU 100 doesn't exist. -------------------------------------------------------------------------------- Signed-off-by: Masayuki Sunou <fj1826dm@aa.jp.fujitsu.com> Thanks, Masayuki Sunou. -------------------------------------------------------------------------------- Index: src/virsh.c =================================================================== RCS file: /data/cvs/libvirt/src/virsh.c,v retrieving revision 1.67 diff -u -p -r1.67 virsh.c --- src/virsh.c 20 Mar 2007 15:31:46 -0000 1.67 +++ src/virsh.c 22 Mar 2007 06:05:14 -0000 @@ -1358,6 +1358,11 @@ cmdVcpupin(vshControl * ctl, vshCmd * cm if (cpu < VIR_NODEINFO_MAXCPUS(nodeinfo)) { VIR_USE_CPU(cpumap, cpu); + } else { + vshError(ctl, FALSE, _("Physical CPU %d doesn't exist."), cpu); + free(cpumap); + virDomainFree(dom); + return FALSE; } cpulist = index(cpulist, ','); if (cpulist) --------------------------------------------------------------------------------

On Thu, Mar 22, 2007 at 03:14:29PM +0900, Masayuki Sunou wrote:
Hi
When CPU not existing is set to virsh vcpupin, CPU affinity is set to all CPU.
Oh, right, not reporting and not exiting from the function at that point is clearly a bug ! Applied and commited to CVS, thanks a lot ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (2)
-
Daniel Veillard
-
Masayuki Sunou