direct-io.hg

view tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py @ 10702:ef8d08aa2072

[XM-TEST] Increase timeout on hotplug-cpus-down test to 30 seconds.
This is needed when dom0 has 32 CPUs.
Signed-off-by: Susan Krysan <krysans@unisys.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jul 14 12:00:02 2006 +0100 (2006-07-14)
parents 647d012b9a36
children
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Authors: Dan Smith <danms@us.ibm.com>
5 # Ryan Harper <ryanh@us.ibm.com>
7 # 1) Make sure we have a multi cpu system and dom0 has at
8 # least 2 vcpus online.
9 # 2) clone standard config (/etc/xen/xend-config.sxp)
10 # 3) modify clone with enforce_dom0_cpus=X
11 # 4) restart xend with modified config
12 # 5) check /proc/cpuinfo for cpu count
13 # 6) check xm info 'VCPUs' field to see that only 'enforce_dom0_cpus'
14 # number of cpus are online in dom0
15 # 7) Restore initial dom0 vcpu state
16 # 8) Restart xend with default config
18 import sys
19 import re
20 import time
21 import os
23 # what value should dom0_cpus enforce?
24 enforce_dom0_cpus=1
26 from XmTestLib import *
28 check_status = 1
29 max_tries = 10
31 def reset_vcpu_count():
32 status, output = traceCommand("xm vcpu-set 0 %s"%(dom0_online_vcpus))
33 if status != 0:
34 print "WARNING!!! Unable to set vcpus back to %s, please set manually"\
35 %(dom0_online_vcpus)
37 # 1) Make sure we have a multi cpu system and dom0 has at least 2 vcpus online.
39 if smpConcurrencyLevel() <= 1:
40 print "*** NOTE: This machine does not have more than one physical"
41 print " or logical cpu. The vcpu-disable test cannot be run!"
42 SKIP("Host not capable of running test")
44 # count number of online vcpus in dom0
45 dom0_online_vcpus = int(getDomInfo("Domain-0", "VCPUs"))
46 if dom0_online_vcpus <= 1:
47 print "*** NOTE: DOM0 needs at least 2 VCPUs online to run this test"
48 print " Please enable additional vcpus if possible via xm vcpu-set"
49 SKIP("Host state not capable of running test")
51 # 2) clone standard config (/etc/xen/xend-config.sxp)
52 # 3) modify clone with enforce_dom0_cpus=1
53 old_config="/etc/xen/xend-config.sxp"
54 new_config ="/tmp/xend-config.sxp"
55 cmd = "sed -e 's,dom0-cpus 0,dom0-cpus %s,' %s > %s" % (enforce_dom0_cpus,
56 old_config,
57 new_config)
58 status, output = traceCommand(cmd)
59 if check_status and status != 0:
60 FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
63 # 4) restart xend with new config
64 os.putenv("XEND_CONFIG", "/tmp/xend-config.sxp")
65 status = restartXend()
66 os.unsetenv("XEND_CONFIG")
67 if check_status and status != 0:
68 ns, no = restartXend()
69 if ns != 0:
70 FAIL("Restarting xend isn't working: something is WAY broken")
71 else:
72 FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
74 # 5) check /proc/cpuinfo for cpu count
76 # It takes some time for the CPU count to change, on multi-proc systems, so check the number of procs in a loop for 30 seconds.
77 #Sleep inside the loop for a second each time.
78 timeout = 30
79 starttime = time.time()
80 while timeout + starttime > time.time():
81 # Check /proc/cpuinfo
82 cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
83 status, output = traceCommand(cmd)
84 if check_status and status != 0:
85 reset_vcpu_count()
86 restartXend()
87 FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
88 # Has it succeeded? If so, we can leave the loop
89 if output == str(enforce_dom0_cpus):
90 break
91 # Sleep for 1 second before trying again
92 time.sleep(1)
93 if output != str(enforce_dom0_cpus):
94 reset_vcpu_count()
95 restartXend()
96 FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s != %s)"%(output,
97 enforce_dom0_cpus))
99 # 6) count number of online cpus and see that it matches enforce value
100 num_online = int(getDomInfo("Domain-0", "VCPUs"))
101 if num_online != enforce_dom0_cpus:
102 reset_vcpu_count()
103 restartXend()
104 FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online,
105 enforce_dom0_cpus))
107 # 7) restore dead processors
108 reset_vcpu_count()
110 # check restore worked
111 # Since this also takes time, we will do it in a loop with a 30 second timeout.
112 timeout=30
113 starttime=time.time()
114 while timeout + starttime > time.time():
115 num_online = int(getDomInfo("Domain-0", "VCPUs"))
116 if num_online == dom0_online_vcpus:
117 break
118 time.sleep(1)
119 if num_online != dom0_online_vcpus:
120 restartXend()
121 FAIL("failed to restore dom0's VCPUs")
124 # 8) Restart xend with default config
125 restartXend()