summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/util/vm/VboxMetaData.java
diff options
context:
space:
mode:
authorVictor Mocanu2017-11-21 13:36:02 +0100
committerVictor Mocanu2017-11-21 13:36:02 +0100
commitcb22d2a446c5a6d0978f8317761eaf0532df6867 (patch)
treee55d5039d8b2ae59b19d813137b4db5d4fad3291 /src/main/java/org/openslx/util/vm/VboxMetaData.java
parent[VBox] improved and expanded the setters and getters for the enum types (diff)
downloadmaster-sync-shared-cb22d2a446c5a6d0978f8317761eaf0532df6867.tar.gz
master-sync-shared-cb22d2a446c5a6d0978f8317761eaf0532df6867.tar.xz
master-sync-shared-cb22d2a446c5a6d0978f8317761eaf0532df6867.zip
[VBox] added all networkcards for virtualbox made small change to internal class
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VboxMetaData.java')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java69
1 files changed, 50 insertions, 19 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java
index 57563d0..a4dc063 100644
--- a/src/main/java/org/openslx/util/vm/VboxMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java
@@ -55,10 +55,12 @@ class VBoxHWVersionMeta
class VBoxEthernetDevTypeMeta
{
public final String value;
+ public final boolean isPresent;
- public VBoxEthernetDevTypeMeta( String val )
+ public VBoxEthernetDevTypeMeta( boolean present, String val )
{
value = val;
+ isPresent = present;
}
}
@@ -258,12 +260,8 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
{
VBoxSoundCardMeta sound = soundCards.get( type );
- if ( type.equals( VmMetaData.SoundCardType.NONE ) ) {
- config.changeAttribute( "AudioAdapter", "enabled", vmBoolean( false ) );
- } else {
- config.changeAttribute( "AudioAdapter", "enabled", vmBoolean( true ) );
- config.changeAttribute( "AudioAdapter", "controller", sound.value );
- }
+ config.changeAttribute( "AudioAdapter", "enabled", vmBoolean( sound.isPresent ) );
+ config.changeAttribute( "AudioAdapter", "controller", sound.value );
}
// TODO test with/without codec if there is sound
@@ -287,9 +285,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
returnsct = VmMetaData.SoundCardType.AC;
break;
default:
- // TODO ask around if there exists another possibility to tell the user that the previous argument was wrong without blocking the whole
- // program
- throw new IllegalArgumentException( "Invalid entry: " + controller );
+ throw new IllegalArgumentException( "Invalid entry: controller=" + controller );
}
}
return returnsct;
@@ -341,17 +337,46 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public void setEthernetDevType( int cardIndex, EthernetDevType type )
{
- // TODO Auto-generated method stub
-
+ String index = "0";
+ VBoxEthernetDevTypeMeta networkc = networkCards.get( type );
+ // TODO 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 )
{
VmMetaData.EthernetDevType returnedt = null;
- // TODO what do here?
- // TODO need to search for the 1.st adapter of network tag
- return VmMetaData.EthernetDevType.AUTO;
+ 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":
+ 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);
+ }
+ }
+ return returnedt;
}
@Override
@@ -363,7 +388,8 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public void populateTheMaps()
{
// add all from vmware supported sound cards here
- soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, null ) );
+ // none type needs to have a valid value; it takes the value of AC97; if value is left null or empty vm will not start because value is not valid
+ soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, "AC97" ) );
soundCards.put( VmMetaData.SoundCardType.SOUND_BLASTER, new VBoxSoundCardMeta( true, "SB16" ) );
soundCards.put( VmMetaData.SoundCardType.HD_AUDIO, new VBoxSoundCardMeta( true, "HDA" ) );
soundCards.put( VmMetaData.SoundCardType.AC, new VBoxSoundCardMeta( true, "AC97" ) );
@@ -377,9 +403,14 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
// end of all from vmware supported Hardware versions here
// add all from vmware supported Ethernet devices versions here
- networkCards.put( VmMetaData.EthernetDevType.AUTO, new VBoxEthernetDevTypeMeta( null ) );
- networkCards.put( VmMetaData.EthernetDevType.PCNET32, new VBoxEthernetDevTypeMeta( "vlance" ) );
- networkCards.put( VmMetaData.EthernetDevType.E1000, new VBoxEthernetDevTypeMeta( "e1000" ) );
+ // 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
+ networkCards.put( VmMetaData.EthernetDevType.NONE, new VBoxEthernetDevTypeMeta( false, "Am79C970A" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PCNETPCI2, new VBoxEthernetDevTypeMeta( true, "Am79C970A" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PCNETFAST3, new VBoxEthernetDevTypeMeta( true, "Am79C973" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PRO1000MTD, new VBoxEthernetDevTypeMeta( true, "82540EM" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PRO1000TS, new VBoxEthernetDevTypeMeta( true, "82543GC" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PRO1000MTS, new VBoxEthernetDevTypeMeta( true, "82545EM" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PARAVIRT, new VBoxEthernetDevTypeMeta( true, "virtio" ) );
// end of all from vmware supported Ethernet devices versions here
}