ia64/xen-unstable

view tools/xm-test/lib/XmTestLib/arch.py @ 15879:fec8b52b1a7f

[xm-test] Set "console=xvc0" for xm-test guests on Intel architecture platforms.
Tests have been failing because the console for the test ramdisk wasn't using
xvc0 so testcases were not able to interact with it.

Signed-off-by: James Bulpin <james@xensource.com>
author James Bulpin <james@xensource.com>
date Tue Sep 11 19:11:02 2007 +0100 (2007-09-11)
parents d1cce5bafe28
children b0d7780794eb
line source
1 #!/usr/bin/python
2 """
3 arch.py - Encapsulate all logic regarding what type of hardware xen
4 is running on to make adding new platforms easier.
6 Copyright (C) 2006 Tony Breeds IBM Corporation
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; under version 2 of the License.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 """
23 import os
24 import re
25 import config
26 import commands
28 from Test import *
30 BLOCK_ROOT_DEV = "hda"
32 # This isn't truly platform related but it makes the code tidier
33 def getRdPath():
34 """Locate the full path to ramdisks needed by domUs"""
35 rdpath = os.environ.get("RD_PATH")
36 if not rdpath:
37 rdpath = "../../ramdisk"
38 rdpath = os.path.abspath(rdpath)
40 return rdpath
42 # Begin: Intel ia32 and ia64 as well as AMD 32-bit and 64-bit processors
43 def ia_checkBuffer(buffer):
44 return
46 def ia_minSafeMem():
47 return 32
49 def ia64_minSafeMem():
50 return 128
52 def ia_getDeviceModel():
53 """Get the path to the device model based on
54 the architecture reported in uname"""
55 architecture = os.uname()[4]
56 if re.search("64", architecture):
57 return "/usr/lib64/xen/bin/qemu-dm"
58 else:
59 return "/usr/lib/xen/bin/qemu-dm"
61 def ia_getDefaultKernel():
62 """Get the path to the default DomU kernel"""
63 dom0Ver = commands.getoutput("uname -r");
64 domUVer = dom0Ver.replace("xen0", "xenU");
66 return "/boot/vmlinuz-" + domUVer;
68 ia_ParavirtDefaults = {"memory" : 64,
69 "vcpus" : 1,
70 "kernel" : ia_getDefaultKernel(),
71 "root" : "/dev/ram0",
72 "ramdisk" : getRdPath() + "/initrd.img",
73 "extra" : "console=xvc0",
74 }
75 ia_HVMDefaults = {"memory" : 64,
76 "vcpus" : 1,
77 "acpi" : 0,
78 "disk" : ["file:%s/disk.img,ioemu:%s,w!" %
79 (getRdPath(), BLOCK_ROOT_DEV)],
80 "kernel" : "/usr/lib/xen/boot/hvmloader",
81 "builder" : "hvm",
82 "sdl" : 0,
83 "vnc" : 0,
84 "vncviewer" : 0,
85 "nographic" : 1,
86 "serial" : "pty",
87 "device_model" : ia_getDeviceModel(),
88 }
89 # End : Intel ia32 and ia64 as well as AMD 32-bit and 64-bit processors
91 # Begin: PowerPC
92 def ppc_checkBuffer(buffer):
93 checks = [
94 {"pattern" : re.compile("^\d+:mon>\s*$", re.MULTILINE),
95 "message" : "domain trapped into XMON"},
96 ]
98 for i in range(0, len(checks)):
99 check=checks[i]
100 if check.get('pattern').search(buffer):
101 FAIL(check.get('message'))
103 return
105 def ppc_minSafeMem():
106 return 64
108 def ppc_getDefaultKernel():
109 """Get the path to the default DomU kernel"""
110 dom0Ver = commands.getoutput("uname -r");
111 domUVer = dom0Ver.replace("xen0", "xenU");
113 return "/boot/vmlinux-" + domUVer;
115 ppc_ParavirtDefaults = {"memory" : 64,
116 "vcpus" : 1,
117 "kernel" : ppc_getDefaultKernel(),
118 "root" : "/dev/ram0",
119 "ramdisk" : getRdPath() + "/initrd.img",
120 "extra" : "xencons=tty128 console=tty128",
121 }
122 # End : PowerPC
124 """Convert from uname specification to a more general platform."""
125 _uname_to_arch_map = {
126 "i386" : "x86",
127 "i486" : "x86",
128 "i586" : "x86",
129 "i686" : "x86",
130 "x86_64": "x86_64",
131 "ia64" : "ia64",
132 "ppc" : "powerpc",
133 "ppc64" : "powerpc",
134 }
136 # Lookup current platform.
137 _arch = _uname_to_arch_map.get(os.uname()[4], "Unknown")
138 if _arch == "x86" or _arch == "x86_64" or _arch == "ia64":
139 minSafeMem = ia_minSafeMem
140 getDefaultKernel = ia_getDefaultKernel
141 checkBuffer = ia_checkBuffer
142 if config.ENABLE_HVM_SUPPORT:
143 configDefaults = ia_HVMDefaults
144 else:
145 configDefaults = ia_ParavirtDefaults
147 # note: xm-test generates an uncompressed image, and this code
148 # expects one. This will fail with a gzip-ed image.
149 if configDefaults['ramdisk']:
150 rd_size = os.stat(configDefaults['ramdisk']).st_size
151 clause = 'ramdisk_size=' + str((rd_size / 1024)+1)
152 if configDefaults.has_key('extra'):
153 configDefaults['extra'] = configDefaults['extra'] + " " + clause
154 else:
155 configDefaults['extra'] = clause
157 if _arch == "ia64":
158 minSafeMem = ia64_minSafeMem
159 configDefaults['memory'] = ia64_minSafeMem()
161 elif _arch == "powerpc":
162 minSafeMem = ppc_minSafeMem
163 getDefaultKernel = ppc_getDefaultKernel
164 checkBuffer = ppc_checkBuffer
165 configDefaults = ppc_ParavirtDefaults
166 else:
167 raise ValueError, "Unknown architecture!"