diff options
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VboxMetaData.java')
-rw-r--r-- | src/main/java/org/openslx/util/vm/VboxMetaData.java | 101 |
1 files changed, 32 insertions, 69 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java index 1f83572..147b4d2 100644 --- a/src/main/java/org/openslx/util/vm/VboxMetaData.java +++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java @@ -7,14 +7,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.UUID; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.Virtualizer; @@ -99,16 +91,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, } } - // TODO DELETE LATER WHEN NOT NEEDED ANYMORE - private void WriteToFile() throws TransformerFactoryConfigurationError, TransformerException - { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - StreamResult output = new StreamResult( new File( "output.xml" ) ); - Source input = new DOMSource( config.getConfigDoc() ); - transformer.transform( input, output ); - } - // TODO END DELETE LATER WHEN NOT NEEDED ANYMORE - @Override public Virtualizer getVirtualizer() { @@ -204,15 +186,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, return true; } - public void reWrite() - { - try { - WriteToFile(); - } catch ( TransformerFactoryConfigurationError | TransformerException e ) { - e.printStackTrace(); - } - } - @Override public void setOs( String vendorOsId ) { @@ -238,7 +211,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, @Override public void addFloppy( int index, String image, boolean readOnly ) { - + // TODO will need to add this soon if ( image == null ) { } else { } @@ -278,19 +251,20 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, if ( !x.hasAttribute( "enabled" ) || ( x.hasAttribute( "enabled" ) && x.getAttribute( "enabled" ).equals( "false" ) ) ) { returnsct = VmMetaData.SoundCardType.NONE; } else { - String controller = x.getAttribute( "controller" ); - switch ( controller ) { - case "HDA": - returnsct = VmMetaData.SoundCardType.HD_AUDIO; - break; - case "SB16": - returnsct = VmMetaData.SoundCardType.SOUND_BLASTER; - break; - case "AC97": + // extra separate case for the non-existing argument} + if ( !x.hasAttribute( "type" ) ) { returnsct = VmMetaData.SoundCardType.AC; - break; - default: - throw new IllegalArgumentException( "Invalid entry: controller=" + controller ); + } else { + String controller = x.getAttribute( "controller" ); + VBoxSoundCardMeta soundMeta = null; + for ( VmMetaData.SoundCardType type : VmMetaData.SoundCardType.values() ) { + soundMeta = soundCards.get( type ); + if ( soundMeta != null ) { + if ( controller.equals( soundMeta.value ) ) { + returnsct = type; + } + } + } } } return returnsct; @@ -330,12 +304,11 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, } @Override - public HWVersion getHWVersion() + public VmMetaData.HWVersion getHWVersion() { VmMetaData.HWVersion returnhwv = null; - // TODO what do here? there is only one supported hwversion as far as I know + // Virtual Box uses only one virtual hardware version and can't be changed returnhwv = VmMetaData.HWVersion.DEFAULT; - // TODO End return returnhwv; } @@ -344,41 +317,33 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, { String index = "0"; VBoxEthernetDevTypeMeta networkc = networkCards.get( type ); - // TODO cardIndex is not used yet...maybe later needed for different network cards + // cardIndex is not used yet...maybe later needed for different network cards config.changeAttribute( "Adapter", "enabled", vmBoolean( networkc.isPresent ), "slot", index ); config.changeAttribute( "Adapter", "type", networkc.value, "slot", index ); } @Override - public EthernetDevType getEthernetDevType( int cardIndex ) + public VmMetaData.EthernetDevType getEthernetDevType( int cardIndex ) { VmMetaData.EthernetDevType returnedt = null; Element x = (Element)config.findANode( "Adapter" ).item( 0 ); if ( !x.hasAttribute( "enabled" ) || ( x.hasAttribute( "enabled" ) && x.getAttribute( "enabled" ).equals( "false" ) ) ) { returnedt = VmMetaData.EthernetDevType.NONE; } else { - String type = x.getAttribute( "type" ); - switch ( type ) { - case "Am79C970A": - returnedt = VmMetaData.EthernetDevType.PCNETPCI2; - break; - case "Am79C973": + // extra separate case for the non-existing argument} + if ( !x.hasAttribute( "type" ) ) { returnedt = VmMetaData.EthernetDevType.PCNETFAST3; - break; - case "82540EM": - returnedt = VmMetaData.EthernetDevType.PRO1000MTD; - break; - case "82543GC": - returnedt = VmMetaData.EthernetDevType.PRO1000TS; - break; - case "82545EM": - returnedt = VmMetaData.EthernetDevType.PRO1000MTS; - break; - case "virtio": - returnedt = VmMetaData.EthernetDevType.PARAVIRT; - break; - default: - throw new IllegalArgumentException( "Invalid entry: type=" + type); + } else { + String temp = x.getAttribute( "type" ); + VBoxEthernetDevTypeMeta etherMeta = null; + for ( VmMetaData.EthernetDevType type : VmMetaData.EthernetDevType.values() ) { + etherMeta = networkCards.get( type ); + if ( etherMeta != null ) { + if ( temp.equals( etherMeta.value ) ) { + returnedt = type; + } + } + } } } return returnedt; @@ -405,7 +370,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, // end of all from vmware supported settings for the 3D acceleration // add all from vmware supported Hardware versions here hwversion.put( VmMetaData.HWVersion.DEFAULT, new VBoxHWVersionMeta( 0 ) ); - // end of all from vmware supported Hardware versions here // add all from vmware supported Ethernet devices versions here // none type needs to have a valid value; it takes the value of pcnetcpi2; if value is left null or empty vm will not start because value is not valid @@ -419,8 +383,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, // end of all from vmware supported Ethernet devices versions here } - - /** * given a boolean value returns a string in lowercase of given boolean * @@ -451,6 +413,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, public boolean disableSuspend() { // TODO how?? + // https://forums.virtualbox.org/viewtopic.php?f=6&t=77169 // https://forums.virtualbox.org/viewtopic.php?f=8&t=80338 return true; } |