ia64/xen-unstable

view tools/xm-test/lib/XmTestLib/arch.py @ 11962:a661566745ae

Add x86_64 to the supported architectures since otherwise the tests
don't run.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Oct 24 16:46:02 2006 +0100 (2006-10-24)
parents 1c74ee519776
children 2368e779f89f
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 ia_getDeviceModel():
50 """Get the path to the device model based on
51 the architecture reported in uname"""
52 architecture = os.uname()[4]
53 if re.search("64", architecture):
54 return "/usr/lib64/xen/bin/qemu-dm"
55 else:
56 return "/usr/lib/xen/bin/qemu-dm"
58 def ia_getDefaultKernel():
59 """Get the path to the default DomU kernel"""
60 dom0Ver = commands.getoutput("uname -r");
61 domUVer = dom0Ver.replace("xen0", "xenU");
63 return "/boot/vmlinuz-" + domUVer;
65 ia_ParavirtDefaults = {"memory" : 64,
66 "vcpus" : 1,
67 "kernel" : ia_getDefaultKernel(),
68 "root" : "/dev/ram0",
69 "ramdisk" : getRdPath() + "/initrd.img",
70 }
71 ia_HVMDefaults = {"memory" : 64,
72 "vcpus" : 1,
73 "acpi" : 0,
74 "apic" : 0,
75 "disk" : ["file:%s/disk.img,ioemu:%s,w!" %
76 (getRdPath(), BLOCK_ROOT_DEV)],
77 "kernel" : "/usr/lib/xen/boot/hvmloader",
78 "builder" : "hvm",
79 "sdl" : 0,
80 "vnc" : 0,
81 "vncviewer" : 0,
82 "nographic" : 1,
83 "serial" : "pty",
84 "device_model" : ia_getDeviceModel(),
85 }
86 # End : Intel ia32 and ia64 as well as AMD 32-bit and 64-bit processors
88 # Begin: PowerPC
89 def ppc_checkBuffer(buffer):
90 checks = [
91 {"pattern" : re.compile("^\d+:mon>\s*$", re.MULTILINE),
92 "message" : "domain trapped into XMON"},
93 ]
95 for i in range(0, len(checks)):
96 check=checks[i]
97 if check.get('pattern').search(buffer):
98 FAIL(check.get('message'))
100 return
102 def ppc_minSafeMem():
103 return 64
105 def ppc_getDefaultKernel():
106 """Get the path to the default DomU kernel"""
107 dom0Ver = commands.getoutput("uname -r");
108 domUVer = dom0Ver.replace("xen0", "xenU");
110 return "/boot/vmlinux-" + domUVer;
112 ppc_ParavirtDefaults = {"memory" : 64,
113 "vcpus" : 1,
114 "kernel" : ppc_getDefaultKernel(),
115 "root" : "/dev/ram0",
116 "ramdisk" : getRdPath() + "/initrd.img",
117 "extra" : "xencons=tty128 console=tty128",
118 }
119 # End : PowerPC
121 """Convert from uname specification to a more general platform."""
122 _uname_to_arch_map = {
123 "i386" : "x86",
124 "i486" : "x86",
125 "i586" : "x86",
126 "i686" : "x86",
127 "x86_64": "x86_64",
128 "ia64" : "ia64",
129 "ppc" : "powerpc",
130 "ppc64" : "powerpc",
131 }
133 # Lookup current platform.
134 _arch = _uname_to_arch_map.get(os.uname()[4], "Unknown")
135 if _arch == "x86" or _arch == "x86_64" or _arch == "ia64":
136 minSafeMem = ia_minSafeMem
137 getDefaultKernel = ia_getDefaultKernel
138 checkBuffer = ia_checkBuffer
139 if config.ENABLE_HVM_SUPPORT:
140 configDefaults = ia_HVMDefaults
141 else:
142 configDefaults = ia_ParavirtDefaults
143 elif _arch == "powerpc":
144 minSafeMem = ppc_minSafeMem
145 getDefaultKernel = ppc_getDefaultKernel
146 checkBuffer = ppc_checkBuffer
147 configDefaults = ppc_ParavirtDefaults
148 else:
149 raise ValueError, "Unknown architecture!"