1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/usr/bin/python
"""
arch.py - Encapsulate all logic regarding what type of hardware xen
is running on to make adding new platforms easier.
Copyright (C) 2006 Tony Breeds IBM Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; under version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
import os
import re
import config
import commands
from Test import *
BLOCK_ROOT_DEV = "hda"
# This isn't truly platform related but it makes the code tidier
def getRdPath():
"""Locate the full path to ramdisks needed by domUs"""
rdpath = os.environ.get("RD_PATH")
if not rdpath:
rdpath = "../../ramdisk"
rdpath = os.path.abspath(rdpath)
return rdpath
# Begin: Intel ia32 and ia64 as well as AMD 32-bit and 64-bit processors
def ia_checkBuffer(buffer):
return
def ia_minSafeMem():
return 32
def ia64_minSafeMem():
return 128
def ia_getDeviceModel():
"""Get the path to the device model based on
the architecture reported in uname"""
architecture = os.uname()[4]
if re.search("64", architecture):
return "/usr/lib64/xen/bin/qemu-dm"
else:
return "/usr/lib/xen/bin/qemu-dm"
def ia_getDefaultKernel():
"""Get the path to the default DomU kernel"""
dom0Ver = commands.getoutput("uname -r");
domUVer = dom0Ver.replace("xen0", "xenU");
return "/boot/vmlinuz-" + domUVer;
ia_ParavirtDefaults = {"memory" : 64,
"vcpus" : 1,
"kernel" : ia_getDefaultKernel(),
"root" : "/dev/ram0",
"ramdisk" : getRdPath() + "/initrd.img",
"extra" : "console=xvc0",
}
ia_HVMDefaults = {"memory" : 64,
"vcpus" : 1,
"acpi" : 0,
"disk" : ["file:%s/disk.img,ioemu:%s,w!" %
(getRdPath(), BLOCK_ROOT_DEV)],
"kernel" : "/usr/lib/xen/boot/hvmloader",
"builder" : "hvm",
"sdl" : 0,
"vnc" : 0,
"vncviewer" : 0,
"nographic" : 1,
"serial" : "pty",
"device_model" : ia_getDeviceModel(),
}
# End : Intel ia32 and ia64 as well as AMD 32-bit and 64-bit processors
"""Convert from uname specification to a more general platform."""
_uname_to_arch_map = {
"i386" : "x86",
"i486" : "x86",
"i586" : "x86",
"i686" : "x86",
"x86_64": "x86_64",
"ia64" : "ia64",
}
# Lookup current platform.
_arch = _uname_to_arch_map.get(os.uname()[4], "Unknown")
if _arch == "x86" or _arch == "x86_64" or _arch == "ia64":
minSafeMem = ia_minSafeMem
getDefaultKernel = ia_getDefaultKernel
checkBuffer = ia_checkBuffer
if config.ENABLE_HVM_SUPPORT:
configDefaults = ia_HVMDefaults
else:
configDefaults = ia_ParavirtDefaults
# note: xm-test generates an uncompressed image, and this code
# expects one. This will fail with a gzip-ed image.
if configDefaults['ramdisk']:
rd_size = os.stat(configDefaults['ramdisk']).st_size
clause = 'ramdisk_size=' + str((rd_size / 1024)+1)
if configDefaults.has_key('extra'):
configDefaults['extra'] = configDefaults['extra'] + " " + clause
else:
configDefaults['extra'] = clause
if _arch == "ia64":
minSafeMem = ia64_minSafeMem
configDefaults['memory'] = ia64_minSafeMem()
else:
raise ValueError, "Unknown architecture!"
|