# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID ea609f28ec01b7cc9b540481cf99173b83135863
# Parent 167790b102ac48e6645882b0cf74ffdb60758f3c
The enforce_dom0_cpus test sets the number of vcpus for the Dom0 and
checks to see if they have been set correctly. We found that on
multi-proc systems, it takes a certain amount of time for the number of
vcpus to change.
This patch checks the number of vcpus inside a loop until it is correct
or 20 seconds elapse, whichever happens first. If after 20 seconds the
number of vcpus is not changed correctly, an error is raised.
Signed-off-by: Rajagopalan Subrahmanian <raj.subrahmanian@xxxxxxxxxx>
---
tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py | 32
+++++++---
1 files changed, 25 insertions(+), 7 deletions(-)
diff -r 167790b102ac -r ea609f28ec01
tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
--- a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
Fri May 19 15:52:35 2006 +0100
+++ b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
Fri May 19 16:21:43 2006 +0100
@@ -65,13 +65,24 @@ if check_status and status != 0:
FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
# 5) check /proc/cpuinfo for cpu count
-cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
-status, output = traceCommand(cmd)
-if check_status and status != 0:
- os.unsetenv("XEND_CONFIG")
- restartXend()
- FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
+# It takes some time for the CPU count to change, on multi-proc systems, so
check the number of procs in a loop for 20 seconds.
+#Sleep inside the loop for a second each time.
+timeout = 20
+starttime = time.time()
+while timeout + starttime > time.time():
+# Check /proc/cpuinfo
+ cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
+ status, output = traceCommand(cmd)
+ if check_status and status != 0:
+ os.unsetenv("XEND_CONFIG")
+ restartXend()
+ FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
+# Has it succeeded? If so, we can leave the loop
+ if output == str(enforce_dom0_cpus):
+ break
+# Sleep for 1 second before trying again
+ time.sleep(1)
if output != str(enforce_dom0_cpus):
os.unsetenv("XEND_CONFIG")
restartXend()
@@ -94,7 +105,14 @@ if check_status and status != 0:
FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
# check restore worked
-num_online = int(getDomInfo("Domain-0", "VCPUs"))
+# Since this also takes time, we will do it in a loop with a 20 second timeout.
+timeout=20
+starttime=time.time()
+while timeout + starttime > time.time():
+ num_online = int(getDomInfo("Domain-0", "VCPUs"))
+ if num_online == dom0_online_vcpus:
+ break
+ time.sleep(1)
if num_online != dom0_online_vcpus:
os.unsetenv("XEND_CONFIG")
restartXend()
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|