Skip to contentSkip to conversation

xm: Fix string index out of range in 'vcpu-pin' command

PATCH New Yu Zhiguo 1 participant 1 message Apr 9, 2010

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

PATCH 1/1 xm: Fix string index out of range in 'vcpu-pin' command

Hi,

This patch fix the following trivial bug.

# xm vcpu-pin 0 0 1,,2
Unexpected error: exceptions.IndexError

Please report to [email protected]
Traceback (most recent call last):
File "/usr/sbin/xm", line 7, in ?
main.main(sys.argv)
File "usr/lib/python2.4/site-packages/xen/xm/main.py", line 3616, in main File "usr/lib/python2.4/site-packages/xen/xm/main.py", line 3640, in _run_cmd File "usr/lib/python2.4/site-packages/xen/xm/main.py", line 1479, in xm_vcpu_pin File "usr/lib/python2.4/site-packages/xen/xm/main.py", line 1467, in cpu_make_map
IndexError: string index out of range

------------------------------------------------

# HG changeset patch
# User Yu Zhiguo <[email protected]>
# Date 1270783370 -28800
# Node ID 3c5685e957d1dae49988e401d988e7400319773d # Parent 3376c90960e83d9f1e34d51601a930290a128c09
xm: Fix string index out of range in 'vcpu-pin' command

if <PCPUs> contins '' (e.g. '1,,2'), error 'string index out of range' occurs. Fix this trivial bug.

tools/python/xen/xm/main.py +2 -0
diff -r 3376c90960e8 -r 3c5685e957d1 tools/python/xen/xm/main.py
@@ -1458,6 +1458,8 @@
     def cpu_make_map(cpulist):
         cpus = []
         for c in cpulist.split(','):
+            if c == '':
+                continue
             if c.find('-') != -1:
                 (x,y) = c.split('-')
                 for i in range(int(x),int(y)+1):