summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVmware.java
blob: 107014faf8d3482f0a1c3b4782c202503cdaa3f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
package org.openslx.virtualization.configuration;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.thrifthelper.TConst;
import org.openslx.util.Util;
import org.openslx.virtualization.Version;
import org.openslx.virtualization.configuration.VirtualizationConfigurationVmwareFileFormat.ConfigEntry;
import org.openslx.virtualization.hardware.VirtOptionValue;
import org.openslx.virtualization.hardware.ConfigurationGroups;
import org.openslx.virtualization.hardware.Ethernet;
import org.openslx.virtualization.hardware.SoundCard;
import org.openslx.virtualization.hardware.Usb;
import org.openslx.virtualization.virtualizer.VirtualizerVmware;

public class VirtualizationConfigurationVmware extends VirtualizationConfiguration
{
	/**
	 * File name extension for VMware virtualization configuration files.
	 */
	public static final String FILE_NAME_EXTENSION = "vmx";

	private static final Logger LOGGER = LogManager.getLogger( VirtualizationConfigurationVmware.class );

	private static final Pattern HDD_PATTERN = Pattern.compile( "^(ide\\d|scsi\\d|sata\\d|nvme\\d):?(\\d?)\\.(.*)",
			Pattern.CASE_INSENSITIVE );

	/** Lowercase regex of allowed settings for stateless execution */
	private static final Pattern STATELESS_WHITELIST_PATTERN;

	/** Lowercase regex of forbidden settings when uploading (privacy concerns) */
	private static final Pattern PRIVACY_BLACKLIST_PATTERN;

	private final VirtualizationConfigurationVmwareFileFormat config;

	// Init static members
	static {
		// LOWERCASE - Client execution whitelist
		String[] list1 = { "^guestos", "^uuid\\.bios", "^config\\.version", "^ehci[.:]", "^mks\\.enable3d",
				"^virtualhw\\.",
				"^sound[.:]", "\\.pcislotnumber$", "^pcibridge", "\\.virtualdev$", "^tools\\.syncTime$",
				"^time\\.synchronize",
				"^bios\\.bootDelay", "^rtc\\.", "^xhci[.:]", "^usb_xhci[.:]", "\\.deviceType$", "\\.port$", "\\.parent$",
				"^usb[.:]",
				"^firmware", "^hpet", "^vm\\.genid",
				"^svga\\.graphicsMemoryKB$" };
		STATELESS_WHITELIST_PATTERN = Pattern.compile( String.join( "|", list1 ), Pattern.CASE_INSENSITIVE );
		// LOWERCASE - Upload privacy filter
		String[] list2 = { "^displayname$", "^extendedconfigfile$", "^gui\\.", "^nvram$", "^memsize$" };
		PRIVACY_BLACKLIST_PATTERN = Pattern.compile( String.join( "|", list2 ), Pattern.CASE_INSENSITIVE );
	}

	public static enum EthernetType
	{
		NAT( "vmnet1" ), BRIDGED( "vmnet0" ), HOST_ONLY( "vmnet2" );

		public final String vmnet;

		private EthernetType( String vnet )
		{
			this.vmnet = vnet;
		}
	}

	public VirtualizationConfigurationVmware( List<OperatingSystem> osList, File file )
			throws IOException, VirtualizationConfigurationException
	{
		super( new VirtualizerVmware(), osList );
		this.config = new VirtualizationConfigurationVmwareFileFormat( file );
		init();
	}

	public VirtualizationConfigurationVmware( List<OperatingSystem> osList, byte[] vmxContent, int length )
			throws VirtualizationConfigurationException
	{
		super( new VirtualizerVmware(), osList );
		this.config = new VirtualizationConfigurationVmwareFileFormat( vmxContent, length ); // still unfiltered
		init(); // now filtered
	}

	private void init()
	{
		Map<String, Controller> disks = new HashMap<>();
		for ( Entry<String, ConfigEntry> entry : config.entrySet() ) {
			handleLoadEntry( entry, disks );
		}
		// Fix accidentally filtered USB config if we see EHCI is present
		if ( isSetAndTrue( "ehci.present" ) && !isSetAndTrue( "usb.present" ) ) {
			addFiltered( "usb.present", "TRUE" );
		}
		// if we find this tag, we already went through the hdd's - so we're done.
		if ( config.get( "#SLX_HDD_BUS" ) != null ) {
			try {
				hdds.add( new HardDisk( config.get( "#SLX_HDD_CHIP" ),
						DriveBusType.valueOf( config.get( "#SLX_HDD_BUS" ) ), "empty" ) );
			} catch ( Exception e ) {
				LOGGER.debug( "Error adding HDD object when parsing #SLX_HDD_BUS. Meta-data will be incorrect.", e );
			}
			return;
		}
		// Now find the HDDs and add to list
		for ( Entry<String, Controller> cEntry : disks.entrySet() ) {
			Controller controller = cEntry.getValue();
			String controllerType = cEntry.getKey();
			if ( !controller.present )
				continue;
			for ( Entry<String, Device> dEntry : controller.devices.entrySet() ) {
				String deviceId = dEntry.getKey();
				Device device = dEntry.getValue();
				if ( !device.present )
					continue; // Not present
				if ( device.deviceType != null && !device.deviceType.toLowerCase().endsWith( "disk" ) )
					continue; // Not a HDD
				DriveBusType bus = null;
				if ( controllerType.startsWith( "ide" ) ) {
					bus = DriveBusType.IDE;
				} else if ( controllerType.startsWith( "scsi" ) ) {
					bus = DriveBusType.SCSI;
				} else if ( controllerType.startsWith( "sata" ) ) {
					bus = DriveBusType.SATA;
				} else if ( controllerType.startsWith( "nvme" ) ) {
					bus = DriveBusType.NVME;
				}
				hdds.add( new HardDisk( controller.virtualDev, bus, device.filename ) );
				// Remove original entries from VMX
				removeEntriesStartingWith( controllerType + ":" + deviceId + "." );
			}
		}
		this.isMachineSnapshot = false;

		// Add HDD to cleaned vmx
		if ( !hdds.isEmpty() ) {
			HardDisk hdd = hdds.get( 0 );
			addFiltered( "#SLX_HDD_BUS", hdd.bus.toString() );
			if ( hdd.chipsetDriver != null ) {
				addFiltered( "#SLX_HDD_CHIP", hdd.chipsetDriver );
			}
		}
	}

	private void removeEntriesStartingWith( String start )
	{
		for ( Iterator<Entry<String, ConfigEntry>> it = config.entrySet().iterator(); it.hasNext(); ) {
			Entry<String, ConfigEntry> entry = it.next();
			if ( entry.getKey().startsWith( start ) ) {
				it.remove();
			}
		}
	}

	private void addFiltered( String key, String value )
	{
		config.set( key, value );
	}

	private boolean isSetAndTrue( String key )
	{
		String value = config.get( key );
		return value != null && value.equalsIgnoreCase( "true" );
	}

	private void handleLoadEntry( Entry<String, ConfigEntry> entry, Map<String, Controller> disks )
	{
		String lowerKey = entry.getKey().toLowerCase();
		// Dig Usable meta data
		String value = entry.getValue().getValue();
		if ( lowerKey.equals( "guestos" ) ) {
			setOs( value );
			return;
		}
		if ( lowerKey.equals( "displayname" ) ) {
			displayName = value;
			return;
		}
		Matcher hdd = HDD_PATTERN.matcher( entry.getKey() );
		if ( hdd.find() ) {
			handleHddEntry( disks, hdd.group( 1 ).toLowerCase(), hdd.group( 2 ), hdd.group( 3 ), value );
		}
	}

	private void handleHddEntry( Map<String, Controller> disks, String controllerStr, String deviceStr, String property, String value )
	{
		Controller controller = disks.get( controllerStr );
		if ( controller == null ) {
			controller = new Controller();
			disks.put( controllerStr, controller );
		}
		if ( deviceStr == null || deviceStr.isEmpty() ) {
			// Controller property
			if ( property.equalsIgnoreCase( "present" ) ) {
				controller.present = Boolean.parseBoolean( value );
			} else if ( property.equalsIgnoreCase( "virtualDev" ) ) {
				controller.virtualDev = value;
			}
			return;
		}
		// Device property
		Device device = controller.devices.get( deviceStr );
		if ( device == null ) {
			device = new Device();
			controller.devices.put( deviceStr, device );
		}
		if ( property.equalsIgnoreCase( "deviceType" ) ) {
			device.deviceType = value;
		} else if ( property.equalsIgnoreCase( "filename" ) ) {
			device.filename = value;
		} else if ( property.equalsIgnoreCase( "present" ) ) {
			device.present = Boolean.parseBoolean( value );
		}
	}

	@Override
	public boolean addEmptyHddTemplate()
	{
		return this.addHddTemplate( "%VM_DISK_PATH%", "%VM_DISK_MODE%", "%VM_DISK_REDOLOGDIR%" );
	}

	@Override
	public boolean addHddTemplate( File diskImage, String hddMode, String redoDir )
	{
		return addHddTemplate( diskImage.getName(), hddMode, redoDir );
	}

	@Override
	public boolean addHddTemplate( String diskImagePath, String hddMode, String redoDir )
	{
		if ( diskImagePath.isEmpty() ) {
			LOGGER.error( "Empty disk image path given!" );
			return false;
		}

		if ( hdds.isEmpty() ) {
			LOGGER.warn( "No HDDs found in configuration" );
			return false;
		}

		HardDisk hdd = hdds.get( 0 );

		String chipset = hdd.chipsetDriver;
		String prefix;
		switch ( hdd.bus ) {
		case SATA:
			// Cannot happen?... use lsisas1068
			prefix = "scsi0";
			chipset = "lsisas1068";
			break;
		case IDE:
		case SCSI:
		case NVME:
			prefix = hdd.bus.name().toLowerCase() + "0";
			break;
		default:
			LOGGER.warn( "Unknown HDD bus type: " + hdd.bus.toString() );
			return false;
		}
		// Gen
		addFiltered( prefix + ".present", "TRUE" );
		if ( chipset != null ) {
			addFiltered( prefix + ".virtualDev", chipset );
		}
		addFiltered( prefix + ":0.present", "TRUE" );
		addFiltered( prefix + ":0.deviceType", "disk" );
		addFiltered( prefix + ":0.fileName", diskImagePath );
		if ( hddMode != null ) {
			addFiltered( prefix + ":0.mode", hddMode );
			addFiltered( prefix + ":0.redo", "" );
			addFiltered( prefix + ":0.redoLogDir", redoDir );
		}
		config.remove( "#SLX_HDD_BUS" );
		config.remove( "#SLX_HDD_CHIP" );
		return true;
	}

	public boolean addDefaultNat()
	{
		addFiltered( "ethernet0.present", "TRUE" );
		addFiltered( "ethernet0.connectionType", "nat" );
		return true;
	}

	public boolean addEthernet( VirtualizationConfiguration.EtherType type )
	{
		boolean ret = false;
		int index = 0;
		for ( ;; ++index ) {
			if ( config.get( "ethernet" + index + ".present" ) == null )
				break;
		}
		switch ( type ) {
		case NAT:
			ret = addEthernet( index, EthernetType.NAT );
			break;
		case BRIDGED:
			ret = addEthernet( index, EthernetType.BRIDGED );
			break;
		case HOST_ONLY:
			ret = addEthernet( index, EthernetType.HOST_ONLY );
			break;
		default:
			// Should not come to this...
			break;
		}
		return ret;
	}

	public boolean addEthernet( int index, EthernetType type )
	{
		String ether = "ethernet" + index;
		addFiltered( ether + ".present", "TRUE" );
		addFiltered( ether + ".connectionType", "custom" );
		addFiltered( ether + ".vnet", type.vmnet );
		if ( config.get( ether + ".virtualDev" ) == null ) {
			String dev = config.get( "ethernet0.virtualDev" );
			if ( dev != null ) {
				addFiltered( ether + ".virtualDev", dev );
			}
		}
		return true;
	}

	public void addFloppy( int index, String image, boolean readOnly )
	{
		String pre = "floppy" + index;
		addFiltered( pre + ".present", "TRUE" );
		if ( image == null ) {
			addFiltered( pre + ".startConnected", "FALSE" );
			addFiltered( pre + ".fileType", "device" );
			config.remove( pre + ".fileName" );
			config.remove( pre + ".readonly" );
			addFiltered( pre + ".autodetect", "TRUE" );
		} else {
			addFiltered( pre + ".startConnected", "TRUE" );
			addFiltered( pre + ".fileType", "file" );
			addFiltered( pre + ".fileName", image );
			addFiltered( pre + ".readonly", vmBoolean( readOnly ) );
			config.remove( pre + ".autodetect" );
		}
	}

	public boolean addCdrom( String image )
	{
		for ( String port : new String[] { "ide0:0", "ide0:1", "ide1:0", "ide1:1", "scsi0:1" } ) {
			if ( !isSetAndTrue( port + ".present" ) ) {
				addFiltered( port + ".present", "TRUE" );
				if ( image == null ) {
					addFiltered( port + ".autodetect", "TRUE" );
					addFiltered( port + ".deviceType", "cdrom-raw" );
					config.remove( port + ".fileName" );
				} else {
					config.remove( port + ".autodetect" );
					addFiltered( port + ".deviceType", "cdrom-image" );
					addFiltered( port + ".fileName", image );
				}
				return true;
			}
		}
		return false;
	}

	private static String vmBoolean( boolean var )
	{
		return Boolean.toString( var ).toUpperCase();
	}

	private static String vmInteger( int val )
	{
		return Integer.toString( val );
	}

	@Override
	public void transformNonPersistent() throws VirtualizationConfigurationException
	{
		// Cleaned vmx construction
		for ( Iterator<Entry<String, ConfigEntry>> it = config.entrySet().iterator(); it.hasNext(); ) {
			Entry<String, ConfigEntry> elem = it.next();
			if ( !STATELESS_WHITELIST_PATTERN.matcher( elem.getKey() ).find() ) {
				it.remove();
			}
		}
		addFiltered( "suspend.disabled", "TRUE" );
	}

	@Override
	public void transformEditable() throws VirtualizationConfigurationException
	{
		addFiltered( "gui.applyHostDisplayScalingToGuest", "FALSE" );
		// This is for a very old bug: Check we have at lerast USB 2.0, as
		// a buggy dmsd removed all USB controllers
		List<ConfigurableOptionGroup> groups = getConfigurableOptions();
		for ( ConfigurableOptionGroup group : groups ) {
			if ( group.groupIdentifier != ConfigurationGroups.USB_SPEED )
				continue;
			int currentSpeed = 0;
			VirtOptionValue twoPointOh = null;
			for ( VirtOptionValue option : group.availableOptions ) {
				int s = Util.parseInt( option.getId(), 0 );
				if ( option.isActive() && s > currentSpeed ) {
					currentSpeed = s;
				}
				if ( s == 2 ) {
					twoPointOh = option;
				}
			}
			if ( currentSpeed < 3 && twoPointOh != null ) {
				twoPointOh.apply();
			}
		}
	}

	@Override
	public void transformPrivacy() throws VirtualizationConfigurationException
	{
		for ( Iterator<Entry<String, ConfigEntry>> it = config.entrySet().iterator(); it.hasNext(); ) {
			Entry<String, ConfigEntry> elem = it.next();
			String key = elem.getKey();
			String value = elem.getValue().getValue();
			if ( key.endsWith( ".fileName" ) && !value.startsWith( "-" )
					&& ( value.contains( "." ) || value.contains( "/" ) || value.contains( "\\" ) ) ) {
				it.remove();
			} else if ( PRIVACY_BLACKLIST_PATTERN.matcher( key ).find() ) {
				it.remove();
			}
		}
	}

	@Override
	public boolean addDisplayName( String name )
	{
		addFiltered( "displayName", name );
		return true;
	}

	@Override
	public boolean addRam( int mem )
	{
		addFiltered( "memsize", Integer.toString( mem ) );
		return true;
	}

	public void setOs( String vendorOsId )
	{
		addFiltered( "guestOS", vendorOsId );

		final OperatingSystem os = VirtualizationConfigurationUtils.getOsOfVirtualizerFromList( this.osList,
				TConst.VIRT_VMWARE, vendorOsId );
		this.setOs( os );
	}

	public byte[] getConfigurationAsByteArray()
	{
		return config.toString().getBytes( StandardCharsets.UTF_8 );
	}

	private static class Device
	{
		public boolean present = false;
		public String deviceType = null;
		public String filename = null;

		@Override
		public String toString()
		{
			return filename + " is " + deviceType + " (present: " + present + ")";
		}
	}

	private static class Controller
	{
		public boolean present = true; // Seems to be implicit, seen at least for IDE...
		public String virtualDev = null;
		Map<String, Device> devices = new HashMap<>();

		@Override
		public String toString()
		{
			return virtualDev + " is (present: " + present + "): " + devices.toString();
		}
	}

	public String getValue( String key )
	{
		return config.get( key );
	}
	
	class VmwareNoSoundCard extends VirtOptionValue
	{

		public VmwareNoSoundCard( String displayName )
		{
			super( "", displayName );
		}

		@Override
		public void apply()
		{
			addFiltered( "sound.present", vmBoolean( false ) );
			config.remove( "sound.virtualDev" );
		}

		@Override
		public boolean isActive()
		{
			return !isSetAndTrue( "sound.present" );
		}

	}

	class VmWareSoundCardModelNone extends VirtOptionValue
	{

		public VmWareSoundCardModelNone( String displayName )
		{
			super( "none", displayName );
		}

		@Override
		public void apply()
		{
			addFiltered( "sound.present", vmBoolean( false ) );
			addFiltered( "sound.autodetect", vmBoolean( false ) );
			config.remove( "sound.virtualDev" );
		}

		@Override
		public boolean isActive()
		{
			return !isSetAndTrue( "sound.present" );
		}

	}

	class VmWareSoundCardModel extends VirtOptionValue
	{

		public VmWareSoundCardModel( String id, String displayName )
		{
			super( id, displayName );
		}

		@Override
		public void apply()
		{
			addFiltered( "sound.present", vmBoolean( true ) );
			addFiltered( "sound.autodetect", vmBoolean( true ) );
			addFiltered( "sound.virtualDev", this.id );
		}

		@Override
		public boolean isActive()
		{
			return isSetAndTrue( "sound.present" ) && isSetAndTrue( "sound.autodetect" )
					&& this.id.equals( config.get( "sound.virtualDev" ) );
		}

	}

	class VmWareAccel3D extends VirtOptionValue
	{

		public VmWareAccel3D( String id, String displayName )
		{
			super( id, displayName );
		}

		@Override
		public void apply()
		{
			addFiltered( "mks.enable3d", this.id );
		}

		@Override
		public boolean isActive()
		{
			return Boolean.parseBoolean( this.id ) == isSetAndTrue( "mks.enable3d" );
		}

	}

	public void setVirtualizerVersion( Version type )
	{
		addFiltered( "virtualHW.version", vmInteger( type.getMajor() ) );
	}

	public Version getVirtualizerVersion()
	{
		final short major = Integer.valueOf( Util.parseInt( config.get( "virtualHW.version" ), -1 ) ).shortValue();
		return Version.getInstanceByMajorFromVersions( major, this.getVirtualizer().getSupportedVersions() );
	}
	
	class VmwareNicModel extends VirtOptionValue
	{

		private final int cardIndex;
		
		public VmwareNicModel( int cardIndex, String id, String displayName )
		{
			super( id, displayName );
			this.cardIndex = cardIndex;
		}

		@Override
		public void apply()
		{
			if ( Util.isEmptyString( id ) ) {
				config.remove( "ethernet" + cardIndex + ".virtualDev" );
			} else {
				addFiltered( "ethernet" + cardIndex + ".virtualDev", id );
			}
		}

		@Override
		public boolean isActive()
		{
			String temp = config.get( "ethernet" + cardIndex + ".virtualDev" );
			if ( temp == null )
				return Util.isEmptyString( this.id );
			return temp.equals( this.id );
		}

	}
	
	class VmWareUsbSpeed extends VirtOptionValue
	{
		private final String[] SPEED = { null, "usb", "ehci", "usb_xhci" };
		private final int speed;

		public VmWareUsbSpeed( int speed, String displayName )
		{
			super( Integer.toString( speed ), displayName );
			this.speed = speed;
		}

		@Override
		public void apply()
		{
			// XXX TODO This sucks, qnd
			for ( int i = 1; i < SPEED.length; ++i ) {
				String key = SPEED[i] + ".present";
				if ( i <= speed ) {
					// Enable desired speed class, plus all lower ones
					addFiltered( key, "TRUE" );
				} else {
					config.remove( key );
				}
			}
			// VMware 14+ needs this to use USB 3.0 devices at USB 3.0 ports in VMs configured for < 3.0
			if ( speed > 0 && speed < 3 ) {
				addFiltered( "usb.mangleUsb3Speed", "TRUE" );
			}
		}

		@Override
		public boolean isActive()
		{
			int max = 0;
			for ( int i = 1; i < SPEED.length; ++i ) {
				if ( isSetAndTrue( SPEED[i] + ".present" ) ) {
					max = i;
				}
			}
			return speed == max;
		}
		
	}

	@Override
	public boolean addCpuCoreCount( int numCores )
	{
		addFiltered( "numvcpus", vmInteger( numCores ) );
		return true;
	}

	public void registerVirtualHW()
	{
		List<VirtOptionValue> list;
		list = new ArrayList<>();
		list.add( new VmWareSoundCardModelNone( SoundCard.NONE ) );
		list.add( new VmWareSoundCardModel( "", SoundCard.DEFAULT ) );
		list.add( new VmWareSoundCardModel( "sb16", SoundCard.SOUND_BLASTER ) );
		list.add( new VmWareSoundCardModel( "es1371", SoundCard.ES ) );
		list.add( new VmWareSoundCardModel( "hdaudio", SoundCard.HD_AUDIO ) );
		configurableOptions.add( new ConfigurableOptionGroup( ConfigurationGroups.SOUND_CARD_MODEL, list ) );

		list = new ArrayList<>();
		list.add( new VmWareAccel3D( "FALSE", "2D" ) );
		list.add( new VmWareAccel3D( "TRUE", "3D" ) );
		configurableOptions.add( new ConfigurableOptionGroup( ConfigurationGroups.GFX_TYPE, list ) );
		
		list = new ArrayList<>();
		list.add( new VmwareNicModel( 0, "", Ethernet.AUTO ) );
		list.add( new VmwareNicModel( 0, "vlance", Ethernet.PCNET32 ) );
		list.add( new VmwareNicModel( 0, "e1000", Ethernet.E1000 ) );
		list.add( new VmwareNicModel( 0, "e1000e", Ethernet.E1000E ) );
		list.add( new VmwareNicModel( 0, "vmxnet", Ethernet.VMXNET ) );
		list.add( new VmwareNicModel( 0, "vmxnet3", Ethernet.VMXNET3 ) );
		configurableOptions.add( new ConfigurableOptionGroup( ConfigurationGroups.NIC_MODEL, list ) );

		list = new ArrayList<>();
		list.add( new VmWareUsbSpeed( 0, Usb.NONE ) );
		list.add( new VmWareUsbSpeed( 1, Usb.USB1_1 ) );
		list.add( new VmWareUsbSpeed( 2, Usb.USB2_0 ) );
		list.add( new VmWareUsbSpeed( 3, Usb.USB3_0 ) );
		configurableOptions.add( new ConfigurableOptionGroup( ConfigurationGroups.USB_SPEED, list ) );
	}

	@Override
	public String getFileNameExtension()
	{
		return VirtualizationConfigurationVmware.FILE_NAME_EXTENSION;
	}

	@Override
	public void validate() throws VirtualizationConfigurationException
	{
	}

	@Override
	public void disableUsb()
	{
		new VmWareUsbSpeed( 0, Usb.NONE ).apply();
	}
		
	@Override
	public String getSuspendedFile()
	{
		return config.get( "checkpoint.vmState" );
	}
}