From cb6aee22c694781bfc4c63332ec8ba471e6f4e18 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 18 Jun 2019 17:34:41 +0200 Subject: Add support for configuring USB speed --- src/main/java/org/openslx/util/vm/VmMetaData.java | 43 +++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'src/main/java/org/openslx/util/vm/VmMetaData.java') diff --git a/src/main/java/org/openslx/util/vm/VmMetaData.java b/src/main/java/org/openslx/util/vm/VmMetaData.java index c750ecc..9cff9f5 100644 --- a/src/main/java/org/openslx/util/vm/VmMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmMetaData.java @@ -18,7 +18,7 @@ import org.openslx.bwlp.thrift.iface.Virtualizer; * Describes a configured virtual machine. This class is parsed from a machine * description, like a *.vmx for VMware machines. */ -public abstract class VmMetaData +public abstract class VmMetaData { private static final Logger LOGGER = Logger.getLogger( VmMetaData.class ); @@ -29,6 +29,7 @@ public abstract class VmMetaData protected Map ddacc = new HashMap<>(); protected Map hwversion = new HashMap<>(); protected Map networkCards = new HashMap<>(); + protected Map usbSpeeds = new HashMap<>(); /** * Virtual sound cards types @@ -103,6 +104,21 @@ public abstract class VmMetaData this.displayName = dName; } } + + public static enum UsbSpeed + { + NONE( "None" ), + USB1_1( "USB 1.1" ), + USB2_0( "USB 2.0" ), + USB3_0( "USB 3.0" ); + + public final String displayName; + + private UsbSpeed( String dName ) + { + this.displayName = dName; + } + } public static enum DriveBusType { @@ -172,6 +188,13 @@ public abstract class VmMetaData return availables; } + public List getSupportedUsbSpeeds() + { + ArrayList availables = new ArrayList<>( usbSpeeds.keySet() ); + Collections.sort( availables ); + return availables; + } + /** * Get operating system of this VM. */ @@ -270,7 +293,7 @@ public abstract class VmMetaData * @param file VM's machine description file to get the metadata instance from * @return VmMetaData object representing the relevant parts of the given machine description */ - public static VmMetaData getInstance( List osList, File file ) + public static VmMetaData getInstance( List osList, File file ) throws IOException { try { @@ -301,20 +324,24 @@ public abstract class VmMetaData * @return VmMetaData object representing the relevant parts of the given machine description * @throws IOException */ - public static VmMetaData getInstance( List osList, byte[] vmContent, int length ) throws IOException + public static VmMetaData getInstance( List osList, byte[] vmContent, int length ) throws IOException { + Map exceptions = new HashMap<>(); try { return new VmwareMetaData( osList, vmContent, length ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.info( "Not a VMware file", e ); + exceptions.put( "Not a VMware file", e ); } try { return new VboxMetaData( osList, vmContent, length ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.info( "Not a VirtualBox file", e ); + exceptions.put( "Not a VirtualBox file", e ); } // TODO QEmu -- hack above expects qcow2 file, so we can't do anything here yet LOGGER.error( "Could not detect any known virtualizer format" ); + for ( Entry e : exceptions.entrySet() ) { + LOGGER.error( e.getKey(), e.getValue() ); + } return null; } @@ -352,14 +379,16 @@ public abstract class VmMetaData public abstract EthernetDevType getEthernetDevType( int cardIndex ); + public abstract void setMaxUsbSpeed( UsbSpeed speed ); + + public abstract UsbSpeed getMaxUsbSpeed(); + public abstract byte[] getDefinitionArray(); public abstract boolean addEthernet( EtherType type ); public abstract Virtualizer getVirtualizer(); - public abstract void enableUsb( boolean enabled ); - public abstract boolean disableSuspend(); /** -- cgit v1.2.3-55-g7522