ia64/xen-unstable

changeset 10045:fdd64fd51edd

Fix up enforce_dom0_cpu test case to check that dom0 has at least 2 vcpus
online. Also fix bogus call to vcpu-enable; xm now uses vcpu-set as method for
enable/disable of vcpus. Previously after a successful test run, this test
would not leave dom0 in the same state as it was when the test started. Also
some comment language changes and 80 column formatting.
author Ryan Harper <ryanh@us.ibm.com>
date Thu May 11 13:49:20 2006 +0100 (2006-05-11)
parents d5d46dbfde22
children 08f5adb5058b
files tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
line diff
     1.1 --- a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py	Thu May 11 13:45:10 2006 +0100
     1.2 +++ b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py	Thu May 11 13:49:20 2006 +0100
     1.3 @@ -4,20 +4,23 @@
     1.4  # Authors: Dan Smith <danms@us.ibm.com>
     1.5  #          Ryan Harper <ryanh@us.ibm.com>
     1.6  
     1.7 -# 1) Make sure we have a multi cpu system
     1.8 +# 1) Make sure we have a multi cpu system and dom0 has at 
     1.9 +#    least 2 vcpus online.
    1.10  # 2) clone standard config (/etc/xen/xend-config.sxp) 
    1.11  # 3) modify clone with enforce_dom0_cpus=X
    1.12  # 4) restart xend with modified config
    1.13  # 5) check /proc/cpuinfo for cpu count
    1.14 -# 6) check xm list -v to see that only 1 cpu is online for dom0
    1.15 -# 7) Restart xend with default config
    1.16 +# 6) check xm info 'VCPUs' field to see that only 'enforce_dom0_cpus' 
    1.17 +#    number of cpus are online in dom0
    1.18 +# 7) Restore initial dom0 vcpu state
    1.19 +# 8) Restart xend with default config
    1.20  
    1.21  import sys
    1.22  import re
    1.23  import time
    1.24  import os
    1.25  
    1.26 -# what value should dom0_cpus be enforced?
    1.27 +# what value should dom0_cpus enforce?
    1.28  enforce_dom0_cpus=1
    1.29  
    1.30  from XmTestLib import *
    1.31 @@ -25,12 +28,19 @@ from XmTestLib import *
    1.32  check_status = 1
    1.33  max_tries = 10
    1.34  
    1.35 -# 1) Make sure we have a multi cpu system
    1.36 +# 1) Make sure we have a multi cpu system and dom0 has at least 2 vcpus online.
    1.37  
    1.38  if smpConcurrencyLevel() <= 1:
    1.39      print "*** NOTE: This machine does not have more than one physical"
    1.40      print "          or logical cpu.  The vcpu-disable test cannot be run!"
    1.41      SKIP("Host not capable of running test")
    1.42 +
    1.43 +# count number of online vcpus in dom0
    1.44 +dom0_online_vcpus = int(getDomInfo("Domain-0", "VCPUs"))
    1.45 +if dom0_online_vcpus <= 1:
    1.46 +    print "*** NOTE: DOM0 needs at least 2 VCPUs online to run this test"
    1.47 +    print "          Please enable additional vcpus if possible via xm vcpu-set"
    1.48 +    SKIP("Host state not capable of running test")
    1.49      
    1.50  # 2) clone standard config (/etc/xen/xend-config.sxp) 
    1.51  # 3) modify clone with enforce_dom0_cpus=1
    1.52 @@ -65,26 +75,33 @@ if check_status and status != 0:
    1.53  if output != str(enforce_dom0_cpus):
    1.54      os.unsetenv("XEND_CONFIG")
    1.55      restartXend()
    1.56 -    FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s != %s)" %(output, enforce_dom0_cpus))
    1.57 +    FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s != %s)"%(output, 
    1.58 +                                                             enforce_dom0_cpus))
    1.59  
    1.60 -# 7) count number of online cpus and see that it matches enforce value
    1.61 -dom0vcpus = getVcpuInfo("Domain-0")
    1.62 -num_online = len(filter(lambda x: x >= 0, dom0vcpus.values()))
    1.63 +# 6) count number of online cpus and see that it matches enforce value
    1.64 +num_online = int(getDomInfo("Domain-0", "VCPUs"))
    1.65  if num_online != enforce_dom0_cpus:
    1.66      os.unsetenv("XEND_CONFIG")
    1.67      restartXend()
    1.68 -    FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online, enforce_dom0_cpus))
    1.69 +    FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online, 
    1.70 +                                                             enforce_dom0_cpus))
    1.71  
    1.72 -# restore dead processors 
    1.73 -for (k,v) in zip(dom0vcpus.keys(),dom0vcpus.values()):
    1.74 -    if v == -1:
    1.75 -        status, output = traceCommand("xm vcpu-enable 0 %s"%(k))
    1.76 -        if check_status and status != 0:
    1.77 -            os.unsetenv("XEND_CONFIG")
    1.78 -            restartXend()
    1.79 -            FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
    1.80 +# 7) restore dead processors 
    1.81 +status, output = traceCommand("xm vcpu-set 0 %s"%(dom0_online_vcpus))
    1.82 +if check_status and status != 0:
    1.83 +    os.unsetenv("XEND_CONFIG")
    1.84 +    restartXend()
    1.85 +    FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
    1.86  
    1.87 -# Restart xend with default config
    1.88 +# check restore worked
    1.89 +num_online = int(getDomInfo("Domain-0", "VCPUs"))
    1.90 +if num_online != dom0_online_vcpus:
    1.91 +    os.unsetenv("XEND_CONFIG")
    1.92 +    restartXend()
    1.93 +    FAIL("failed to restore dom0's VCPUs")
    1.94 +
    1.95 +
    1.96 +# 8) Restart xend with default config
    1.97  os.unsetenv("XEND_CONFIG")
    1.98  restartXend()
    1.99