1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: vboxtestvms.py 70695 2018-01-22 23:17:53Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | VirtualBox Test VMs
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2010-2017 Oracle Corporation
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | """
|
---|
29 | __version__ = "$Revision: 70695 $"
|
---|
30 |
|
---|
31 | # Standard Python imports.
|
---|
32 | import copy;
|
---|
33 | import os;
|
---|
34 | import re;
|
---|
35 | import random;
|
---|
36 | import socket;
|
---|
37 |
|
---|
38 | # Validation Kit imports.
|
---|
39 | from testdriver import base;
|
---|
40 | from testdriver import reporter;
|
---|
41 | from testdriver import vboxcon;
|
---|
42 |
|
---|
43 |
|
---|
44 | # All virtualization modes.
|
---|
45 | g_asVirtModes = ['hwvirt', 'hwvirt-np', 'raw',];
|
---|
46 | # All virtualization modes except for raw-mode.
|
---|
47 | g_asVirtModesNoRaw = ['hwvirt', 'hwvirt-np',];
|
---|
48 | # Dictionary mapping the virtualization mode mnemonics to a little less cryptic
|
---|
49 | # strings used in test descriptions.
|
---|
50 | g_dsVirtModeDescs = {
|
---|
51 | 'raw' : 'Raw-mode',
|
---|
52 | 'hwvirt' : 'HwVirt',
|
---|
53 | 'hwvirt-np' : 'NestedPaging'
|
---|
54 | };
|
---|
55 |
|
---|
56 | ## @name Flags.
|
---|
57 | ## @{
|
---|
58 | g_k32 = 32; # pylint: disable=C0103
|
---|
59 | g_k64 = 64; # pylint: disable=C0103
|
---|
60 | g_k32_64 = 96; # pylint: disable=C0103
|
---|
61 | g_kiArchMask = 96;
|
---|
62 | g_kiNoRaw = 128; ##< No raw mode.
|
---|
63 | ## @}
|
---|
64 |
|
---|
65 | # Array indexes.
|
---|
66 | g_iGuestOsType = 0;
|
---|
67 | g_iKind = 1;
|
---|
68 | g_iFlags = 2;
|
---|
69 | g_iMinCpu = 3;
|
---|
70 | g_iMaxCpu = 4;
|
---|
71 | g_iRegEx = 5;
|
---|
72 |
|
---|
73 | # Table translating from VM name core to a more detailed guest info.
|
---|
74 | # pylint: disable=C0301
|
---|
75 | g_aaNameToDetails = \
|
---|
76 | [
|
---|
77 | [ 'WindowsNT3x', 'WindowsNT3x', g_k32, 1, 32, ['nt3', 'nt3[0-9]*']], # max cpus??
|
---|
78 | [ 'WindowsNT4', 'WindowsNT4', g_k32, 1, 32, ['nt4', 'nt4sp[0-9]']], # max cpus??
|
---|
79 | [ 'Windows2000', 'Windows2000', g_k32, 1, 32, ['w2k', 'w2ksp[0-9]', 'win2k', 'win2ksp[0-9]']], # max cpus??
|
---|
80 | [ 'WindowsXP', 'WindowsXP', g_k32, 1, 32, ['xp', 'xpsp[0-9]']],
|
---|
81 | [ 'WindowsXP_64', 'WindowsXP_64', g_k64, 1, 32, ['xp64', 'xp64sp[0-9]']],
|
---|
82 | [ 'Windows2003', 'Windows2003', g_k32, 1, 32, ['w2k3', 'w2k3sp[0-9]', 'win2k3', 'win2k3sp[0-9]']],
|
---|
83 | [ 'WindowsVista', 'WindowsVista', g_k32, 1, 32, ['vista', 'vistasp[0-9]']],
|
---|
84 | [ 'WindowsVista_64','WindowsVista_64', g_k64, 1, 64, ['vista-64', 'vistasp[0-9]-64',]], # max cpus/cores??
|
---|
85 | [ 'Windows2008', 'Windows2008', g_k32, 1, 64, ['w2k8', 'w2k8sp[0-9]', 'win2k8', 'win2k8sp[0-9]']], # max cpus/cores??
|
---|
86 | [ 'Windows2008_64', 'Windows2008_64', g_k64, 1, 64, ['w2k8r2', 'w2k8r2sp[0-9]', 'win2k8r2', 'win2k8r2sp[0-9]']], # max cpus/cores??
|
---|
87 | [ 'Windows7', 'Windows7', g_k32, 1, 32, ['w7', 'w7sp[0-9]', 'win7',]], # max cpus/cores??
|
---|
88 | [ 'Windows7_64', 'Windows7_64', g_k64, 1, 64, ['w7-64', 'w7sp[0-9]-64', 'win7-64',]], # max cpus/cores??
|
---|
89 | [ 'Windows8', 'Windows8', g_k32 | g_kiNoRaw, 1, 32, ['w8', 'w8sp[0-9]', 'win8',]], # max cpus/cores??
|
---|
90 | [ 'Windows8_64', 'Windows8_64', g_k64, 1, 64, ['w8-64', 'w8sp[0-9]-64', 'win8-64',]], # max cpus/cores??
|
---|
91 | [ 'Windows81', 'Windows81', g_k32 | g_kiNoRaw, 1, 32, ['w81', 'w81sp[0-9]', 'win81',]], # max cpus/cores??
|
---|
92 | [ 'Windows81_64', 'Windows81_64', g_k64, 1, 64, ['w81-64', 'w81sp[0-9]-64', 'win81-64',]], # max cpus/cores??
|
---|
93 | [ 'Windows10', 'Windows10', g_k32 | g_kiNoRaw, 1, 32, ['w10', 'w10sp[0-9]', 'win10',]], # max cpus/cores??
|
---|
94 | [ 'Windows10_64', 'Windows10_64', g_k64, 1, 64, ['w10-64', 'w10sp[0-9]-64', 'win10-64',]], # max cpus/cores??
|
---|
95 | [ 'Linux', 'Debian', g_k32, 1, 256, ['deb[0-9]*', 'debian[0-9]*', ]],
|
---|
96 | [ 'Linux_64', 'Debian_64', g_k64, 1, 256, ['deb[0-9]*-64', 'debian[0-9]*-64', ]],
|
---|
97 | [ 'Linux', 'RedHat', g_k32, 1, 256, ['rhel', 'rhel[0-9]', 'rhel[0-9]u[0-9]']],
|
---|
98 | [ 'Linux', 'Fedora', g_k32, 1, 256, ['fedora', 'fedora[0-9]*', ]],
|
---|
99 | [ 'Linux_64', 'Fedora_64', g_k64, 1, 256, ['fedora-64', 'fedora[0-9]*-64', ]],
|
---|
100 | [ 'Linux', 'Oracle', g_k32, 1, 256, ['ols[0-9]*', 'oel[0-9]*', ]],
|
---|
101 | [ 'Linux_64', 'Oracle_64', g_k64, 1, 256, ['ols[0-9]*-64', 'oel[0-9]*-64', ]],
|
---|
102 | [ 'Linux', 'OpenSUSE', g_k32, 1, 256, ['opensuse[0-9]*', 'suse[0-9]*', ]],
|
---|
103 | [ 'Linux_64', 'OpenSUSE_64', g_k64, 1, 256, ['opensuse[0-9]*-64', 'suse[0-9]*-64', ]],
|
---|
104 | [ 'Linux', 'Ubuntu', g_k32, 1, 256, ['ubuntu[0-9]*', ]],
|
---|
105 | [ 'Linux_64', 'Ubuntu_64', g_k64, 1, 256, ['ubuntu[0-9]*-64', ]],
|
---|
106 | [ 'Solaris', 'Solaris', g_k32, 1, 256, ['sol10', 'sol10u[0-9]']],
|
---|
107 | [ 'Solaris_64', 'Solaris_64', g_k64, 1, 256, ['sol10-64', 'sol10u-64[0-9]']],
|
---|
108 | [ 'Solaris_64', 'Solaris11_64', g_k64, 1, 256, ['sol11u1']],
|
---|
109 | [ 'BSD', 'FreeBSD_64', g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
|
---|
110 | ];
|
---|
111 |
|
---|
112 |
|
---|
113 | ## @name Guest OS type string constants.
|
---|
114 | ## @{
|
---|
115 | g_ksGuestOsTypeDarwin = 'darwin';
|
---|
116 | g_ksGuestOsTypeFreeBSD = 'freebsd';
|
---|
117 | g_ksGuestOsTypeLinux = 'linux';
|
---|
118 | g_ksGuestOsTypeOS2 = 'os2';
|
---|
119 | g_ksGuestOsTypeSolaris = 'solaris';
|
---|
120 | g_ksGuestOsTypeWindows = 'windows';
|
---|
121 | ## @}
|
---|
122 |
|
---|
123 | ## @name String constants for paravirtualization providers.
|
---|
124 | ## @{
|
---|
125 | g_ksParavirtProviderNone = 'none';
|
---|
126 | g_ksParavirtProviderDefault = 'default';
|
---|
127 | g_ksParavirtProviderLegacy = 'legacy';
|
---|
128 | g_ksParavirtProviderMinimal = 'minimal';
|
---|
129 | g_ksParavirtProviderHyperV = 'hyperv';
|
---|
130 | g_ksParavirtProviderKVM = 'kvm';
|
---|
131 | ## @}
|
---|
132 |
|
---|
133 | ## Valid paravirtualization providers.
|
---|
134 | g_kasParavirtProviders = ( g_ksParavirtProviderNone, g_ksParavirtProviderDefault, g_ksParavirtProviderLegacy,
|
---|
135 | g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM );
|
---|
136 |
|
---|
137 | # Mapping for support of paravirtualisation providers per guest OS.
|
---|
138 | #g_kdaParavirtProvidersSupported = {
|
---|
139 | # g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
|
---|
140 | # g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
|
---|
141 | # g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
|
---|
142 | # g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
|
---|
143 | # g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
|
---|
144 | # g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, )
|
---|
145 | #}
|
---|
146 | # Temporary tweak:
|
---|
147 | # since for the most guests g_ksParavirtProviderNone is almost the same as g_ksParavirtProviderMinimal,
|
---|
148 | # g_ksParavirtProviderMinimal is removed from the list in order to get maximum number of unique choices
|
---|
149 | # during independent test runs when paravirt provider is taken randomly.
|
---|
150 | g_kdaParavirtProvidersSupported = {
|
---|
151 | g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
|
---|
152 | g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, ),
|
---|
153 | g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
|
---|
154 | g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
|
---|
155 | g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
|
---|
156 | g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, )
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | # pylint: enable=C0301
|
---|
161 |
|
---|
162 | def _intersects(asSet1, asSet2):
|
---|
163 | """
|
---|
164 | Checks if any of the strings in set 1 matches any of the regular
|
---|
165 | expressions in set 2.
|
---|
166 | """
|
---|
167 | for sStr1 in asSet1:
|
---|
168 | for sRx2 in asSet2:
|
---|
169 | if re.match(sStr1, sRx2 + '$'):
|
---|
170 | return True;
|
---|
171 | return False;
|
---|
172 |
|
---|
173 |
|
---|
174 | class TestVm(object):
|
---|
175 | """
|
---|
176 | A Test VM - name + VDI/whatever.
|
---|
177 |
|
---|
178 | This is just a data object.
|
---|
179 | """
|
---|
180 |
|
---|
181 | def __init__(self, # pylint: disable=R0913
|
---|
182 | sVmName, # type: str
|
---|
183 | fGrouping = 0, # type: int
|
---|
184 | oSet = None, # type: TestVmSet
|
---|
185 | sHd = None, # type: str
|
---|
186 | sKind = None, # type: str
|
---|
187 | acCpusSup = None, # type: List[int]
|
---|
188 | asVirtModesSup = None, # type: List[str]
|
---|
189 | fIoApic = None, # type: bool
|
---|
190 | fPae = None, # type: bool
|
---|
191 | sNic0AttachType = None, # type: str
|
---|
192 | sFloppy = None, # type: str
|
---|
193 | fVmmDevTestingPart = None, # type: bool
|
---|
194 | fVmmDevTestingMmio = False, # type: bool
|
---|
195 | asParavirtModesSup = None, # type: List[str]
|
---|
196 | fRandomPvPMode = False, # type: bool
|
---|
197 | sFirmwareType = 'bios', # type: str
|
---|
198 | sChipsetType = 'piix3', # type: str
|
---|
199 | sHddControllerType = 'IDE Controller', # type: str
|
---|
200 | sDvdControllerType = 'IDE Controller' # type: str
|
---|
201 | ):
|
---|
202 | self.oSet = oSet;
|
---|
203 | self.sVmName = sVmName;
|
---|
204 | self.fGrouping = fGrouping;
|
---|
205 | self.sHd = sHd; # Relative to the testrsrc root.
|
---|
206 | self.acCpusSup = acCpusSup;
|
---|
207 | self.asVirtModesSup = asVirtModesSup;
|
---|
208 | self.asParavirtModesSup = asParavirtModesSup;
|
---|
209 | self.asParavirtModesSupOrg = asParavirtModesSup; # HACK ALERT! Trick to make the 'effing random mess not get in the
|
---|
210 | # way of actively selecting virtualization modes.
|
---|
211 | self.sKind = sKind;
|
---|
212 | self.sGuestOsType = None;
|
---|
213 | self.sDvdImage = None; # Relative to the testrsrc root.
|
---|
214 | self.sDvdControllerType = sDvdControllerType;
|
---|
215 | self.fIoApic = fIoApic;
|
---|
216 | self.fPae = fPae;
|
---|
217 | self.sNic0AttachType = sNic0AttachType;
|
---|
218 | self.sHddControllerType = sHddControllerType;
|
---|
219 | self.sFloppy = sFloppy; # Relative to the testrsrc root, except when it isn't...
|
---|
220 | self.fVmmDevTestingPart = fVmmDevTestingPart;
|
---|
221 | self.fVmmDevTestingMmio = fVmmDevTestingMmio;
|
---|
222 | self.sFirmwareType = sFirmwareType;
|
---|
223 | self.sChipsetType = sChipsetType;
|
---|
224 |
|
---|
225 | self.fSnapshotRestoreCurrent = False; # Whether to restore execution on the current snapshot.
|
---|
226 | self.fSkip = False; # All VMs are included in the configured set by default.
|
---|
227 | self.aInfo = None;
|
---|
228 | self._guessStuff(fRandomPvPMode);
|
---|
229 |
|
---|
230 | def _mkCanonicalGuestOSType(self, sType):
|
---|
231 | """
|
---|
232 | Convert guest OS type into constant representation.
|
---|
233 | Raise exception if specified @param sType is unknown.
|
---|
234 | """
|
---|
235 | if sType.lower().startswith('darwin'):
|
---|
236 | return g_ksGuestOsTypeDarwin
|
---|
237 | if sType.lower().startswith('bsd'):
|
---|
238 | return g_ksGuestOsTypeFreeBSD
|
---|
239 | if sType.lower().startswith('linux'):
|
---|
240 | return g_ksGuestOsTypeLinux
|
---|
241 | if sType.lower().startswith('os2'):
|
---|
242 | return g_ksGuestOsTypeOS2
|
---|
243 | if sType.lower().startswith('solaris'):
|
---|
244 | return g_ksGuestOsTypeSolaris
|
---|
245 | if sType.lower().startswith('windows'):
|
---|
246 | return g_ksGuestOsTypeWindows
|
---|
247 | raise base.GenError(sWhat="unknown guest OS kind: %s" % str(sType))
|
---|
248 |
|
---|
249 | def _guessStuff(self, fRandomPvPMode):
|
---|
250 | """
|
---|
251 | Used by the constructor to guess stuff.
|
---|
252 | """
|
---|
253 |
|
---|
254 | sNm = self.sVmName.lower().strip();
|
---|
255 | asSplit = sNm.replace('-', ' ').split(' ');
|
---|
256 |
|
---|
257 | if self.sKind is None:
|
---|
258 | # From name.
|
---|
259 | for aInfo in g_aaNameToDetails:
|
---|
260 | if _intersects(asSplit, aInfo[g_iRegEx]):
|
---|
261 | self.aInfo = aInfo;
|
---|
262 | self.sGuestOsType = self._mkCanonicalGuestOSType(aInfo[g_iGuestOsType])
|
---|
263 | self.sKind = aInfo[g_iKind];
|
---|
264 | break;
|
---|
265 | if self.sKind is None:
|
---|
266 | reporter.fatal('The OS of test VM "%s" cannot be guessed' % (self.sVmName,));
|
---|
267 |
|
---|
268 | # Check for 64-bit, if required and supported.
|
---|
269 | if (self.aInfo[g_iFlags] & g_kiArchMask) == g_k32_64 and _intersects(asSplit, ['64', 'amd64']):
|
---|
270 | self.sKind = self.sKind + '_64';
|
---|
271 | else:
|
---|
272 | # Lookup the kind.
|
---|
273 | for aInfo in g_aaNameToDetails:
|
---|
274 | if self.sKind == aInfo[g_iKind]:
|
---|
275 | self.aInfo = aInfo;
|
---|
276 | break;
|
---|
277 | if self.aInfo is None:
|
---|
278 | reporter.fatal('The OS of test VM "%s" with sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
|
---|
279 |
|
---|
280 | # Translate sKind into sGuest OS Type.
|
---|
281 | if self.sGuestOsType is None:
|
---|
282 | if self.aInfo is not None:
|
---|
283 | self.sGuestOsType = self._mkCanonicalGuestOSType(self.aInfo[g_iGuestOsType])
|
---|
284 | elif self.sKind.find("Windows") >= 0:
|
---|
285 | self.sGuestOsType = g_ksGuestOsTypeWindows
|
---|
286 | elif self.sKind.find("Linux") >= 0:
|
---|
287 | self.sGuestOsType = g_ksGuestOsTypeLinux;
|
---|
288 | elif self.sKind.find("Solaris") >= 0:
|
---|
289 | self.sGuestOsType = g_ksGuestOsTypeSolaris;
|
---|
290 | else:
|
---|
291 | reporter.fatal('The OS of test VM "%s", sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
|
---|
292 |
|
---|
293 | # Restrict modes and such depending on the OS.
|
---|
294 | if self.asVirtModesSup is None:
|
---|
295 | self.asVirtModesSup = list(g_asVirtModes);
|
---|
296 | if self.sGuestOsType in (g_ksGuestOsTypeOS2, g_ksGuestOsTypeDarwin) \
|
---|
297 | or self.sKind.find('_64') > 0 \
|
---|
298 | or (self.aInfo is not None and (self.aInfo[g_iFlags] & g_kiNoRaw)):
|
---|
299 | self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
|
---|
300 | # TEMPORARY HACK - START
|
---|
301 | sHostName = socket.getfqdn();
|
---|
302 | if sHostName.startswith('testboxpile1'):
|
---|
303 | self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
|
---|
304 | # TEMPORARY HACK - END
|
---|
305 |
|
---|
306 | # Restrict the CPU count depending on the OS and/or percieved SMP readiness.
|
---|
307 | if self.acCpusSup is None:
|
---|
308 | if _intersects(asSplit, ['uni']):
|
---|
309 | self.acCpusSup = [1];
|
---|
310 | elif self.aInfo is not None:
|
---|
311 | self.acCpusSup = [i for i in range(self.aInfo[g_iMinCpu], self.aInfo[g_iMaxCpu]) ];
|
---|
312 | else:
|
---|
313 | self.acCpusSup = [1];
|
---|
314 |
|
---|
315 | # Figure relevant PV modes based on the OS.
|
---|
316 | if self.asParavirtModesSup is None:
|
---|
317 | self.asParavirtModesSup = g_kdaParavirtProvidersSupported[self.sGuestOsType];
|
---|
318 | ## @todo Remove this hack as soon as we've got around to explictly configure test variations
|
---|
319 | ## on the server side. Client side random is interesting but not the best option.
|
---|
320 | self.asParavirtModesSupOrg = self.asParavirtModesSup;
|
---|
321 | if fRandomPvPMode:
|
---|
322 | random.seed();
|
---|
323 | self.asParavirtModesSup = (random.choice(self.asParavirtModesSup),);
|
---|
324 |
|
---|
325 | return True;
|
---|
326 |
|
---|
327 | def getMissingResources(self, sTestRsrc):
|
---|
328 | """
|
---|
329 | Returns a list of missing resources (paths, stuff) that the VM needs.
|
---|
330 | """
|
---|
331 | asRet = [];
|
---|
332 | for sPath in [ self.sHd, self.sDvdImage, self.sFloppy]:
|
---|
333 | if sPath is not None:
|
---|
334 | if not os.path.isabs(sPath):
|
---|
335 | sPath = os.path.join(sTestRsrc, sPath);
|
---|
336 | if not os.path.exists(sPath):
|
---|
337 | asRet.append(sPath);
|
---|
338 | return asRet;
|
---|
339 |
|
---|
340 | def createVm(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
|
---|
341 | """
|
---|
342 | Creates the VM with defaults and the few tweaks as per the arguments.
|
---|
343 |
|
---|
344 | Returns same as vbox.TestDriver.createTestVM.
|
---|
345 | """
|
---|
346 | if sDvdImage is not None:
|
---|
347 | sMyDvdImage = sDvdImage;
|
---|
348 | else:
|
---|
349 | sMyDvdImage = self.sDvdImage;
|
---|
350 |
|
---|
351 | if eNic0AttachType is not None:
|
---|
352 | eMyNic0AttachType = eNic0AttachType;
|
---|
353 | elif self.sNic0AttachType is None:
|
---|
354 | eMyNic0AttachType = None;
|
---|
355 | elif self.sNic0AttachType == 'nat':
|
---|
356 | eMyNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
|
---|
357 | elif self.sNic0AttachType == 'bridged':
|
---|
358 | eMyNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
|
---|
359 | else:
|
---|
360 | assert False, self.sNic0AttachType;
|
---|
361 |
|
---|
362 | return self.createVmInner(oTestDrv, eMyNic0AttachType, sMyDvdImage);
|
---|
363 |
|
---|
364 | def createVmInner(self, oTestDrv, eNic0AttachType, sDvdImage):
|
---|
365 | """
|
---|
366 | Same as createVm but parameters resolved.
|
---|
367 |
|
---|
368 | Returns same as vbox.TestDriver.createTestVM.
|
---|
369 | """
|
---|
370 | reporter.log2('');
|
---|
371 | reporter.log2('Calling createTestVM on %s...' % (self.sVmName,))
|
---|
372 | return oTestDrv.createTestVM(self.sVmName,
|
---|
373 | 1, # iGroup
|
---|
374 | sHd = self.sHd,
|
---|
375 | sKind = self.sKind,
|
---|
376 | fIoApic = self.fIoApic,
|
---|
377 | fPae = self.fPae,
|
---|
378 | eNic0AttachType = eNic0AttachType,
|
---|
379 | sDvdImage = sDvdImage,
|
---|
380 | sDvdControllerType = self.sDvdControllerType,
|
---|
381 | sHddControllerType = self.sHddControllerType,
|
---|
382 | sFloppy = self.sFloppy,
|
---|
383 | fVmmDevTestingPart = self.fVmmDevTestingPart,
|
---|
384 | fVmmDevTestingMmio = self.fVmmDevTestingPart,
|
---|
385 | sFirmwareType = self.sFirmwareType,
|
---|
386 | sChipsetType = self.sChipsetType);
|
---|
387 |
|
---|
388 | def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
|
---|
389 | """
|
---|
390 | actionExecute worker that finds and reconfigure a test VM.
|
---|
391 |
|
---|
392 | Returns (fRc, oVM) where fRc is True, None or False and oVM is a
|
---|
393 | VBox VM object that is only present when rc is True.
|
---|
394 | """
|
---|
395 |
|
---|
396 | fRc = False;
|
---|
397 | oVM = oTestDrv.getVmByName(self.sVmName);
|
---|
398 | if oVM is not None:
|
---|
399 | if self.fSnapshotRestoreCurrent is True:
|
---|
400 | fRc = True;
|
---|
401 | else:
|
---|
402 | fHostSupports64bit = oTestDrv.hasHostLongMode();
|
---|
403 | if self.is64bitRequired() and not fHostSupports64bit:
|
---|
404 | fRc = None; # Skip the test.
|
---|
405 | elif self.isViaIncompatible() and oTestDrv.isHostCpuVia():
|
---|
406 | fRc = None; # Skip the test.
|
---|
407 | elif self.isP4Incompatible() and oTestDrv.isHostCpuP4():
|
---|
408 | fRc = None; # Skip the test.
|
---|
409 | else:
|
---|
410 | oSession = oTestDrv.openSession(oVM);
|
---|
411 | if oSession is not None:
|
---|
412 | fRc = oSession.enableVirtEx(sVirtMode != 'raw');
|
---|
413 | fRc = fRc and oSession.enableNestedPaging(sVirtMode == 'hwvirt-np');
|
---|
414 | fRc = fRc and oSession.setCpuCount(cCpus);
|
---|
415 | if cCpus > 1:
|
---|
416 | fRc = fRc and oSession.enableIoApic(True);
|
---|
417 |
|
---|
418 | if sParavirtMode is not None and oSession.fpApiVer >= 5.0:
|
---|
419 | adParavirtProviders = {
|
---|
420 | g_ksParavirtProviderNone : vboxcon.ParavirtProvider_None,
|
---|
421 | g_ksParavirtProviderDefault: vboxcon.ParavirtProvider_Default,
|
---|
422 | g_ksParavirtProviderLegacy : vboxcon.ParavirtProvider_Legacy,
|
---|
423 | g_ksParavirtProviderMinimal: vboxcon.ParavirtProvider_Minimal,
|
---|
424 | g_ksParavirtProviderHyperV : vboxcon.ParavirtProvider_HyperV,
|
---|
425 | g_ksParavirtProviderKVM : vboxcon.ParavirtProvider_KVM,
|
---|
426 | };
|
---|
427 | fRc = fRc and oSession.setParavirtProvider(adParavirtProviders[sParavirtMode]);
|
---|
428 |
|
---|
429 | fCfg64Bit = self.is64bitRequired() or (self.is64bit() and fHostSupports64bit and sVirtMode != 'raw');
|
---|
430 | fRc = fRc and oSession.enableLongMode(fCfg64Bit);
|
---|
431 | if fCfg64Bit: # This is to avoid GUI pedantic warnings in the GUI. Sigh.
|
---|
432 | oOsType = oSession.getOsType();
|
---|
433 | if oOsType is not None:
|
---|
434 | if oOsType.is64Bit and sVirtMode == 'raw':
|
---|
435 | assert(oOsType.id[-3:] == '_64');
|
---|
436 | fRc = fRc and oSession.setOsType(oOsType.id[:-3]);
|
---|
437 | elif not oOsType.is64Bit and sVirtMode != 'raw':
|
---|
438 | fRc = fRc and oSession.setOsType(oOsType.id + '_64');
|
---|
439 |
|
---|
440 | fRc = fRc and oSession.saveSettings();
|
---|
441 | if not oSession.close():
|
---|
442 | fRc = False;
|
---|
443 | if fRc is True:
|
---|
444 | return (True, oVM);
|
---|
445 | return (fRc, None);
|
---|
446 |
|
---|
447 |
|
---|
448 | def isWindows(self):
|
---|
449 | """ Checks if it's a Windows VM. """
|
---|
450 | return self.sGuestOsType == g_ksGuestOsTypeWindows;
|
---|
451 |
|
---|
452 | def isOS2(self):
|
---|
453 | """ Checks if it's an OS/2 VM. """
|
---|
454 | return self.sGuestOsType == g_ksGuestOsTypeOS2;
|
---|
455 |
|
---|
456 | def is64bit(self):
|
---|
457 | """ Checks if it's a 64-bit VM. """
|
---|
458 | return self.sKind.find('_64') >= 0;
|
---|
459 |
|
---|
460 | def is64bitRequired(self):
|
---|
461 | """ Check if 64-bit is required or not. """
|
---|
462 | return (self.aInfo[g_iFlags] & g_k64) != 0;
|
---|
463 |
|
---|
464 | def isLoggedOntoDesktop(self):
|
---|
465 | """ Checks if the test VM is logging onto a graphical desktop by default. """
|
---|
466 | if self.isWindows():
|
---|
467 | return True;
|
---|
468 | if self.isOS2():
|
---|
469 | return True;
|
---|
470 | if self.sVmName.find('-desktop'):
|
---|
471 | return True;
|
---|
472 | return False;
|
---|
473 |
|
---|
474 | def isViaIncompatible(self):
|
---|
475 | """
|
---|
476 | Identifies VMs that doesn't work on VIA.
|
---|
477 |
|
---|
478 | Returns True if NOT supported on VIA, False if it IS supported.
|
---|
479 | """
|
---|
480 | # Oracle linux doesn't like VIA in our experience
|
---|
481 | if self.aInfo[g_iKind] in ['Oracle', 'Oracle_64']:
|
---|
482 | return True;
|
---|
483 | # OS/2: "The system detected an internal processing error at location
|
---|
484 | # 0168:fff1da1f - 000e:ca1f. 0a8606fd
|
---|
485 | if self.isOS2():
|
---|
486 | return True;
|
---|
487 | # Windows NT4 before SP4 won't work because of cmpxchg8b not being
|
---|
488 | # detected, leading to a STOP 3e(80,0,0,0).
|
---|
489 | if self.aInfo[g_iKind] == 'WindowsNT4':
|
---|
490 | if self.sVmName.find('sp') < 0:
|
---|
491 | return True; # no service pack.
|
---|
492 | if self.sVmName.find('sp0') >= 0 \
|
---|
493 | or self.sVmName.find('sp1') >= 0 \
|
---|
494 | or self.sVmName.find('sp2') >= 0 \
|
---|
495 | or self.sVmName.find('sp3') >= 0:
|
---|
496 | return True;
|
---|
497 | # XP x64 on a physical VIA box hangs exactly like a VM.
|
---|
498 | if self.aInfo[g_iKind] in ['WindowsXP_64', 'Windows2003_64']:
|
---|
499 | return True;
|
---|
500 | # Vista 64 throws BSOD 0x5D (UNSUPPORTED_PROCESSOR)
|
---|
501 | if self.aInfo[g_iKind] in ['WindowsVista_64']:
|
---|
502 | return True;
|
---|
503 | # Solaris 11 hangs on VIA, tested on a physical box (testboxvqc)
|
---|
504 | if self.aInfo[g_iKind] in ['Solaris11_64']:
|
---|
505 | return True;
|
---|
506 | return False;
|
---|
507 |
|
---|
508 | def isP4Incompatible(self):
|
---|
509 | """
|
---|
510 | Identifies VMs that doesn't work on Pentium 4 / Pentium D.
|
---|
511 |
|
---|
512 | Returns True if NOT supported on P4, False if it IS supported.
|
---|
513 | """
|
---|
514 | # Stupid 1 kHz timer. Too much for antique CPUs.
|
---|
515 | if self.sVmName.find('rhel5') >= 0:
|
---|
516 | return True;
|
---|
517 | # Due to the boot animation the VM takes forever to boot.
|
---|
518 | if self.aInfo[g_iKind] == 'Windows2000':
|
---|
519 | return True;
|
---|
520 | return False;
|
---|
521 |
|
---|
522 |
|
---|
523 | class BootSectorTestVm(TestVm):
|
---|
524 | """
|
---|
525 | A Boot Sector Test VM.
|
---|
526 | """
|
---|
527 |
|
---|
528 | def __init__(self, oSet, sVmName, sFloppy = None, asVirtModesSup = None, f64BitRequired = False):
|
---|
529 | self.f64BitRequired = f64BitRequired;
|
---|
530 | if asVirtModesSup is None:
|
---|
531 | asVirtModesSup = list(g_asVirtModes);
|
---|
532 | TestVm.__init__(self, sVmName,
|
---|
533 | oSet = oSet,
|
---|
534 | acCpusSup = [1,],
|
---|
535 | sFloppy = sFloppy,
|
---|
536 | asVirtModesSup = asVirtModesSup,
|
---|
537 | fPae = True,
|
---|
538 | fIoApic = True,
|
---|
539 | fVmmDevTestingPart = True,
|
---|
540 | fVmmDevTestingMmio = True,
|
---|
541 | );
|
---|
542 |
|
---|
543 | def is64bitRequired(self):
|
---|
544 | return self.f64BitRequired;
|
---|
545 |
|
---|
546 |
|
---|
547 |
|
---|
548 | #class AncientTestVm(object):
|
---|
549 | # """
|
---|
550 | # A ancient Test VM, using the serial port for communicating results.
|
---|
551 | #
|
---|
552 | # We're looking for 'PASSED' and 'FAILED' lines in the COM1 output.
|
---|
553 | # """
|
---|
554 | #
|
---|
555 | # def __init__(self, oSet, sVmName, fGrouping = , sHd = None, sKind = None, acCpusSup = None, asVirtModesSup = None, # pylint: disable=R0913
|
---|
556 | # fIoApic = None, fPae = None, sNic0AttachType = None, sFloppy = None, sFirmwareType = 'bios',
|
---|
557 | # sChipsetType = 'piix3', sHddControllerType = 'IDE Controller', sDvdControllerType = 'IDE Controller'):
|
---|
558 | # TestVm.__init__(self, oSet, sVmName,
|
---|
559 | #
|
---|
560 |
|
---|
561 |
|
---|
562 | class TestVmSet(object):
|
---|
563 | """
|
---|
564 | A set of Test VMs.
|
---|
565 | """
|
---|
566 |
|
---|
567 | def __init__(self, oTestVmManager = None, acCpus = None, asVirtModes = None, fIgnoreSkippedVm = False):
|
---|
568 | self.oTestVmManager = oTestVmManager;
|
---|
569 | if acCpus is None:
|
---|
570 | acCpus = [1, 2];
|
---|
571 | self.acCpusDef = acCpus;
|
---|
572 | self.acCpus = acCpus;
|
---|
573 | if asVirtModes is None:
|
---|
574 | asVirtModes = list(g_asVirtModes);
|
---|
575 | self.asVirtModesDef = asVirtModes;
|
---|
576 | self.asVirtModes = asVirtModes;
|
---|
577 | self.aoTestVms = [];
|
---|
578 | self.fIgnoreSkippedVm = fIgnoreSkippedVm;
|
---|
579 | self.asParavirtModes = None; ##< If None, use the first PV mode of the test VM, otherwise all modes in this list.
|
---|
580 |
|
---|
581 | def findTestVmByName(self, sVmName):
|
---|
582 | """
|
---|
583 | Returns the TestVm object with the given name.
|
---|
584 | Returns None if not found.
|
---|
585 | """
|
---|
586 |
|
---|
587 | # The 'tst-' prefix is optional.
|
---|
588 | sAltName = sVmName if sVmName.startswith('tst-') else 'tst-' + sVmName;
|
---|
589 |
|
---|
590 | for oTestVm in self.aoTestVms:
|
---|
591 | if oTestVm.sVmName == sVmName or oTestVm.sVmName == sAltName:
|
---|
592 | return oTestVm;
|
---|
593 | return None;
|
---|
594 |
|
---|
595 | def getAllVmNames(self, sSep = ':'):
|
---|
596 | """
|
---|
597 | Returns names of all the test VMs in the set separated by
|
---|
598 | sSep (defaults to ':').
|
---|
599 | """
|
---|
600 | sVmNames = '';
|
---|
601 | for oTestVm in self.aoTestVms:
|
---|
602 | sName = oTestVm.sVmName;
|
---|
603 | if sName.startswith('tst-'):
|
---|
604 | sName = sName[4:];
|
---|
605 | if sVmNames == '':
|
---|
606 | sVmNames = sName;
|
---|
607 | else:
|
---|
608 | sVmNames = sVmNames + sSep + sName;
|
---|
609 | return sVmNames;
|
---|
610 |
|
---|
611 | def showUsage(self):
|
---|
612 | """
|
---|
613 | Invoked by vbox.TestDriver.
|
---|
614 | """
|
---|
615 | reporter.log('');
|
---|
616 | reporter.log('Test VM selection and general config options:');
|
---|
617 | reporter.log(' --virt-modes <m1[:m2[:...]]>');
|
---|
618 | reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
|
---|
619 | reporter.log(' --skip-virt-modes <m1[:m2[:...]]>');
|
---|
620 | reporter.log(' Use this to avoid hwvirt or hwvirt-np when not supported by the host');
|
---|
621 | reporter.log(' since we cannot detect it using the main API. Use after --virt-modes.');
|
---|
622 | reporter.log(' --cpu-counts <c1[:c2[:...]]>');
|
---|
623 | reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
|
---|
624 | reporter.log(' --test-vms <vm1[:vm2[:...]]>');
|
---|
625 | reporter.log(' Test the specified VMs in the given order. Use this to change');
|
---|
626 | reporter.log(' the execution order or limit the choice of VMs');
|
---|
627 | reporter.log(' Default: %s (all)' % (self.getAllVmNames(),));
|
---|
628 | reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
|
---|
629 | reporter.log(' Skip the specified VMs when testing.');
|
---|
630 | reporter.log(' --snapshot-restore-current');
|
---|
631 | reporter.log(' Restores the current snapshot and resumes execution.');
|
---|
632 | reporter.log(' --paravirt-modes <pv1[:pv2[:...]]>');
|
---|
633 | reporter.log(' Set of paravirtualized providers (modes) to tests. Intersected with what the test VM supports.');
|
---|
634 | reporter.log(' Default is the first PV mode the test VMs support, generally same as "legacy".');
|
---|
635 | ## @todo Add more options for controlling individual VMs.
|
---|
636 | return True;
|
---|
637 |
|
---|
638 | def parseOption(self, asArgs, iArg):
|
---|
639 | """
|
---|
640 | Parses the set test vm set options (--test-vms and --skip-vms), modifying the set
|
---|
641 | Invoked by the testdriver method with the same name.
|
---|
642 |
|
---|
643 | Keyword arguments:
|
---|
644 | asArgs -- The argument vector.
|
---|
645 | iArg -- The index of the current argument.
|
---|
646 |
|
---|
647 | Returns iArg if the option was not recognized and the caller should handle it.
|
---|
648 | Returns the index of the next argument when something is consumed.
|
---|
649 |
|
---|
650 | In the event of a syntax error, a InvalidOption or QuietInvalidOption
|
---|
651 | is thrown.
|
---|
652 | """
|
---|
653 |
|
---|
654 | if asArgs[iArg] == '--virt-modes':
|
---|
655 | iArg += 1;
|
---|
656 | if iArg >= len(asArgs):
|
---|
657 | raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
|
---|
658 |
|
---|
659 | self.asVirtModes = asArgs[iArg].split(':');
|
---|
660 | for s in self.asVirtModes:
|
---|
661 | if s not in self.asVirtModesDef:
|
---|
662 | raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
|
---|
663 | % (s, ' '.join(self.asVirtModesDef)));
|
---|
664 |
|
---|
665 | elif asArgs[iArg] == '--skip-virt-modes':
|
---|
666 | iArg += 1;
|
---|
667 | if iArg >= len(asArgs):
|
---|
668 | raise base.InvalidOption('The "--skip-virt-modes" takes a colon separated list of modes');
|
---|
669 |
|
---|
670 | for s in asArgs[iArg].split(':'):
|
---|
671 | if s not in self.asVirtModesDef:
|
---|
672 | raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
|
---|
673 | % (s, ' '.join(self.asVirtModesDef)));
|
---|
674 | if s in self.asVirtModes:
|
---|
675 | self.asVirtModes.remove(s);
|
---|
676 |
|
---|
677 | elif asArgs[iArg] == '--cpu-counts':
|
---|
678 | iArg += 1;
|
---|
679 | if iArg >= len(asArgs):
|
---|
680 | raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
|
---|
681 |
|
---|
682 | self.acCpus = [];
|
---|
683 | for s in asArgs[iArg].split(':'):
|
---|
684 | try: c = int(s);
|
---|
685 | except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
|
---|
686 | if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
|
---|
687 | self.acCpus.append(c);
|
---|
688 |
|
---|
689 | elif asArgs[iArg] == '--test-vms':
|
---|
690 | iArg += 1;
|
---|
691 | if iArg >= len(asArgs):
|
---|
692 | raise base.InvalidOption('The "--test-vms" takes colon separated list');
|
---|
693 |
|
---|
694 | for oTestVm in self.aoTestVms:
|
---|
695 | oTestVm.fSkip = True;
|
---|
696 |
|
---|
697 | asTestVMs = asArgs[iArg].split(':');
|
---|
698 | for s in asTestVMs:
|
---|
699 | oTestVm = self.findTestVmByName(s);
|
---|
700 | if oTestVm is None:
|
---|
701 | raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
|
---|
702 | % (s, self.getAllVmNames(' ')));
|
---|
703 | oTestVm.fSkip = False;
|
---|
704 |
|
---|
705 | elif asArgs[iArg] == '--skip-vms':
|
---|
706 | iArg += 1;
|
---|
707 | if iArg >= len(asArgs):
|
---|
708 | raise base.InvalidOption('The "--skip-vms" takes colon separated list');
|
---|
709 |
|
---|
710 | asTestVMs = asArgs[iArg].split(':');
|
---|
711 | for s in asTestVMs:
|
---|
712 | oTestVm = self.findTestVmByName(s);
|
---|
713 | if oTestVm is None:
|
---|
714 | reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s,));
|
---|
715 | else:
|
---|
716 | oTestVm.fSkip = True;
|
---|
717 |
|
---|
718 | elif asArgs[iArg] == '--snapshot-restore-current':
|
---|
719 | for oTestVm in self.aoTestVms:
|
---|
720 | if oTestVm.fSkip is False:
|
---|
721 | oTestVm.fSnapshotRestoreCurrent = True;
|
---|
722 | reporter.log('VM "%s" will be restored.' % (oTestVm.sVmName));
|
---|
723 |
|
---|
724 | elif asArgs[iArg] == '--paravirt-modes':
|
---|
725 | iArg += 1
|
---|
726 | if iArg >= len(asArgs):
|
---|
727 | raise base.InvalidOption('The "--paravirt-modes" takes a colon separated list of modes');
|
---|
728 |
|
---|
729 | self.asParavirtModes = asArgs[iArg].split(':')
|
---|
730 | for sPvMode in self.asParavirtModes:
|
---|
731 | if sPvMode not in g_kasParavirtProviders:
|
---|
732 | raise base.InvalidOption('The "--paravirt-modes" value "%s" is not valid; valid values are: %s'
|
---|
733 | % (sPvMode, ', '.join(g_kasParavirtProviders),));
|
---|
734 | if not self.asParavirtModes:
|
---|
735 | self.asParavirtModes = None;
|
---|
736 |
|
---|
737 | # HACK ALERT! Reset the random paravirt selection for members.
|
---|
738 | for oTestVm in self.aoTestVms:
|
---|
739 | oTestVm.asParavirtModesSup = oTestVm.asParavirtModesSupOrg;
|
---|
740 |
|
---|
741 | else:
|
---|
742 | return iArg;
|
---|
743 | return iArg + 1;
|
---|
744 |
|
---|
745 | def getResourceSet(self):
|
---|
746 | """
|
---|
747 | Implements base.TestDriver.getResourceSet
|
---|
748 | """
|
---|
749 | asResources = [];
|
---|
750 | for oTestVm in self.aoTestVms:
|
---|
751 | if not oTestVm.fSkip:
|
---|
752 | if oTestVm.sHd is not None:
|
---|
753 | asResources.append(oTestVm.sHd);
|
---|
754 | if oTestVm.sDvdImage is not None:
|
---|
755 | asResources.append(oTestVm.sDvdImage);
|
---|
756 | return asResources;
|
---|
757 |
|
---|
758 | def actionConfig(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
|
---|
759 | """
|
---|
760 | For base.TestDriver.actionConfig. Configure the VMs with defaults and
|
---|
761 | a few tweaks as per arguments.
|
---|
762 |
|
---|
763 | Returns True if successful.
|
---|
764 | Returns False if not.
|
---|
765 | """
|
---|
766 |
|
---|
767 | for oTestVm in self.aoTestVms:
|
---|
768 | if oTestVm.fSkip:
|
---|
769 | continue;
|
---|
770 |
|
---|
771 | if oTestVm.fSnapshotRestoreCurrent:
|
---|
772 | # If we want to restore a VM we don't need to create
|
---|
773 | # the machine anymore -- so just add it to the test VM list.
|
---|
774 | oVM = oTestDrv.addTestMachine(oTestVm.sVmName);
|
---|
775 | else:
|
---|
776 | oVM = oTestVm.createVm(oTestDrv, eNic0AttachType, sDvdImage);
|
---|
777 | if oVM is None:
|
---|
778 | return False;
|
---|
779 |
|
---|
780 | return True;
|
---|
781 |
|
---|
782 | def _removeUnsupportedVirtModes(self, oTestDrv):
|
---|
783 | """
|
---|
784 | Removes unsupported virtualization modes.
|
---|
785 | """
|
---|
786 | if 'hwvirt' in self.asVirtModes and not oTestDrv.hasHostHwVirt():
|
---|
787 | reporter.log('Hardware assisted virtualization is not available on the host, skipping it.');
|
---|
788 | self.asVirtModes.remove('hwvirt');
|
---|
789 |
|
---|
790 | if 'hwvirt-np' in self.asVirtModes and not oTestDrv.hasHostNestedPaging():
|
---|
791 | reporter.log('Nested paging not supported by the host, skipping it.');
|
---|
792 | self.asVirtModes.remove('hwvirt-np');
|
---|
793 |
|
---|
794 | if 'raw' in self.asVirtModes and not oTestDrv.hasRawModeSupport():
|
---|
795 | reporter.log('Raw-mode virtualization is not available in this build (or perhaps for this host), skipping it.');
|
---|
796 | self.asVirtModes.remove('raw');
|
---|
797 |
|
---|
798 | return True;
|
---|
799 |
|
---|
800 | def actionExecute(self, oTestDrv, fnCallback): # pylint: disable=R0914
|
---|
801 | """
|
---|
802 | For base.TestDriver.actionExecute. Calls the callback function for
|
---|
803 | each of the VMs and basic configuration variations (virt-mode and cpu
|
---|
804 | count).
|
---|
805 |
|
---|
806 | Returns True if all fnCallback calls returned True, otherwise False.
|
---|
807 |
|
---|
808 | The callback can return True, False or None. The latter is for when the
|
---|
809 | test is skipped. (True is for success, False is for failure.)
|
---|
810 | """
|
---|
811 |
|
---|
812 | self._removeUnsupportedVirtModes(oTestDrv);
|
---|
813 | cMaxCpus = oTestDrv.getHostCpuCount();
|
---|
814 |
|
---|
815 | #
|
---|
816 | # The test loop.
|
---|
817 | #
|
---|
818 | fRc = True;
|
---|
819 | for oTestVm in self.aoTestVms:
|
---|
820 | if oTestVm.fSkip and self.fIgnoreSkippedVm:
|
---|
821 | reporter.log2('Ignoring VM %s (fSkip = True).' % (oTestVm.sVmName,));
|
---|
822 | continue;
|
---|
823 | reporter.testStart(oTestVm.sVmName);
|
---|
824 | if oTestVm.fSkip:
|
---|
825 | reporter.testDone(fSkipped = True);
|
---|
826 | continue;
|
---|
827 |
|
---|
828 | # Intersect the supported modes and the ones being testing.
|
---|
829 | asVirtModesSup = [sMode for sMode in oTestVm.asVirtModesSup if sMode in self.asVirtModes];
|
---|
830 |
|
---|
831 | # Ditto for CPUs.
|
---|
832 | acCpusSup = [cCpus for cCpus in oTestVm.acCpusSup if cCpus in self.acCpus];
|
---|
833 |
|
---|
834 | # Ditto for paravirtualization modes, except if not specified we got a less obvious default.
|
---|
835 | if self.asParavirtModes is not None and oTestDrv.fpApiVer >= 5.0:
|
---|
836 | asParavirtModes = [sPvMode for sPvMode in oTestVm.asParavirtModesSup if sPvMode in self.asParavirtModes];
|
---|
837 | assert None not in asParavirtModes;
|
---|
838 | elif oTestDrv.fpApiVer >= 5.0:
|
---|
839 | asParavirtModes = (oTestVm.asParavirtModesSup[0],);
|
---|
840 | assert asParavirtModes[0] is not None;
|
---|
841 | else:
|
---|
842 | asParavirtModes = (None,);
|
---|
843 |
|
---|
844 | for cCpus in acCpusSup:
|
---|
845 | if cCpus == 1:
|
---|
846 | reporter.testStart('1 cpu');
|
---|
847 | else:
|
---|
848 | reporter.testStart('%u cpus' % (cCpus));
|
---|
849 | if cCpus > cMaxCpus:
|
---|
850 | reporter.testDone(fSkipped = True);
|
---|
851 | continue;
|
---|
852 |
|
---|
853 | cTests = 0;
|
---|
854 | for sVirtMode in asVirtModesSup:
|
---|
855 | if sVirtMode == 'raw' and cCpus > 1:
|
---|
856 | continue;
|
---|
857 | reporter.testStart('%s' % ( g_dsVirtModeDescs[sVirtMode], ) );
|
---|
858 | cStartTests = cTests;
|
---|
859 |
|
---|
860 | for sParavirtMode in asParavirtModes:
|
---|
861 | if sParavirtMode is not None:
|
---|
862 | assert oTestDrv.fpApiVer >= 5.0;
|
---|
863 | reporter.testStart('%s' % ( sParavirtMode, ) );
|
---|
864 |
|
---|
865 | # Reconfigure the VM.
|
---|
866 | try:
|
---|
867 | (rc2, oVM) = oTestVm.getReconfiguredVm(oTestDrv, cCpus, sVirtMode, sParavirtMode = sParavirtMode);
|
---|
868 | except KeyboardInterrupt:
|
---|
869 | raise;
|
---|
870 | except:
|
---|
871 | reporter.errorXcpt(cFrames = 9);
|
---|
872 | rc2 = False;
|
---|
873 | if rc2 is True:
|
---|
874 | # Do the testing.
|
---|
875 | try:
|
---|
876 | rc2 = fnCallback(oVM, oTestVm);
|
---|
877 | except KeyboardInterrupt:
|
---|
878 | raise;
|
---|
879 | except:
|
---|
880 | reporter.errorXcpt(cFrames = 9);
|
---|
881 | rc2 = False;
|
---|
882 | if rc2 is False:
|
---|
883 | reporter.maybeErr(reporter.testErrorCount() == 0, 'fnCallback failed');
|
---|
884 | elif rc2 is False:
|
---|
885 | reporter.log('getReconfiguredVm failed');
|
---|
886 | if rc2 is False:
|
---|
887 | fRc = False;
|
---|
888 |
|
---|
889 | cTests = cTests + (rc2 is not None);
|
---|
890 | if sParavirtMode is not None:
|
---|
891 | reporter.testDone(fSkipped = (rc2 is None));
|
---|
892 |
|
---|
893 | reporter.testDone(fSkipped = cTests == cStartTests);
|
---|
894 |
|
---|
895 | reporter.testDone(fSkipped = cTests == 0);
|
---|
896 |
|
---|
897 | _, cErrors = reporter.testDone();
|
---|
898 | if cErrors > 0:
|
---|
899 | fRc = False;
|
---|
900 | return fRc;
|
---|
901 |
|
---|
902 | def enumerateTestVms(self, fnCallback):
|
---|
903 | """
|
---|
904 | Enumerates all the 'active' VMs.
|
---|
905 |
|
---|
906 | Returns True if all fnCallback calls returned True.
|
---|
907 | Returns False if any returned False.
|
---|
908 | Returns None immediately if fnCallback returned None.
|
---|
909 | """
|
---|
910 | fRc = True;
|
---|
911 | for oTestVm in self.aoTestVms:
|
---|
912 | if not oTestVm.fSkip:
|
---|
913 | fRc2 = fnCallback(oTestVm);
|
---|
914 | if fRc2 is None:
|
---|
915 | return fRc2;
|
---|
916 | fRc = fRc and fRc2;
|
---|
917 | return fRc;
|
---|
918 |
|
---|
919 |
|
---|
920 |
|
---|
921 | class TestVmManager(object):
|
---|
922 | """
|
---|
923 | Test VM manager.
|
---|
924 | """
|
---|
925 |
|
---|
926 | ## @name VM grouping flags
|
---|
927 | ## @{
|
---|
928 | kfGrpSmoke = 0x0001; ##< Smoke test VM.
|
---|
929 | kfGrpStandard = 0x0002; ##< Standard test VM.
|
---|
930 | kfGrpStdSmoke = kfGrpSmoke | kfGrpStandard; ##< shorthand.
|
---|
931 | kfGrpWithGAs = 0x0004; ##< The VM has guest additions installed.
|
---|
932 | kfGrpNoTxs = 0x0008; ##< The VM lacks test execution service.
|
---|
933 | kfGrpAncient = 0x1000; ##< Ancient OS.
|
---|
934 | kfGrpExotic = 0x2000; ##< Exotic OS.
|
---|
935 | ## @}
|
---|
936 |
|
---|
937 | kaTestVMs = (
|
---|
938 | # Linux
|
---|
939 | TestVm('tst-ubuntu-15_10-64-efi', kfGrpStdSmoke, sHd = '4.2/efi/ubuntu-15_10-efi-amd64.vdi',
|
---|
940 | sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi',
|
---|
941 | asParavirtModesSup = [g_ksParavirtProviderKVM,]),
|
---|
942 | TestVm('tst-rhel5', kfGrpSmoke, sHd = '3.0/tcp/rhel5.vdi',
|
---|
943 | sKind = 'RedHat', acCpusSup = range(1, 33), fIoApic = True, sNic0AttachType = 'nat'),
|
---|
944 |
|
---|
945 | # Solaris
|
---|
946 | TestVm('tst-sol10', kfGrpSmoke, sHd = '3.0/tcp/solaris10.vdi',
|
---|
947 | sKind = 'Solaris', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged'),
|
---|
948 | TestVm('tst-sol10-64', kfGrpSmoke, sHd = '3.0/tcp/solaris10.vdi',
|
---|
949 | sKind = 'Solaris_64', acCpusSup = range(1, 33), sNic0AttachType = 'bridged'),
|
---|
950 | TestVm('tst-sol11u1', kfGrpSmoke, sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
|
---|
951 | sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat', fIoApic = True,
|
---|
952 | sHddControllerType = 'SATA Controller'),
|
---|
953 | #TestVm('tst-sol11u1-ich9', kfGrpSmoke, sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
|
---|
954 | # sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat', fIoApic = True,
|
---|
955 | # sHddControllerType = 'SATA Controller', sChipsetType = 'ich9'),
|
---|
956 |
|
---|
957 | # NT 3.x
|
---|
958 | TestVm('tst-nt310', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
|
---|
959 | sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
|
---|
960 | sDvdControllerType = 'BusLogic SCSI Controller'),
|
---|
961 | TestVm('tst-nt350', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt350/t-nt350.vdi',
|
---|
962 | sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
|
---|
963 | sDvdControllerType = 'BusLogic SCSI Controller'),
|
---|
964 | TestVm('tst-nt351', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt350/t-nt350.vdi',
|
---|
965 | sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
|
---|
966 | sDvdControllerType = 'BusLogic SCSI Controller'),
|
---|
967 |
|
---|
968 | # NT 4
|
---|
969 | TestVm('tst-nt4sp1', kfGrpStdSmoke, sHd = '4.2/nat/nt4sp1/t-nt4sp1.vdi',
|
---|
970 | sKind = 'WindowsNT4', acCpusSup = [1], sNic0AttachType = 'nat'),
|
---|
971 |
|
---|
972 | TestVm('tst-nt4sp6', kfGrpStdSmoke, sHd = '4.2/nt4sp6/t-nt4sp6.vdi',
|
---|
973 | sKind = 'WindowsNT4', acCpusSup = range(1, 33)),
|
---|
974 |
|
---|
975 | # W2K
|
---|
976 | TestVm('tst-2ksp4', kfGrpStdSmoke, sHd = '4.2/win2ksp4/t-win2ksp4.vdi',
|
---|
977 | sKind = 'Windows2000', acCpusSup = range(1, 33)),
|
---|
978 |
|
---|
979 | # XP
|
---|
980 | TestVm('tst-xppro', kfGrpStdSmoke, sHd = '4.2/nat/xppro/t-xppro.vdi',
|
---|
981 | sKind = 'WindowsXP', acCpusSup = range(1, 33), sNic0AttachType = 'nat'),
|
---|
982 | TestVm('tst-xpsp2', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxpsp2.vdi',
|
---|
983 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
|
---|
984 | TestVm('tst-xpsp2-halaacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halaacpi.vdi',
|
---|
985 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
|
---|
986 | TestVm('tst-xpsp2-halacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halacpi.vdi',
|
---|
987 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
|
---|
988 | TestVm('tst-xpsp2-halapic', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halapic.vdi',
|
---|
989 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
|
---|
990 | TestVm('tst-xpsp2-halmacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halmacpi.vdi',
|
---|
991 | sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True),
|
---|
992 | TestVm('tst-xpsp2-halmps', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halmps.vdi',
|
---|
993 | sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True),
|
---|
994 |
|
---|
995 | # W2K3
|
---|
996 | TestVm('tst-win2k3ent', kfGrpSmoke, sHd = '3.0/tcp/win2k3ent-acpi.vdi',
|
---|
997 | sKind = 'Windows2003', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged'),
|
---|
998 |
|
---|
999 | # W7
|
---|
1000 | TestVm('tst-win7', kfGrpStdSmoke, sHd = '4.2/win7-32/t-win7.vdi',
|
---|
1001 | sKind = 'Windows7', acCpusSup = range(1, 33), fIoApic = True),
|
---|
1002 |
|
---|
1003 | # W8
|
---|
1004 | TestVm('tst-win8-64', kfGrpStdSmoke, sHd = '4.2/win8-64/t-win8-64.vdi',
|
---|
1005 | sKind = 'Windows8_64', acCpusSup = range(1, 33), fIoApic = True),
|
---|
1006 | #TestVm('tst-win8-64-ich9', kfGrpStdSmoke, sHd = '4.2/win8-64/t-win8-64.vdi',
|
---|
1007 | # sKind = 'Windows8_64', acCpusSup = range(1, 33), fIoApic = True, sChipsetType = 'ich9'),
|
---|
1008 |
|
---|
1009 | # W10
|
---|
1010 | TestVm('tst-win10-efi', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-x86.vdi',
|
---|
1011 | sKind = 'Windows10', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi'),
|
---|
1012 | TestVm('tst-win10-64-efi', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-amd64.vdi',
|
---|
1013 | sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi'),
|
---|
1014 | #TestVm('tst-win10-64-efi-ich9', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-amd64.vdi',
|
---|
1015 | # sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi', sChipsetType = 'ich9'),
|
---|
1016 |
|
---|
1017 | # DOS and Old Windows.
|
---|
1018 | # todo ...
|
---|
1019 | );
|
---|
1020 |
|
---|
1021 |
|
---|
1022 | def __init__(self, sResourcePath):
|
---|
1023 | self.sResourcePath = sResourcePath;
|
---|
1024 |
|
---|
1025 | def selectSet(self, fGrouping, sTxsTransport = None, fCheckResources = True):
|
---|
1026 | """
|
---|
1027 | Returns a VM set with the selected VMs.
|
---|
1028 | """
|
---|
1029 | oSet = TestVmSet(oTestVmManager = self);
|
---|
1030 | for oVm in self.kaTestVMs:
|
---|
1031 | if oVm.fGrouping & fGrouping:
|
---|
1032 | if sTxsTransport is None or oVm.sNic0AttachType is None or sTxsTransport == oVm.sNic0AttachType:
|
---|
1033 | if not fCheckResources or not oVm.getMissingResources(self.sResourcePath):
|
---|
1034 | oCopyVm = copy.deepcopy(oVm);
|
---|
1035 | oCopyVm.oSet = oSet;
|
---|
1036 | oSet.aoTestVms.append(oCopyVm);
|
---|
1037 | return oSet;
|
---|
1038 |
|
---|
1039 | def getStandardVmSet(self, sTxsTransport):
|
---|
1040 | """
|
---|
1041 | Gets the set of standard test VMs.
|
---|
1042 |
|
---|
1043 | This is supposed to do something seriously clever, like searching the
|
---|
1044 | testrsrc tree for usable VMs, but for the moment it's all hard coded. :-)
|
---|
1045 | """
|
---|
1046 | return self.selectSet(self.kfGrpStandard, sTxsTransport)
|
---|
1047 |
|
---|
1048 | def getSmokeVmSet(self):
|
---|
1049 | """Gets a representative set of VMs for smoke testing. """
|
---|
1050 | return self.selectSet(self.kfGrpSmoke);
|
---|
1051 |
|
---|
1052 | def shutUpPyLint(self):
|
---|
1053 | """ Shut up already! """
|
---|
1054 | return self.sResourcePath;
|
---|
1055 |
|
---|