VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testdriver/vboxtestvms.py@ 78965

Last change on this file since 78965 was 78957, checked in by vboxsync, 6 years ago

ValKit: type hint

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 75.3 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: vboxtestvms.py 78957 2019-06-04 08:46:02Z vboxsync $
3
4"""
5VirtualBox Test VMs
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2010-2019 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 78957 $"
30
31# Standard Python imports.
32import copy;
33import os;
34import re;
35import random;
36import socket;
37import string;
38
39# Validation Kit imports.
40from testdriver import base;
41from testdriver import reporter;
42from testdriver import vboxcon;
43from common import utils;
44
45
46# All virtualization modes.
47g_asVirtModes = ['hwvirt', 'hwvirt-np', 'raw',];
48# All virtualization modes except for raw-mode.
49g_asVirtModesNoRaw = ['hwvirt', 'hwvirt-np',];
50# Dictionary mapping the virtualization mode mnemonics to a little less cryptic
51# strings used in test descriptions.
52g_dsVirtModeDescs = {
53 'raw' : 'Raw-mode',
54 'hwvirt' : 'HwVirt',
55 'hwvirt-np' : 'NestedPaging'
56};
57
58## @name VM grouping flags
59## @{
60g_kfGrpSmoke = 0x0001; ##< Smoke test VM.
61g_kfGrpStandard = 0x0002; ##< Standard test VM.
62g_kfGrpStdSmoke = g_kfGrpSmoke | g_kfGrpStandard; ##< shorthand.
63g_kfGrpWithGAs = 0x0004; ##< The VM has guest additions installed.
64g_kfGrpNoTxs = 0x0008; ##< The VM lacks test execution service.
65g_kfGrpAncient = 0x1000; ##< Ancient OS.
66g_kfGrpExotic = 0x2000; ##< Exotic OS.
67## @}
68
69
70## @name Flags.
71## @{
72g_k32 = 32; # pylint: disable=C0103
73g_k64 = 64; # pylint: disable=C0103
74g_k32_64 = 96; # pylint: disable=C0103
75g_kiArchMask = 96;
76g_kiNoRaw = 128; ##< No raw mode.
77## @}
78
79# Array indexes.
80g_iGuestOsType = 0;
81g_iKind = 1;
82g_iFlags = 2;
83g_iMinCpu = 3;
84g_iMaxCpu = 4;
85g_iRegEx = 5;
86
87# Table translating from VM name core to a more detailed guest info.
88# pylint: disable=C0301
89## @todo what's the difference between the first two columns again?
90g_aaNameToDetails = \
91[
92 [ 'WindowsNT3x', 'WindowsNT3x', g_k32, 1, 32, ['nt3', 'nt3[0-9]*']], # max cpus??
93 [ 'WindowsNT4', 'WindowsNT4', g_k32, 1, 32, ['nt4', 'nt4sp[0-9]']], # max cpus??
94 [ 'Windows2000', 'Windows2000', g_k32, 1, 32, ['w2k', 'w2ksp[0-9]', 'win2k', 'win2ksp[0-9]']], # max cpus??
95 [ 'WindowsXP', 'WindowsXP', g_k32, 1, 32, ['xp', 'xpsp[0-9]']],
96 [ 'WindowsXP_64', 'WindowsXP_64', g_k64, 1, 32, ['xp64', 'xp64sp[0-9]']],
97 [ 'Windows2003', 'Windows2003', g_k32, 1, 32, ['w2k3', 'w2k3sp[0-9]', 'win2k3', 'win2k3sp[0-9]']],
98 [ 'WindowsVista', 'WindowsVista', g_k32, 1, 32, ['vista', 'vistasp[0-9]']],
99 [ 'WindowsVista_64','WindowsVista_64', g_k64, 1, 64, ['vista-64', 'vistasp[0-9]-64',]], # max cpus/cores??
100 [ 'Windows2008', 'Windows2008', g_k32, 1, 64, ['w2k8', 'w2k8sp[0-9]', 'win2k8', 'win2k8sp[0-9]']], # max cpus/cores??
101 [ 'Windows2008_64', 'Windows2008_64', g_k64, 1, 64, ['w2k8r2', 'w2k8r2sp[0-9]', 'win2k8r2', 'win2k8r2sp[0-9]']], # max cpus/cores??
102 [ 'Windows7', 'Windows7', g_k32, 1, 32, ['w7', 'w7sp[0-9]', 'win7',]], # max cpus/cores??
103 [ 'Windows7_64', 'Windows7_64', g_k64, 1, 64, ['w7-64', 'w7sp[0-9]-64', 'win7-64',]], # max cpus/cores??
104 [ 'Windows8', 'Windows8', g_k32 | g_kiNoRaw, 1, 32, ['w8', 'w8sp[0-9]', 'win8',]], # max cpus/cores??
105 [ 'Windows8_64', 'Windows8_64', g_k64, 1, 64, ['w8-64', 'w8sp[0-9]-64', 'win8-64',]], # max cpus/cores??
106 [ 'Windows81', 'Windows81', g_k32 | g_kiNoRaw, 1, 32, ['w81', 'w81sp[0-9]', 'win81',]], # max cpus/cores??
107 [ 'Windows81_64', 'Windows81_64', g_k64, 1, 64, ['w81-64', 'w81sp[0-9]-64', 'win81-64',]], # max cpus/cores??
108 [ 'Windows10', 'Windows10', g_k32 | g_kiNoRaw, 1, 32, ['w10', 'w10sp[0-9]', 'win10',]], # max cpus/cores??
109 [ 'Windows10_64', 'Windows10_64', g_k64, 1, 64, ['w10-64', 'w10sp[0-9]-64', 'win10-64',]], # max cpus/cores??
110 [ 'Linux', 'Debian', g_k32, 1, 256, ['deb[0-9]*', 'debian[0-9]*', ]],
111 [ 'Linux_64', 'Debian_64', g_k64, 1, 256, ['deb[0-9]*-64', 'debian[0-9]*-64', ]],
112 [ 'Linux', 'RedHat', g_k32, 1, 256, ['rhel', 'rhel[0-9]', 'rhel[0-9]u[0-9]']],
113 [ 'Linux', 'Fedora', g_k32, 1, 256, ['fedora', 'fedora[0-9]*', ]],
114 [ 'Linux_64', 'Fedora_64', g_k64, 1, 256, ['fedora-64', 'fedora[0-9]*-64', ]],
115 [ 'Linux', 'Oracle', g_k32, 1, 256, ['ols[0-9]*', 'oel[0-9]*', ]],
116 [ 'Linux_64', 'Oracle_64', g_k64, 1, 256, ['ols[0-9]*-64', 'oel[0-9]*-64', ]],
117 [ 'Linux', 'OpenSUSE', g_k32, 1, 256, ['opensuse[0-9]*', 'suse[0-9]*', ]],
118 [ 'Linux_64', 'OpenSUSE_64', g_k64, 1, 256, ['opensuse[0-9]*-64', 'suse[0-9]*-64', ]],
119 [ 'Linux', 'Ubuntu', g_k32, 1, 256, ['ubuntu[0-9]*', ]],
120 [ 'Linux_64', 'Ubuntu_64', g_k64, 1, 256, ['ubuntu[0-9]*-64', ]],
121 [ 'Linux', 'ArchLinux', g_k32, 1, 256, ['arch[0-9]*', ]],
122 [ 'Linux_64', 'ArchLinux_64', g_k64, 1, 256, ['arch[0-9]*-64', ]],
123 [ 'Solaris', 'Solaris', g_k32, 1, 256, ['sol10', 'sol10u[0-9]']],
124 [ 'Solaris_64', 'Solaris_64', g_k64, 1, 256, ['sol10-64', 'sol10u-64[0-9]']],
125 [ 'Solaris_64', 'Solaris11_64', g_k64, 1, 256, ['sol11u1']],
126 [ 'BSD', 'FreeBSD_64', g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
127 [ 'DOS', 'DOS', g_k32, 1, 1, ['bs-.*']],
128];
129
130
131## @name Guest OS type string constants.
132## @{
133g_ksGuestOsTypeDarwin = 'darwin';
134g_ksGuestOsTypeDOS = 'dos';
135g_ksGuestOsTypeFreeBSD = 'freebsd';
136g_ksGuestOsTypeLinux = 'linux';
137g_ksGuestOsTypeOS2 = 'os2';
138g_ksGuestOsTypeSolaris = 'solaris';
139g_ksGuestOsTypeWindows = 'windows';
140## @}
141
142## @name String constants for paravirtualization providers.
143## @{
144g_ksParavirtProviderNone = 'none';
145g_ksParavirtProviderDefault = 'default';
146g_ksParavirtProviderLegacy = 'legacy';
147g_ksParavirtProviderMinimal = 'minimal';
148g_ksParavirtProviderHyperV = 'hyperv';
149g_ksParavirtProviderKVM = 'kvm';
150## @}
151
152## Valid paravirtualization providers.
153g_kasParavirtProviders = ( g_ksParavirtProviderNone, g_ksParavirtProviderDefault, g_ksParavirtProviderLegacy,
154 g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM );
155
156# Mapping for support of paravirtualisation providers per guest OS.
157#g_kdaParavirtProvidersSupported = {
158# g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
159# g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
160# g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
161# g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
162# g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
163# g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, )
164#}
165# Temporary tweak:
166# since for the most guests g_ksParavirtProviderNone is almost the same as g_ksParavirtProviderMinimal,
167# g_ksParavirtProviderMinimal is removed from the list in order to get maximum number of unique choices
168# during independent test runs when paravirt provider is taken randomly.
169g_kdaParavirtProvidersSupported = {
170 g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
171 g_ksGuestOsTypeDOS : ( g_ksParavirtProviderNone, ),
172 g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, ),
173 g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
174 g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
175 g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
176 g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, )
177}
178
179
180# pylint: enable=C0301
181
182def _intersects(asSet1, asSet2):
183 """
184 Checks if any of the strings in set 1 matches any of the regular
185 expressions in set 2.
186 """
187 for sStr1 in asSet1:
188 for sRx2 in asSet2:
189 if re.match(sStr1, sRx2 + '$'):
190 return True;
191 return False;
192
193
194
195class BaseTestVm(object):
196 """
197 Base class ofr Test VMs.
198 """
199
200 def __init__(self, # pylint: disable=R0913
201 sVmName, # type: str
202 fGrouping = 0, # type: int
203 oSet = None, # type: TestVmSet
204 sKind = None, # type: str
205 acCpusSup = None, # type: List[int]
206 asVirtModesSup = None, # type: List[str]
207 asParavirtModesSup = None, # type: List[str]
208 fRandomPvPModeCrap = False, # type: bool
209 fVmmDevTestingPart = None, # type: bool
210 fVmmDevTestingMmio = False, # type: bool
211 ):
212 self.oSet = oSet;
213 self.sVmName = sVmName;
214 self.fGrouping = fGrouping;
215 self.sKind = sKind; # Guest OS type.
216 self.acCpusSup = acCpusSup;
217 self.asVirtModesSup = asVirtModesSup;
218 self.asParavirtModesSup = asParavirtModesSup;
219 self.asParavirtModesSupOrg = asParavirtModesSup; # HACK ALERT! Trick to make the 'effing random mess not get in the
220 # way of actively selecting virtualization modes.
221
222 self.fSkip = False; # All VMs are included in the configured set by default.
223 self.fSnapshotRestoreCurrent = False; # Whether to restore execution on the current snapshot.
224
225 self.fVmmDevTestingPart = fVmmDevTestingPart;
226 self.fVmmDevTestingMmio = fVmmDevTestingMmio;
227 self.fCom1RawFile = False;
228 self.sCom1RawFile = None; # Set by createVmInner and getReconfiguredVm if fCom1RawFile is set.
229
230 # Derived stuff:
231 self.aInfo = None;
232 self.sGuestOsType = None; # ksGuestOsTypeXxxx value, API GuestOS Type is in the sKind member.
233 self._guessStuff(fRandomPvPModeCrap);
234
235 def _mkCanonicalGuestOSType(self, sType):
236 """
237 Convert guest OS type into constant representation.
238 Raise exception if specified @param sType is unknown.
239 """
240 if sType.lower().startswith('darwin'):
241 return g_ksGuestOsTypeDarwin
242 if sType.lower().startswith('bsd'):
243 return g_ksGuestOsTypeFreeBSD
244 if sType.lower().startswith('dos'):
245 return g_ksGuestOsTypeDOS
246 if sType.lower().startswith('linux'):
247 return g_ksGuestOsTypeLinux
248 if sType.lower().startswith('os2'):
249 return g_ksGuestOsTypeOS2
250 if sType.lower().startswith('solaris'):
251 return g_ksGuestOsTypeSolaris
252 if sType.lower().startswith('windows'):
253 return g_ksGuestOsTypeWindows
254 raise base.GenError(sWhat="unknown guest OS kind: %s" % str(sType))
255
256 def _guessStuff(self, fRandomPvPModeCrap):
257 """
258 Used by the constructor to guess stuff.
259 """
260
261 sNm = self.sVmName.lower().strip();
262 asSplit = sNm.replace('-', ' ').split(' ');
263
264 if self.sKind is None:
265 # From name.
266 for aInfo in g_aaNameToDetails:
267 if _intersects(asSplit, aInfo[g_iRegEx]):
268 self.aInfo = aInfo;
269 self.sGuestOsType = self._mkCanonicalGuestOSType(aInfo[g_iGuestOsType])
270 self.sKind = aInfo[g_iKind];
271 break;
272 if self.sKind is None:
273 reporter.fatal('The OS of test VM "%s" cannot be guessed' % (self.sVmName,));
274
275 # Check for 64-bit, if required and supported.
276 if (self.aInfo[g_iFlags] & g_kiArchMask) == g_k32_64 and _intersects(asSplit, ['64', 'amd64']):
277 self.sKind = self.sKind + '_64';
278 else:
279 # Lookup the kind.
280 for aInfo in g_aaNameToDetails:
281 if self.sKind == aInfo[g_iKind]:
282 self.aInfo = aInfo;
283 break;
284 if self.aInfo is None:
285 reporter.fatal('The OS of test VM "%s" with sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
286
287 # Translate sKind into sGuest OS Type.
288 if self.sGuestOsType is None:
289 if self.aInfo is not None:
290 self.sGuestOsType = self._mkCanonicalGuestOSType(self.aInfo[g_iGuestOsType])
291 elif self.sKind.find("Windows") >= 0:
292 self.sGuestOsType = g_ksGuestOsTypeWindows
293 elif self.sKind.find("Linux") >= 0:
294 self.sGuestOsType = g_ksGuestOsTypeLinux;
295 elif self.sKind.find("Solaris") >= 0:
296 self.sGuestOsType = g_ksGuestOsTypeSolaris;
297 elif self.sKind.find("DOS") >= 0:
298 self.sGuestOsType = g_ksGuestOsTypeDOS;
299 else:
300 reporter.fatal('The OS of test VM "%s", sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
301
302 # Restrict modes and such depending on the OS.
303 if self.asVirtModesSup is None:
304 self.asVirtModesSup = list(g_asVirtModes);
305 if self.sGuestOsType in (g_ksGuestOsTypeOS2, g_ksGuestOsTypeDarwin) \
306 or self.sKind.find('_64') > 0 \
307 or (self.aInfo is not None and (self.aInfo[g_iFlags] & g_kiNoRaw)):
308 self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
309 # TEMPORARY HACK - START
310 sHostName = os.environ.get("COMPUTERNAME", None);
311 if sHostName: sHostName = sHostName.lower();
312 else: sHostName = socket.getfqdn(); # Horribly slow on windows without IPv6 DNS/whatever.
313 if sHostName.startswith('testboxpile1'):
314 self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
315 # TEMPORARY HACK - END
316
317 # Restrict the CPU count depending on the OS and/or percieved SMP readiness.
318 if self.acCpusSup is None:
319 if _intersects(asSplit, ['uni']):
320 self.acCpusSup = [1];
321 elif self.aInfo is not None:
322 self.acCpusSup = [i for i in range(self.aInfo[g_iMinCpu], self.aInfo[g_iMaxCpu]) ];
323 else:
324 self.acCpusSup = [1];
325
326 # Figure relevant PV modes based on the OS.
327 if self.asParavirtModesSup is None:
328 self.asParavirtModesSup = g_kdaParavirtProvidersSupported[self.sGuestOsType];
329 ## @todo Remove this hack as soon as we've got around to explictly configure test variations
330 ## on the server side. Client side random is interesting but not the best option.
331 self.asParavirtModesSupOrg = self.asParavirtModesSup;
332 if fRandomPvPModeCrap:
333 random.seed();
334 self.asParavirtModesSup = (random.choice(self.asParavirtModesSup),);
335
336 return True;
337
338 def _generateRawPortFilename(self, oTestDrv, sInfix, sSuffix):
339 """ Generates a raw port filename. """
340 random.seed();
341 sRandom = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10));
342 return os.path.join(oTestDrv.sScratchPath, self.sVmName + sInfix + sRandom + sSuffix);
343
344 def _createVmTail(self, oTestDrv, eNic0AttachType, sDvdImage):
345 """
346 Returns same as vbox.TestDriver.createTestVM.
347 """
348 _ = oTestDrv; _ = eNic0AttachType; _ = sDvdImage;
349 return reporter.error('Base class _createVmTail must not be called!');
350
351 def _childVmReconfig(self, oTestDrv, oVM, oSession):
352 """
353 Hook into getReconfiguredVm() for children.
354 """
355 _ = oTestDrv; _ = oVM; _ = oSession;
356 return True;
357
358
359 #
360 # Public interface.
361 #
362
363 def getMissingResources(self, sTestRsrc):
364 """
365 Returns a list of missing resources (paths, stuff) that the VM needs.
366 """
367 _ = sTestRsrc;
368 return [];
369
370 def createVm(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
371 """
372 Creates the VM with defaults and the few tweaks as per the arguments.
373
374 Returns same as vbox.TestDriver.createTestVM.
375 """
376 reporter.log2('');
377 reporter.log2('Creating %s...' % (self.sVmName,))
378
379 if self.fCom1RawFile:
380 self.sCom1RawFile = self._generateRawPortFilename(oTestDrv, '-com1-', '.out');
381
382 return self._createVmTail(oTestDrv, eNic0AttachType, sDvdImage);
383
384 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
385 """
386 actionExecute worker that finds and reconfigure a test VM.
387
388 Returns (fRc, oVM) where fRc is True, None or False and oVM is a
389 VBox VM object that is only present when rc is True.
390 """
391
392 fRc = False;
393 oVM = oTestDrv.getVmByName(self.sVmName);
394 if oVM is not None:
395 if self.fSnapshotRestoreCurrent is True:
396 fRc = True;
397 else:
398 fHostSupports64bit = oTestDrv.hasHostLongMode();
399 if self.is64bitRequired() and not fHostSupports64bit:
400 fRc = None; # Skip the test.
401 elif self.isViaIncompatible() and oTestDrv.isHostCpuVia():
402 fRc = None; # Skip the test.
403 elif self.isShanghaiIncompatible() and oTestDrv.isHostCpuShanghai():
404 fRc = None; # Skip the test.
405 elif self.isP4Incompatible() and oTestDrv.isHostCpuP4():
406 fRc = None; # Skip the test.
407 else:
408 oSession = oTestDrv.openSession(oVM);
409 if oSession is not None:
410 fRc = oSession.enableVirtEx(sVirtMode != 'raw');
411 fRc = fRc and oSession.enableNestedPaging(sVirtMode == 'hwvirt-np');
412 fRc = fRc and oSession.setCpuCount(cCpus);
413 if cCpus > 1:
414 fRc = fRc and oSession.enableIoApic(True);
415
416 if sParavirtMode is not None and oSession.fpApiVer >= 5.0:
417 adParavirtProviders = {
418 g_ksParavirtProviderNone : vboxcon.ParavirtProvider_None,
419 g_ksParavirtProviderDefault: vboxcon.ParavirtProvider_Default,
420 g_ksParavirtProviderLegacy : vboxcon.ParavirtProvider_Legacy,
421 g_ksParavirtProviderMinimal: vboxcon.ParavirtProvider_Minimal,
422 g_ksParavirtProviderHyperV : vboxcon.ParavirtProvider_HyperV,
423 g_ksParavirtProviderKVM : vboxcon.ParavirtProvider_KVM,
424 };
425 fRc = fRc and oSession.setParavirtProvider(adParavirtProviders[sParavirtMode]);
426
427 fCfg64Bit = self.is64bitRequired() or (self.is64bit() and fHostSupports64bit and sVirtMode != 'raw');
428 fRc = fRc and oSession.enableLongMode(fCfg64Bit);
429 if fCfg64Bit: # This is to avoid GUI pedantic warnings in the GUI. Sigh.
430 oOsType = oSession.getOsType();
431 if oOsType is not None:
432 if oOsType.is64Bit and sVirtMode == 'raw':
433 assert(oOsType.id[-3:] == '_64');
434 fRc = fRc and oSession.setOsType(oOsType.id[:-3]);
435 elif not oOsType.is64Bit and sVirtMode != 'raw':
436 fRc = fRc and oSession.setOsType(oOsType.id + '_64');
437
438 # New serial raw file.
439 if fRc and self.fCom1RawFile:
440 self.sCom1RawFile = self._generateRawPortFilename(oTestDrv, '-com1-', '.out');
441 utils.noxcptDeleteFile(self.sCom1RawFile);
442 fRc = oSession.setupSerialToRawFile(0, self.sCom1RawFile);
443
444 # Make life simpler for child classes.
445 if fRc:
446 fRc = self._childVmReconfig(oTestDrv, oVM, oSession);
447
448 fRc = fRc and oSession.saveSettings();
449 if not oSession.close():
450 fRc = False;
451 if fRc is True:
452 return (True, oVM);
453 return (fRc, None);
454
455 def getNonCanonicalGuestOsType(self):
456 """
457 Gets the non-canonical OS type (self.sGuestOsType is canonical).
458 """
459 return self.sKind; #self.aInfo[g_iGuestOsType];
460
461 def isWindows(self):
462 """ Checks if it's a Windows VM. """
463 return self.sGuestOsType == g_ksGuestOsTypeWindows;
464
465 def isOS2(self):
466 """ Checks if it's an OS/2 VM. """
467 return self.sGuestOsType == g_ksGuestOsTypeOS2;
468
469 def isLinux(self):
470 """ Checks if it's an Linux VM. """
471 return self.sGuestOsType == g_ksGuestOsTypeLinux;
472
473 def is64bit(self):
474 """ Checks if it's a 64-bit VM. """
475 return self.sKind.find('_64') >= 0;
476
477 def is64bitRequired(self):
478 """ Check if 64-bit is required or not. """
479 return (self.aInfo[g_iFlags] & g_k64) != 0;
480
481 def isLoggedOntoDesktop(self):
482 """ Checks if the test VM is logging onto a graphical desktop by default. """
483 if self.isWindows():
484 return True;
485 if self.isOS2():
486 return True;
487 if self.sVmName.find('-desktop'):
488 return True;
489 return False;
490
491 def isViaIncompatible(self):
492 """
493 Identifies VMs that doesn't work on VIA.
494
495 Returns True if NOT supported on VIA, False if it IS supported.
496 """
497 # Oracle linux doesn't like VIA in our experience
498 if self.aInfo[g_iKind] in ['Oracle', 'Oracle_64']:
499 return True;
500 # OS/2: "The system detected an internal processing error at location
501 # 0168:fff1da1f - 000e:ca1f. 0a8606fd
502 if self.isOS2():
503 return True;
504 # Windows NT4 before SP4 won't work because of cmpxchg8b not being
505 # detected, leading to a STOP 3e(80,0,0,0).
506 if self.aInfo[g_iKind] == 'WindowsNT4':
507 if self.sVmName.find('sp') < 0:
508 return True; # no service pack.
509 if self.sVmName.find('sp0') >= 0 \
510 or self.sVmName.find('sp1') >= 0 \
511 or self.sVmName.find('sp2') >= 0 \
512 or self.sVmName.find('sp3') >= 0:
513 return True;
514 # XP x64 on a physical VIA box hangs exactly like a VM.
515 if self.aInfo[g_iKind] in ['WindowsXP_64', 'Windows2003_64']:
516 return True;
517 # Vista 64 throws BSOD 0x5D (UNSUPPORTED_PROCESSOR)
518 if self.aInfo[g_iKind] in ['WindowsVista_64']:
519 return True;
520 # Solaris 11 hangs on VIA, tested on a physical box (testboxvqc)
521 if self.aInfo[g_iKind] in ['Solaris11_64']:
522 return True;
523 return False;
524
525 def isShanghaiIncompatible(self):
526 """
527 Identifies VMs that doesn't work on Shanghai.
528
529 Returns True if NOT supported on Shanghai, False if it IS supported.
530 """
531 # For now treat it just like VIA, to be adjusted later
532 return self.isViaIncompatible()
533
534 def isP4Incompatible(self):
535 """
536 Identifies VMs that doesn't work on Pentium 4 / Pentium D.
537
538 Returns True if NOT supported on P4, False if it IS supported.
539 """
540 # Stupid 1 kHz timer. Too much for antique CPUs.
541 if self.sVmName.find('rhel5') >= 0:
542 return True;
543 # Due to the boot animation the VM takes forever to boot.
544 if self.aInfo[g_iKind] == 'Windows2000':
545 return True;
546 return False;
547
548 def isHostCpuAffectedByUbuntuNewAmdBug(self, oTestDrv):
549 """
550 Checks if the host OS is affected by older ubuntu installers being very
551 picky about which families of AMD CPUs it would run on.
552
553 The installer checks for family 15, later 16, later 20, and in 11.10
554 they remove the family check for AMD CPUs.
555 """
556 if not oTestDrv.isHostCpuAmd():
557 return False;
558 try:
559 (uMaxExt, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000000, 0);
560 (uFamilyModel, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000001, 0);
561 except:
562 reporter.logXcpt();
563 return False;
564 if uMaxExt < 0x80000001 or uMaxExt > 0x8000ffff:
565 return False;
566
567 uFamily = (uFamilyModel >> 8) & 0xf
568 if uFamily == 0xf:
569 uFamily = ((uFamilyModel >> 20) & 0x7f) + 0xf;
570 ## @todo Break this down into which old ubuntu release supports exactly
571 ## which AMD family, if we care.
572 if uFamily <= 15:
573 return False;
574 reporter.log('Skipping "%s" because host CPU is a family %u AMD, which may cause trouble for the guest OS installer.'
575 % (self.sVmName, uFamily,));
576 return True;
577
578
579## @todo Inherit from BaseTestVm
580class TestVm(object):
581 """
582 A Test VM - name + VDI/whatever.
583
584 This is just a data object.
585 """
586
587 def __init__(self, # pylint: disable=R0913
588 sVmName, # type: str
589 fGrouping = 0, # type: int
590 oSet = None, # type: TestVmSet
591 sHd = None, # type: str
592 sKind = None, # type: str
593 acCpusSup = None, # type: List[int]
594 asVirtModesSup = None, # type: List[str]
595 fIoApic = None, # type: bool
596 fNstHwVirt = False, # type: bool
597 fPae = None, # type: bool
598 sNic0AttachType = None, # type: str
599 sFloppy = None, # type: str
600 fVmmDevTestingPart = None, # type: bool
601 fVmmDevTestingMmio = False, # type: bool
602 asParavirtModesSup = None, # type: List[str]
603 fRandomPvPMode = False, # type: bool
604 sFirmwareType = 'bios', # type: str
605 sChipsetType = 'piix3', # type: str
606 sHddControllerType = 'IDE Controller', # type: str
607 sDvdControllerType = 'IDE Controller' # type: str
608 ):
609 self.oSet = oSet;
610 self.sVmName = sVmName;
611 self.fGrouping = fGrouping;
612 self.sHd = sHd; # Relative to the testrsrc root.
613 self.acCpusSup = acCpusSup;
614 self.asVirtModesSup = asVirtModesSup;
615 self.asParavirtModesSup = asParavirtModesSup;
616 self.asParavirtModesSupOrg = asParavirtModesSup; # HACK ALERT! Trick to make the 'effing random mess not get in the
617 # way of actively selecting virtualization modes.
618 self.sKind = sKind;
619 self.sGuestOsType = None;
620 self.sDvdImage = None; # Relative to the testrsrc root.
621 self.sDvdControllerType = sDvdControllerType;
622 self.fIoApic = fIoApic;
623 self.fNstHwVirt = fNstHwVirt;
624 self.fPae = fPae;
625 self.sNic0AttachType = sNic0AttachType;
626 self.sHddControllerType = sHddControllerType;
627 self.sFloppy = sFloppy; # Relative to the testrsrc root, except when it isn't...
628 self.fVmmDevTestingPart = fVmmDevTestingPart;
629 self.fVmmDevTestingMmio = fVmmDevTestingMmio;
630 self.sFirmwareType = sFirmwareType;
631 self.sChipsetType = sChipsetType;
632 self.fCom1RawFile = False;
633
634 self.fSnapshotRestoreCurrent = False; # Whether to restore execution on the current snapshot.
635 self.fSkip = False; # All VMs are included in the configured set by default.
636 self.aInfo = None;
637 self.sCom1RawFile = None; # Set by createVmInner and getReconfiguredVm if fCom1RawFile is set.
638 self._guessStuff(fRandomPvPMode);
639
640 def _mkCanonicalGuestOSType(self, sType):
641 """
642 Convert guest OS type into constant representation.
643 Raise exception if specified @param sType is unknown.
644 """
645 if sType.lower().startswith('darwin'):
646 return g_ksGuestOsTypeDarwin
647 if sType.lower().startswith('bsd'):
648 return g_ksGuestOsTypeFreeBSD
649 if sType.lower().startswith('dos'):
650 return g_ksGuestOsTypeDOS
651 if sType.lower().startswith('linux'):
652 return g_ksGuestOsTypeLinux
653 if sType.lower().startswith('os2'):
654 return g_ksGuestOsTypeOS2
655 if sType.lower().startswith('solaris'):
656 return g_ksGuestOsTypeSolaris
657 if sType.lower().startswith('windows'):
658 return g_ksGuestOsTypeWindows
659 raise base.GenError(sWhat="unknown guest OS kind: %s" % str(sType))
660
661 def _guessStuff(self, fRandomPvPMode):
662 """
663 Used by the constructor to guess stuff.
664 """
665
666 sNm = self.sVmName.lower().strip();
667 asSplit = sNm.replace('-', ' ').split(' ');
668
669 if self.sKind is None:
670 # From name.
671 for aInfo in g_aaNameToDetails:
672 if _intersects(asSplit, aInfo[g_iRegEx]):
673 self.aInfo = aInfo;
674 self.sGuestOsType = self._mkCanonicalGuestOSType(aInfo[g_iGuestOsType])
675 self.sKind = aInfo[g_iKind];
676 break;
677 if self.sKind is None:
678 reporter.fatal('The OS of test VM "%s" cannot be guessed' % (self.sVmName,));
679
680 # Check for 64-bit, if required and supported.
681 if (self.aInfo[g_iFlags] & g_kiArchMask) == g_k32_64 and _intersects(asSplit, ['64', 'amd64']):
682 self.sKind = self.sKind + '_64';
683 else:
684 # Lookup the kind.
685 for aInfo in g_aaNameToDetails:
686 if self.sKind == aInfo[g_iKind]:
687 self.aInfo = aInfo;
688 break;
689 if self.aInfo is None:
690 reporter.fatal('The OS of test VM "%s" with sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
691
692 # Translate sKind into sGuest OS Type.
693 if self.sGuestOsType is None:
694 if self.aInfo is not None:
695 self.sGuestOsType = self._mkCanonicalGuestOSType(self.aInfo[g_iGuestOsType])
696 elif self.sKind.find("Windows") >= 0:
697 self.sGuestOsType = g_ksGuestOsTypeWindows
698 elif self.sKind.find("Linux") >= 0:
699 self.sGuestOsType = g_ksGuestOsTypeLinux;
700 elif self.sKind.find("Solaris") >= 0:
701 self.sGuestOsType = g_ksGuestOsTypeSolaris;
702 elif self.sKind.find("DOS") >= 0:
703 self.sGuestOsType = g_ksGuestOsTypeDOS;
704 else:
705 reporter.fatal('The OS of test VM "%s", sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
706
707 # Restrict modes and such depending on the OS.
708 if self.asVirtModesSup is None:
709 self.asVirtModesSup = list(g_asVirtModes);
710 if self.sGuestOsType in (g_ksGuestOsTypeOS2, g_ksGuestOsTypeDarwin) \
711 or self.sKind.find('_64') > 0 \
712 or (self.aInfo is not None and (self.aInfo[g_iFlags] & g_kiNoRaw)):
713 self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
714 # TEMPORARY HACK - START
715 sHostName = os.environ.get("COMPUTERNAME", None);
716 if sHostName: sHostName = sHostName.lower();
717 else: sHostName = socket.getfqdn(); # Horribly slow on windows without IPv6 DNS/whatever.
718 if sHostName.startswith('testboxpile1'):
719 self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
720 # TEMPORARY HACK - END
721
722 # Restrict the CPU count depending on the OS and/or percieved SMP readiness.
723 if self.acCpusSup is None:
724 if _intersects(asSplit, ['uni']):
725 self.acCpusSup = [1];
726 elif self.aInfo is not None:
727 self.acCpusSup = [i for i in range(self.aInfo[g_iMinCpu], self.aInfo[g_iMaxCpu]) ];
728 else:
729 self.acCpusSup = [1];
730
731 # Figure relevant PV modes based on the OS.
732 if self.asParavirtModesSup is None:
733 self.asParavirtModesSup = g_kdaParavirtProvidersSupported[self.sGuestOsType];
734 ## @todo Remove this hack as soon as we've got around to explictly configure test variations
735 ## on the server side. Client side random is interesting but not the best option.
736 self.asParavirtModesSupOrg = self.asParavirtModesSup;
737 if fRandomPvPMode:
738 random.seed();
739 self.asParavirtModesSup = (random.choice(self.asParavirtModesSup),);
740
741 return True;
742
743 def getNonCanonicalGuestOsType(self):
744 """
745 Gets the non-canonical OS type (self.sGuestOsType is canonical).
746 """
747 return self.aInfo[g_iGuestOsType];
748
749 def getMissingResources(self, sTestRsrc):
750 """
751 Returns a list of missing resources (paths, stuff) that the VM needs.
752 """
753 asRet = [];
754 for sPath in [ self.sHd, self.sDvdImage, self.sFloppy]:
755 if sPath is not None:
756 if not os.path.isabs(sPath):
757 sPath = os.path.join(sTestRsrc, sPath);
758 if not os.path.exists(sPath):
759 asRet.append(sPath);
760 return asRet;
761
762 def createVm(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
763 """
764 Creates the VM with defaults and the few tweaks as per the arguments.
765
766 Returns same as vbox.TestDriver.createTestVM.
767 """
768 if sDvdImage is not None:
769 sMyDvdImage = sDvdImage;
770 else:
771 sMyDvdImage = self.sDvdImage;
772
773 if eNic0AttachType is not None:
774 eMyNic0AttachType = eNic0AttachType;
775 elif self.sNic0AttachType is None:
776 eMyNic0AttachType = None;
777 elif self.sNic0AttachType == 'nat':
778 eMyNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
779 elif self.sNic0AttachType == 'bridged':
780 eMyNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
781 else:
782 assert False, self.sNic0AttachType;
783
784 return self.createVmInner(oTestDrv, eMyNic0AttachType, sMyDvdImage);
785
786 def _generateRawPortFilename(self, oTestDrv, sInfix, sSuffix):
787 """ Generates a raw port filename. """
788 random.seed();
789 sRandom = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10));
790 return os.path.join(oTestDrv.sScratchPath, self.sVmName + sInfix + sRandom + sSuffix);
791
792 def createVmInner(self, oTestDrv, eNic0AttachType, sDvdImage):
793 """
794 Same as createVm but parameters resolved.
795
796 Returns same as vbox.TestDriver.createTestVM.
797 """
798 reporter.log2('');
799 reporter.log2('Calling createTestVM on %s...' % (self.sVmName,))
800 if self.fCom1RawFile:
801 self.sCom1RawFile = self._generateRawPortFilename(oTestDrv, '-com1-', '.out');
802 return oTestDrv.createTestVM(self.sVmName,
803 1, # iGroup
804 sHd = self.sHd,
805 sKind = self.sKind,
806 fIoApic = self.fIoApic,
807 fNstHwVirt = self.fNstHwVirt,
808 fPae = self.fPae,
809 eNic0AttachType = eNic0AttachType,
810 sDvdImage = sDvdImage,
811 sDvdControllerType = self.sDvdControllerType,
812 sHddControllerType = self.sHddControllerType,
813 sFloppy = self.sFloppy,
814 fVmmDevTestingPart = self.fVmmDevTestingPart,
815 fVmmDevTestingMmio = self.fVmmDevTestingPart,
816 sFirmwareType = self.sFirmwareType,
817 sChipsetType = self.sChipsetType,
818 sCom1RawFile = self.sCom1RawFile if self.fCom1RawFile else None
819 );
820
821 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
822 """
823 actionExecute worker that finds and reconfigure a test VM.
824
825 Returns (fRc, oVM) where fRc is True, None or False and oVM is a
826 VBox VM object that is only present when rc is True.
827 """
828
829 fRc = False;
830 oVM = oTestDrv.getVmByName(self.sVmName);
831 if oVM is not None:
832 if self.fSnapshotRestoreCurrent is True:
833 fRc = True;
834 else:
835 fHostSupports64bit = oTestDrv.hasHostLongMode();
836 if self.is64bitRequired() and not fHostSupports64bit:
837 fRc = None; # Skip the test.
838 elif self.isViaIncompatible() and oTestDrv.isHostCpuVia():
839 fRc = None; # Skip the test.
840 elif self.isShanghaiIncompatible() and oTestDrv.isHostCpuShanghai():
841 fRc = None; # Skip the test.
842 elif self.isP4Incompatible() and oTestDrv.isHostCpuP4():
843 fRc = None; # Skip the test.
844 else:
845 oSession = oTestDrv.openSession(oVM);
846 if oSession is not None:
847 fRc = oSession.enableVirtEx(sVirtMode != 'raw');
848 fRc = fRc and oSession.enableNestedPaging(sVirtMode == 'hwvirt-np');
849 fRc = fRc and oSession.setCpuCount(cCpus);
850 if cCpus > 1:
851 fRc = fRc and oSession.enableIoApic(True);
852
853 if sParavirtMode is not None and oSession.fpApiVer >= 5.0:
854 adParavirtProviders = {
855 g_ksParavirtProviderNone : vboxcon.ParavirtProvider_None,
856 g_ksParavirtProviderDefault: vboxcon.ParavirtProvider_Default,
857 g_ksParavirtProviderLegacy : vboxcon.ParavirtProvider_Legacy,
858 g_ksParavirtProviderMinimal: vboxcon.ParavirtProvider_Minimal,
859 g_ksParavirtProviderHyperV : vboxcon.ParavirtProvider_HyperV,
860 g_ksParavirtProviderKVM : vboxcon.ParavirtProvider_KVM,
861 };
862 fRc = fRc and oSession.setParavirtProvider(adParavirtProviders[sParavirtMode]);
863
864 fCfg64Bit = self.is64bitRequired() or (self.is64bit() and fHostSupports64bit and sVirtMode != 'raw');
865 fRc = fRc and oSession.enableLongMode(fCfg64Bit);
866 if fCfg64Bit: # This is to avoid GUI pedantic warnings in the GUI. Sigh.
867 oOsType = oSession.getOsType();
868 if oOsType is not None:
869 if oOsType.is64Bit and sVirtMode == 'raw':
870 assert(oOsType.id[-3:] == '_64');
871 fRc = fRc and oSession.setOsType(oOsType.id[:-3]);
872 elif not oOsType.is64Bit and sVirtMode != 'raw':
873 fRc = fRc and oSession.setOsType(oOsType.id + '_64');
874
875 # New serial raw file.
876 if fRc and self.fCom1RawFile:
877 self.sCom1RawFile = self._generateRawPortFilename(oTestDrv, '-com1-', '.out');
878 utils.noxcptDeleteFile(self.sCom1RawFile);
879 fRc = oSession.setupSerialToRawFile(0, self.sCom1RawFile);
880
881 # Make life simpler for child classes.
882 if fRc:
883 fRc = self._childVmReconfig(oTestDrv, oVM, oSession);
884
885 fRc = fRc and oSession.saveSettings();
886 if not oSession.close():
887 fRc = False;
888 if fRc is True:
889 return (True, oVM);
890 return (fRc, None);
891
892 def _childVmReconfig(self, oTestDrv, oVM, oSession):
893 """ Hook into getReconfiguredVm() for children. """
894 _ = oTestDrv; _ = oVM; _ = oSession;
895 return True;
896
897 def isWindows(self):
898 """ Checks if it's a Windows VM. """
899 return self.sGuestOsType == g_ksGuestOsTypeWindows;
900
901 def isOS2(self):
902 """ Checks if it's an OS/2 VM. """
903 return self.sGuestOsType == g_ksGuestOsTypeOS2;
904
905 def isLinux(self):
906 """ Checks if it's an Linux VM. """
907 return self.sGuestOsType == g_ksGuestOsTypeLinux;
908
909 def is64bit(self):
910 """ Checks if it's a 64-bit VM. """
911 return self.sKind.find('_64') >= 0;
912
913 def is64bitRequired(self):
914 """ Check if 64-bit is required or not. """
915 return (self.aInfo[g_iFlags] & g_k64) != 0;
916
917 def isLoggedOntoDesktop(self):
918 """ Checks if the test VM is logging onto a graphical desktop by default. """
919 if self.isWindows():
920 return True;
921 if self.isOS2():
922 return True;
923 if self.sVmName.find('-desktop'):
924 return True;
925 return False;
926
927 def isViaIncompatible(self):
928 """
929 Identifies VMs that doesn't work on VIA.
930
931 Returns True if NOT supported on VIA, False if it IS supported.
932 """
933 # Oracle linux doesn't like VIA in our experience
934 if self.aInfo[g_iKind] in ['Oracle', 'Oracle_64']:
935 return True;
936 # OS/2: "The system detected an internal processing error at location
937 # 0168:fff1da1f - 000e:ca1f. 0a8606fd
938 if self.isOS2():
939 return True;
940 # Windows NT4 before SP4 won't work because of cmpxchg8b not being
941 # detected, leading to a STOP 3e(80,0,0,0).
942 if self.aInfo[g_iKind] == 'WindowsNT4':
943 if self.sVmName.find('sp') < 0:
944 return True; # no service pack.
945 if self.sVmName.find('sp0') >= 0 \
946 or self.sVmName.find('sp1') >= 0 \
947 or self.sVmName.find('sp2') >= 0 \
948 or self.sVmName.find('sp3') >= 0:
949 return True;
950 # XP x64 on a physical VIA box hangs exactly like a VM.
951 if self.aInfo[g_iKind] in ['WindowsXP_64', 'Windows2003_64']:
952 return True;
953 # Vista 64 throws BSOD 0x5D (UNSUPPORTED_PROCESSOR)
954 if self.aInfo[g_iKind] in ['WindowsVista_64']:
955 return True;
956 # Solaris 11 hangs on VIA, tested on a physical box (testboxvqc)
957 if self.aInfo[g_iKind] in ['Solaris11_64']:
958 return True;
959 return False;
960
961 def isShanghaiIncompatible(self):
962 """
963 Identifies VMs that doesn't work on Shanghai.
964
965 Returns True if NOT supported on Shanghai, False if it IS supported.
966 """
967 # For now treat it just like VIA, to be adjusted later
968 return self.isViaIncompatible()
969
970 def isP4Incompatible(self):
971 """
972 Identifies VMs that doesn't work on Pentium 4 / Pentium D.
973
974 Returns True if NOT supported on P4, False if it IS supported.
975 """
976 # Stupid 1 kHz timer. Too much for antique CPUs.
977 if self.sVmName.find('rhel5') >= 0:
978 return True;
979 # Due to the boot animation the VM takes forever to boot.
980 if self.aInfo[g_iKind] == 'Windows2000':
981 return True;
982 return False;
983
984 def isHostCpuAffectedByUbuntuNewAmdBug(self, oTestDrv):
985 """
986 Checks if the host OS is affected by older ubuntu installers being very
987 picky about which families of AMD CPUs it would run on.
988
989 The installer checks for family 15, later 16, later 20, and in 11.10
990 they remove the family check for AMD CPUs.
991 """
992 if not oTestDrv.isHostCpuAmd():
993 return False;
994 try:
995 (uMaxExt, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000000, 0);
996 (uFamilyModel, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000001, 0);
997 except:
998 reporter.logXcpt();
999 return False;
1000 if uMaxExt < 0x80000001 or uMaxExt > 0x8000ffff:
1001 return False;
1002
1003 uFamily = (uFamilyModel >> 8) & 0xf
1004 if uFamily == 0xf:
1005 uFamily = ((uFamilyModel >> 20) & 0x7f) + 0xf;
1006 ## @todo Break this down into which old ubuntu release supports exactly
1007 ## which AMD family, if we care.
1008 if uFamily <= 15:
1009 return False;
1010 reporter.log('Skipping "%s" because host CPU is a family %u AMD, which may cause trouble for the guest OS installer.'
1011 % (self.sVmName, uFamily,));
1012 return True;
1013
1014
1015class BootSectorTestVm(TestVm):
1016 """
1017 A Boot Sector Test VM.
1018 """
1019
1020 def __init__(self, oSet, sVmName, sFloppy = None, asVirtModesSup = None, f64BitRequired = False):
1021 self.f64BitRequired = f64BitRequired;
1022 if asVirtModesSup is None:
1023 asVirtModesSup = list(g_asVirtModes);
1024 TestVm.__init__(self, sVmName,
1025 oSet = oSet,
1026 acCpusSup = [1,],
1027 sFloppy = sFloppy,
1028 asVirtModesSup = asVirtModesSup,
1029 fPae = True,
1030 fIoApic = True,
1031 fVmmDevTestingPart = True,
1032 fVmmDevTestingMmio = True,
1033 );
1034
1035 def is64bitRequired(self):
1036 return self.f64BitRequired;
1037
1038
1039class AncientTestVm(TestVm):
1040 """
1041 A ancient Test VM, using the serial port for communicating results.
1042
1043 We're looking for 'PASSED' and 'FAILED' lines in the COM1 output.
1044 """
1045
1046
1047 def __init__(self, # pylint: disable=R0913
1048 sVmName, # type: str
1049 fGrouping = g_kfGrpAncient | g_kfGrpNoTxs, # type: int
1050 sHd = None, # type: str
1051 sKind = None, # type: str
1052 acCpusSup = None, # type: List[int]
1053 asVirtModesSup = None, # type: List[str]
1054 sNic0AttachType = None, # type: str
1055 sFloppy = None, # type: str
1056 sFirmwareType = 'bios', # type: str
1057 sChipsetType = 'piix3', # type: str
1058 sHddControllerName = 'IDE Controller', # type: str
1059 sDvdControllerName = 'IDE Controller', # type: str
1060 cMBRamMax = None, # type: int
1061 ):
1062 TestVm.__init__(self,
1063 sVmName,
1064 fGrouping = fGrouping,
1065 sHd = sHd,
1066 sKind = sKind,
1067 acCpusSup = [1] if acCpusSup is None else acCpusSup,
1068 asVirtModesSup = asVirtModesSup,
1069 sNic0AttachType = sNic0AttachType,
1070 sFloppy = sFloppy,
1071 sFirmwareType = sFirmwareType,
1072 sChipsetType = sChipsetType,
1073 sHddControllerType = sHddControllerName,
1074 sDvdControllerType = sDvdControllerName,
1075 asParavirtModesSup = (g_ksParavirtProviderNone,)
1076 );
1077 self.fCom1RawFile = True;
1078 self.cMBRamMax= cMBRamMax;
1079
1080
1081 def _childVmReconfig(self, oTestDrv, oVM, oSession):
1082 _ = oVM; _ = oTestDrv;
1083 fRc = True;
1084
1085 # DOS 4.01 doesn't like the default 32MB of memory.
1086 if fRc and self.cMBRamMax is not None:
1087 try:
1088 cMBRam = oSession.o.machine.memorySize;
1089 except:
1090 cMBRam = self.cMBRamMax + 4;
1091 if self.cMBRamMax < cMBRam:
1092 fRc = oSession.setRamSize(self.cMBRamMax);
1093
1094 return fRc;
1095
1096
1097class TestVmSet(object):
1098 """
1099 A set of Test VMs.
1100 """
1101
1102 def __init__(self, oTestVmManager = None, acCpus = None, asVirtModes = None, fIgnoreSkippedVm = False):
1103 self.oTestVmManager = oTestVmManager;
1104 if acCpus is None:
1105 acCpus = [1, 2];
1106 self.acCpusDef = acCpus;
1107 self.acCpus = acCpus;
1108 if asVirtModes is None:
1109 asVirtModes = list(g_asVirtModes);
1110 self.asVirtModesDef = asVirtModes;
1111 self.asVirtModes = asVirtModes;
1112 self.aoTestVms = [] # type: list(BaseTestVm)
1113 self.fIgnoreSkippedVm = fIgnoreSkippedVm;
1114 self.asParavirtModes = None; ##< If None, use the first PV mode of the test VM, otherwise all modes in this list.
1115
1116 def findTestVmByName(self, sVmName):
1117 """
1118 Returns the TestVm object with the given name.
1119 Returns None if not found.
1120 """
1121
1122 # The 'tst-' prefix is optional.
1123 sAltName = sVmName if sVmName.startswith('tst-') else 'tst-' + sVmName;
1124
1125 for oTestVm in self.aoTestVms:
1126 if oTestVm.sVmName == sVmName or oTestVm.sVmName == sAltName:
1127 return oTestVm;
1128 return None;
1129
1130 def getAllVmNames(self, sSep = ':'):
1131 """
1132 Returns names of all the test VMs in the set separated by
1133 sSep (defaults to ':').
1134 """
1135 sVmNames = '';
1136 for oTestVm in self.aoTestVms:
1137 sName = oTestVm.sVmName;
1138 if sName.startswith('tst-'):
1139 sName = sName[4:];
1140 if sVmNames == '':
1141 sVmNames = sName;
1142 else:
1143 sVmNames = sVmNames + sSep + sName;
1144 return sVmNames;
1145
1146 def showUsage(self):
1147 """
1148 Invoked by vbox.TestDriver.
1149 """
1150 reporter.log('');
1151 reporter.log('Test VM selection and general config options:');
1152 reporter.log(' --virt-modes <m1[:m2[:...]]>');
1153 reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
1154 reporter.log(' --skip-virt-modes <m1[:m2[:...]]>');
1155 reporter.log(' Use this to avoid hwvirt or hwvirt-np when not supported by the host');
1156 reporter.log(' since we cannot detect it using the main API. Use after --virt-modes.');
1157 reporter.log(' --cpu-counts <c1[:c2[:...]]>');
1158 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
1159 reporter.log(' --test-vms <vm1[:vm2[:...]]>');
1160 reporter.log(' Test the specified VMs in the given order. Use this to change');
1161 reporter.log(' the execution order or limit the choice of VMs');
1162 reporter.log(' Default: %s (all)' % (self.getAllVmNames(),));
1163 reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
1164 reporter.log(' Skip the specified VMs when testing.');
1165 reporter.log(' --snapshot-restore-current');
1166 reporter.log(' Restores the current snapshot and resumes execution.');
1167 reporter.log(' --paravirt-modes <pv1[:pv2[:...]]>');
1168 reporter.log(' Set of paravirtualized providers (modes) to tests. Intersected with what the test VM supports.');
1169 reporter.log(' Default is the first PV mode the test VMs support, generally same as "legacy".');
1170 reporter.log(' --with-nested-hwvirt-only');
1171 reporter.log(' Test VMs using nested hardware-virtualization only.');
1172 reporter.log(' --without-nested-hwvirt-only');
1173 reporter.log(' Test VMs not using nested hardware-virtualization only.');
1174 ## @todo Add more options for controlling individual VMs.
1175 return True;
1176
1177 def parseOption(self, asArgs, iArg):
1178 """
1179 Parses the set test vm set options (--test-vms and --skip-vms), modifying the set
1180 Invoked by the testdriver method with the same name.
1181
1182 Keyword arguments:
1183 asArgs -- The argument vector.
1184 iArg -- The index of the current argument.
1185
1186 Returns iArg if the option was not recognized and the caller should handle it.
1187 Returns the index of the next argument when something is consumed.
1188
1189 In the event of a syntax error, a InvalidOption or QuietInvalidOption
1190 is thrown.
1191 """
1192
1193 if asArgs[iArg] == '--virt-modes':
1194 iArg += 1;
1195 if iArg >= len(asArgs):
1196 raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
1197
1198 self.asVirtModes = asArgs[iArg].split(':');
1199 for s in self.asVirtModes:
1200 if s not in self.asVirtModesDef:
1201 raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
1202 % (s, ' '.join(self.asVirtModesDef)));
1203
1204 elif asArgs[iArg] == '--skip-virt-modes':
1205 iArg += 1;
1206 if iArg >= len(asArgs):
1207 raise base.InvalidOption('The "--skip-virt-modes" takes a colon separated list of modes');
1208
1209 for s in asArgs[iArg].split(':'):
1210 if s not in self.asVirtModesDef:
1211 raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
1212 % (s, ' '.join(self.asVirtModesDef)));
1213 if s in self.asVirtModes:
1214 self.asVirtModes.remove(s);
1215
1216 elif asArgs[iArg] == '--cpu-counts':
1217 iArg += 1;
1218 if iArg >= len(asArgs):
1219 raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
1220
1221 self.acCpus = [];
1222 for s in asArgs[iArg].split(':'):
1223 try: c = int(s);
1224 except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
1225 if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
1226 self.acCpus.append(c);
1227
1228 elif asArgs[iArg] == '--test-vms':
1229 iArg += 1;
1230 if iArg >= len(asArgs):
1231 raise base.InvalidOption('The "--test-vms" takes colon separated list');
1232
1233 for oTestVm in self.aoTestVms:
1234 oTestVm.fSkip = True;
1235
1236 asTestVMs = asArgs[iArg].split(':');
1237 for s in asTestVMs:
1238 oTestVm = self.findTestVmByName(s);
1239 if oTestVm is None:
1240 raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
1241 % (s, self.getAllVmNames(' ')));
1242 oTestVm.fSkip = False;
1243
1244 elif asArgs[iArg] == '--skip-vms':
1245 iArg += 1;
1246 if iArg >= len(asArgs):
1247 raise base.InvalidOption('The "--skip-vms" takes colon separated list');
1248
1249 asTestVMs = asArgs[iArg].split(':');
1250 for s in asTestVMs:
1251 oTestVm = self.findTestVmByName(s);
1252 if oTestVm is None:
1253 reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s,));
1254 else:
1255 oTestVm.fSkip = True;
1256
1257 elif asArgs[iArg] == '--snapshot-restore-current':
1258 for oTestVm in self.aoTestVms:
1259 if oTestVm.fSkip is False:
1260 oTestVm.fSnapshotRestoreCurrent = True;
1261 reporter.log('VM "%s" will be restored.' % (oTestVm.sVmName));
1262
1263 elif asArgs[iArg] == '--paravirt-modes':
1264 iArg += 1
1265 if iArg >= len(asArgs):
1266 raise base.InvalidOption('The "--paravirt-modes" takes a colon separated list of modes');
1267
1268 self.asParavirtModes = asArgs[iArg].split(':')
1269 for sPvMode in self.asParavirtModes:
1270 if sPvMode not in g_kasParavirtProviders:
1271 raise base.InvalidOption('The "--paravirt-modes" value "%s" is not valid; valid values are: %s'
1272 % (sPvMode, ', '.join(g_kasParavirtProviders),));
1273 if not self.asParavirtModes:
1274 self.asParavirtModes = None;
1275
1276 # HACK ALERT! Reset the random paravirt selection for members.
1277 for oTestVm in self.aoTestVms:
1278 oTestVm.asParavirtModesSup = oTestVm.asParavirtModesSupOrg;
1279
1280 elif asArgs[iArg] == '--with-nested-hwvirt-only':
1281 for oTestVm in self.aoTestVms:
1282 if oTestVm.fNstHwVirt is False:
1283 oTestVm.fSkip = True;
1284
1285 elif asArgs[iArg] == '--without-nested-hwvirt-only':
1286 for oTestVm in self.aoTestVms:
1287 if oTestVm.fNstHwVirt is True:
1288 oTestVm.fSkip = True;
1289
1290 else:
1291 return iArg;
1292 return iArg + 1;
1293
1294 def getResourceSet(self):
1295 """
1296 Implements base.TestDriver.getResourceSet
1297 """
1298 asResources = [];
1299 for oTestVm in self.aoTestVms:
1300 if not oTestVm.fSkip:
1301 if oTestVm.sHd is not None:
1302 asResources.append(oTestVm.sHd);
1303 if oTestVm.sDvdImage is not None:
1304 asResources.append(oTestVm.sDvdImage);
1305 return asResources;
1306
1307 def actionConfig(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
1308 """
1309 For base.TestDriver.actionConfig. Configure the VMs with defaults and
1310 a few tweaks as per arguments.
1311
1312 Returns True if successful.
1313 Returns False if not.
1314 """
1315
1316 for oTestVm in self.aoTestVms:
1317 if oTestVm.fSkip:
1318 continue;
1319
1320 if oTestVm.fSnapshotRestoreCurrent:
1321 # If we want to restore a VM we don't need to create
1322 # the machine anymore -- so just add it to the test VM list.
1323 oVM = oTestDrv.addTestMachine(oTestVm.sVmName);
1324 else:
1325 oVM = oTestVm.createVm(oTestDrv, eNic0AttachType, sDvdImage);
1326 if oVM is None:
1327 return False;
1328
1329 return True;
1330
1331 def _removeUnsupportedVirtModes(self, oTestDrv):
1332 """
1333 Removes unsupported virtualization modes.
1334 """
1335 if 'hwvirt' in self.asVirtModes and not oTestDrv.hasHostHwVirt():
1336 reporter.log('Hardware assisted virtualization is not available on the host, skipping it.');
1337 self.asVirtModes.remove('hwvirt');
1338
1339 if 'hwvirt-np' in self.asVirtModes and not oTestDrv.hasHostNestedPaging():
1340 reporter.log('Nested paging not supported by the host, skipping it.');
1341 self.asVirtModes.remove('hwvirt-np');
1342
1343 if 'raw' in self.asVirtModes and not oTestDrv.hasRawModeSupport():
1344 reporter.log('Raw-mode virtualization is not available in this build (or perhaps for this host), skipping it.');
1345 self.asVirtModes.remove('raw');
1346
1347 return True;
1348
1349 def actionExecute(self, oTestDrv, fnCallback): # pylint: disable=R0914
1350 """
1351 For base.TestDriver.actionExecute. Calls the callback function for
1352 each of the VMs and basic configuration variations (virt-mode and cpu
1353 count).
1354
1355 Returns True if all fnCallback calls returned True, otherwise False.
1356
1357 The callback can return True, False or None. The latter is for when the
1358 test is skipped. (True is for success, False is for failure.)
1359 """
1360
1361 self._removeUnsupportedVirtModes(oTestDrv);
1362 cMaxCpus = oTestDrv.getHostCpuCount();
1363
1364 #
1365 # The test loop.
1366 #
1367 fRc = True;
1368 for oTestVm in self.aoTestVms:
1369 if oTestVm.fNstHwVirt and not oTestDrv.isHostCpuAmd():
1370 reporter.log('Ignoring VM %s (Nested hardware-virtualization only supported on AMD CPUs).' % (oTestVm.sVmName,));
1371 continue;
1372 if oTestVm.fSkip and self.fIgnoreSkippedVm:
1373 reporter.log2('Ignoring VM %s (fSkip = True).' % (oTestVm.sVmName,));
1374 continue;
1375 reporter.testStart(oTestVm.sVmName);
1376 if oTestVm.fSkip:
1377 reporter.testDone(fSkipped = True);
1378 continue;
1379
1380 # Intersect the supported modes and the ones being testing.
1381 asVirtModesSup = [sMode for sMode in oTestVm.asVirtModesSup if sMode in self.asVirtModes];
1382
1383 # Ditto for CPUs.
1384 acCpusSup = [cCpus for cCpus in oTestVm.acCpusSup if cCpus in self.acCpus];
1385
1386 # Ditto for paravirtualization modes, except if not specified we got a less obvious default.
1387 if self.asParavirtModes is not None and oTestDrv.fpApiVer >= 5.0:
1388 asParavirtModes = [sPvMode for sPvMode in oTestVm.asParavirtModesSup if sPvMode in self.asParavirtModes];
1389 assert None not in asParavirtModes;
1390 elif oTestDrv.fpApiVer >= 5.0:
1391 asParavirtModes = (oTestVm.asParavirtModesSup[0],);
1392 assert asParavirtModes[0] is not None;
1393 else:
1394 asParavirtModes = (None,);
1395
1396 for cCpus in acCpusSup:
1397 if cCpus == 1:
1398 reporter.testStart('1 cpu');
1399 else:
1400 reporter.testStart('%u cpus' % (cCpus));
1401 if cCpus > cMaxCpus:
1402 reporter.testDone(fSkipped = True);
1403 continue;
1404
1405 cTests = 0;
1406 for sVirtMode in asVirtModesSup:
1407 if sVirtMode == 'raw' and cCpus > 1:
1408 continue;
1409 reporter.testStart('%s' % ( g_dsVirtModeDescs[sVirtMode], ) );
1410 cStartTests = cTests;
1411
1412 for sParavirtMode in asParavirtModes:
1413 if sParavirtMode is not None:
1414 assert oTestDrv.fpApiVer >= 5.0;
1415 reporter.testStart('%s' % ( sParavirtMode, ) );
1416
1417 # Reconfigure the VM.
1418 try:
1419 (rc2, oVM) = oTestVm.getReconfiguredVm(oTestDrv, cCpus, sVirtMode, sParavirtMode = sParavirtMode);
1420 except KeyboardInterrupt:
1421 raise;
1422 except:
1423 reporter.errorXcpt(cFrames = 9);
1424 rc2 = False;
1425 if rc2 is True:
1426 # Do the testing.
1427 try:
1428 rc2 = fnCallback(oVM, oTestVm);
1429 except KeyboardInterrupt:
1430 raise;
1431 except:
1432 reporter.errorXcpt(cFrames = 9);
1433 rc2 = False;
1434 if rc2 is False:
1435 reporter.maybeErr(reporter.testErrorCount() == 0, 'fnCallback failed');
1436 elif rc2 is False:
1437 reporter.log('getReconfiguredVm failed');
1438 if rc2 is False:
1439 fRc = False;
1440
1441 cTests = cTests + (rc2 is not None);
1442 if sParavirtMode is not None:
1443 reporter.testDone(fSkipped = (rc2 is None));
1444
1445 reporter.testDone(fSkipped = cTests == cStartTests);
1446
1447 reporter.testDone(fSkipped = cTests == 0);
1448
1449 _, cErrors = reporter.testDone();
1450 if cErrors > 0:
1451 fRc = False;
1452 return fRc;
1453
1454 def enumerateTestVms(self, fnCallback):
1455 """
1456 Enumerates all the 'active' VMs.
1457
1458 Returns True if all fnCallback calls returned True.
1459 Returns False if any returned False.
1460 Returns None immediately if fnCallback returned None.
1461 """
1462 fRc = True;
1463 for oTestVm in self.aoTestVms:
1464 if not oTestVm.fSkip:
1465 fRc2 = fnCallback(oTestVm);
1466 if fRc2 is None:
1467 return fRc2;
1468 fRc = fRc and fRc2;
1469 return fRc;
1470
1471
1472
1473class TestVmManager(object):
1474 """
1475 Test VM manager.
1476 """
1477
1478 ## @name VM grouping flags
1479 ## @{
1480 kfGrpSmoke = g_kfGrpSmoke;
1481 kfGrpStandard = g_kfGrpStandard;
1482 kfGrpStdSmoke = g_kfGrpStdSmoke;
1483 kfGrpWithGAs = g_kfGrpWithGAs;
1484 kfGrpNoTxs = g_kfGrpNoTxs;
1485 kfGrpAncient = g_kfGrpAncient;
1486 kfGrpExotic = g_kfGrpExotic;
1487 ## @}
1488
1489 kaTestVMs = (
1490 # Linux
1491 TestVm('tst-ubuntu-15_10-64-efi', kfGrpStdSmoke, sHd = '4.2/efi/ubuntu-15_10-efi-amd64.vdi',
1492 sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi',
1493 asParavirtModesSup = [g_ksParavirtProviderKVM,]),
1494 TestVm('tst-rhel5', kfGrpSmoke, sHd = '3.0/tcp/rhel5.vdi',
1495 sKind = 'RedHat', acCpusSup = range(1, 33), fIoApic = True, sNic0AttachType = 'nat'),
1496 TestVm('tst-arch', kfGrpStandard, sHd = '4.2/usb/tst-arch.vdi',
1497 sKind = 'ArchLinux_64', acCpusSup = range(1, 33), fIoApic = True, sNic0AttachType = 'nat'),
1498 # disabled 2019-03-08 klaus - fails all over the place and pollutes the test results
1499 #TestVm('tst-ubuntu-1804-64', kfGrpStdSmoke, sHd = '4.2/ubuntu-1804/t-ubuntu-1804-64.vdi',
1500 # sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True),
1501 TestVm('tst-ol76-64', kfGrpStdSmoke, sHd = '4.2/ol76/t-ol76-64.vdi',
1502 sKind = 'Oracle_64', acCpusSup = range(1, 33), fIoApic = True),
1503
1504 # Solaris
1505 TestVm('tst-sol10', kfGrpSmoke, sHd = '3.0/tcp/solaris10.vdi',
1506 sKind = 'Solaris', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged'),
1507 TestVm('tst-sol10-64', kfGrpSmoke, sHd = '3.0/tcp/solaris10.vdi',
1508 sKind = 'Solaris_64', acCpusSup = range(1, 33), sNic0AttachType = 'bridged'),
1509 TestVm('tst-sol11u1', kfGrpSmoke, sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
1510 sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat', fIoApic = True,
1511 sHddControllerType = 'SATA Controller'),
1512 #TestVm('tst-sol11u1-ich9', kfGrpSmoke, sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
1513 # sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat', fIoApic = True,
1514 # sHddControllerType = 'SATA Controller', sChipsetType = 'ich9'),
1515
1516 # NT 3.x
1517 TestVm('tst-nt310', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
1518 sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
1519 sDvdControllerType = 'BusLogic SCSI Controller'),
1520 TestVm('tst-nt350', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt350/t-nt350.vdi',
1521 sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
1522 sDvdControllerType = 'BusLogic SCSI Controller'),
1523 TestVm('tst-nt351', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt350/t-nt351.vdi',
1524 sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
1525 sDvdControllerType = 'BusLogic SCSI Controller'),
1526
1527 # NT 4
1528 TestVm('tst-nt4sp1', kfGrpStdSmoke, sHd = '4.2/nat/nt4sp1/t-nt4sp1.vdi',
1529 sKind = 'WindowsNT4', acCpusSup = [1], sNic0AttachType = 'nat'),
1530
1531 TestVm('tst-nt4sp6', kfGrpStdSmoke, sHd = '4.2/nt4sp6/t-nt4sp6.vdi',
1532 sKind = 'WindowsNT4', acCpusSup = range(1, 33)),
1533
1534 # W2K
1535 TestVm('tst-2ksp4', kfGrpStdSmoke, sHd = '4.2/win2ksp4/t-win2ksp4.vdi',
1536 sKind = 'Windows2000', acCpusSup = range(1, 33)),
1537
1538 # XP
1539 TestVm('tst-xppro', kfGrpStdSmoke, sHd = '4.2/nat/xppro/t-xppro.vdi',
1540 sKind = 'WindowsXP', acCpusSup = range(1, 33), sNic0AttachType = 'nat'),
1541 TestVm('tst-xpsp2', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxpsp2.vdi',
1542 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1543 TestVm('tst-xpsp2-halaacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halaacpi.vdi',
1544 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1545 TestVm('tst-xpsp2-halacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halacpi.vdi',
1546 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1547 TestVm('tst-xpsp2-halapic', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halapic.vdi',
1548 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1549 TestVm('tst-xpsp2-halmacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halmacpi.vdi',
1550 sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True),
1551 TestVm('tst-xpsp2-halmps', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halmps.vdi',
1552 sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True),
1553
1554 # W2K3
1555 TestVm('tst-win2k3ent', kfGrpSmoke, sHd = '3.0/tcp/win2k3ent-acpi.vdi',
1556 sKind = 'Windows2003', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged'),
1557
1558 # W7
1559 TestVm('tst-win7', kfGrpStdSmoke, sHd = '4.2/win7-32/t-win7.vdi',
1560 sKind = 'Windows7', acCpusSup = range(1, 33), fIoApic = True),
1561
1562 # W8
1563 TestVm('tst-win8-64', kfGrpStdSmoke, sHd = '4.2/win8-64/t-win8-64.vdi',
1564 sKind = 'Windows8_64', acCpusSup = range(1, 33), fIoApic = True),
1565 #TestVm('tst-win8-64-ich9', kfGrpStdSmoke, sHd = '4.2/win8-64/t-win8-64.vdi',
1566 # sKind = 'Windows8_64', acCpusSup = range(1, 33), fIoApic = True, sChipsetType = 'ich9'),
1567
1568 # W10
1569 TestVm('tst-win10-efi', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-x86.vdi',
1570 sKind = 'Windows10', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi'),
1571 TestVm('tst-win10-64-efi', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-amd64.vdi',
1572 sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi'),
1573 #TestVm('tst-win10-64-efi-ich9', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-amd64.vdi',
1574 # sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi', sChipsetType = 'ich9'),
1575
1576 # Nested hardware-virtualization
1577 TestVm('tst-nsthwvirt-ubuntu-64', kfGrpStdSmoke, sHd = '5.3/nat/nsthwvirt-ubuntu64/t-nsthwvirt-ubuntu64.vdi',
1578 sKind = 'Ubuntu_64', acCpusSup = range(1, 2), asVirtModesSup = ['hwvirt-np',], fIoApic = True, fNstHwVirt = True,
1579 sNic0AttachType = 'nat'),
1580
1581 # DOS and Old Windows.
1582 AncientTestVm('tst-dos20', sKind = 'DOS',
1583 sHd = '5.2/great-old-ones/t-dos20/t-dos20.vdi'),
1584 AncientTestVm('tst-dos401-win30me', sKind = 'DOS',
1585 sHd = '5.2/great-old-ones/t-dos401-win30me/t-dos401-win30me.vdi', cMBRamMax = 4),
1586 AncientTestVm('tst-dos401-emm386-win30me', sKind = 'DOS',
1587 sHd = '5.2/great-old-ones/t-dos401-emm386-win30me/t-dos401-emm386-win30me.vdi', cMBRamMax = 4),
1588 AncientTestVm('tst-dos50-win31', sKind = 'DOS',
1589 sHd = '5.2/great-old-ones/t-dos50-win31/t-dos50-win31.vdi'),
1590 AncientTestVm('tst-dos50-emm386-win31', sKind = 'DOS',
1591 sHd = '5.2/great-old-ones/t-dos50-emm386-win31/t-dos50-emm386-win31.vdi'),
1592 AncientTestVm('tst-dos622', sKind = 'DOS',
1593 sHd = '5.2/great-old-ones/t-dos622/t-dos622.vdi'),
1594 AncientTestVm('tst-dos622-emm386', sKind = 'DOS',
1595 sHd = '5.2/great-old-ones/t-dos622-emm386/t-dos622-emm386.vdi'),
1596 AncientTestVm('tst-dos71', sKind = 'DOS',
1597 sHd = '5.2/great-old-ones/t-dos71/t-dos71.vdi'),
1598
1599 #AncientTestVm('tst-dos5-win311a', sKind = 'DOS', sHd = '5.2/great-old-ones/t-dos5-win311a/t-dos5-win311a.vdi'),
1600 );
1601
1602
1603 def __init__(self, sResourcePath):
1604 self.sResourcePath = sResourcePath;
1605
1606 def selectSet(self, fGrouping, sTxsTransport = None, fCheckResources = True):
1607 """
1608 Returns a VM set with the selected VMs.
1609 """
1610 oSet = TestVmSet(oTestVmManager = self);
1611 for oVm in self.kaTestVMs:
1612 if oVm.fGrouping & fGrouping:
1613 if sTxsTransport is None or oVm.sNic0AttachType is None or sTxsTransport == oVm.sNic0AttachType:
1614 if not fCheckResources or not oVm.getMissingResources(self.sResourcePath):
1615 oCopyVm = copy.deepcopy(oVm);
1616 oCopyVm.oSet = oSet;
1617 oSet.aoTestVms.append(oCopyVm);
1618 return oSet;
1619
1620 def getStandardVmSet(self, sTxsTransport):
1621 """
1622 Gets the set of standard test VMs.
1623
1624 This is supposed to do something seriously clever, like searching the
1625 testrsrc tree for usable VMs, but for the moment it's all hard coded. :-)
1626 """
1627 return self.selectSet(self.kfGrpStandard, sTxsTransport)
1628
1629 def getSmokeVmSet(self, sTxsTransport = None):
1630 """Gets a representative set of VMs for smoke testing. """
1631 return self.selectSet(self.kfGrpSmoke, sTxsTransport);
1632
1633 def shutUpPyLint(self):
1634 """ Shut up already! """
1635 return self.sResourcePath;
1636
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette