summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorVictor Mocanu2017-10-08 16:44:06 +0200
committerVictor Mocanu2017-10-08 16:44:06 +0200
commitf3756962eaf3c0ff436af11b46fe2a8b9a403d73 (patch)
tree5624e95193967e49a9b9e6344d68da8cc1709246 /src/main/java/org
parentMerge branch 'vbox' of git.openslx.org:bwlp/master-sync-shared into vbox (diff)
downloadmaster-sync-shared-f3756962eaf3c0ff436af11b46fe2a8b9a403d73.tar.gz
master-sync-shared-f3756962eaf3c0ff436af11b46fe2a8b9a403d73.tar.xz
master-sync-shared-f3756962eaf3c0ff436af11b46fe2a8b9a403d73.zip
[VBox] improved the way the new uuid is written in the vdi file
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java
index 40f9f4d..44a2179 100644
--- a/src/main/java/org/openslx/util/vm/VboxMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java
@@ -98,11 +98,12 @@ public class VboxMetaData extends VmMetaData
}
@Override
- public boolean addHddTemplate( String diskImage, String hddMode, String redoDir ) {
+ public boolean addHddTemplate( String diskImage, String hddMode, String redoDir )
+ {
config.changeAttribute( "HardDisk", "location", diskImage );
return true;
}
-
+
@Override
public boolean addHddTemplate( File diskImage, String hddMode, String redoDir )
{
@@ -111,15 +112,38 @@ public class VboxMetaData extends VmMetaData
UUID newuuid = UUID.randomUUID();
LOGGER.debug( newuuid );
-
+
// patching the new uuid in the vbox config file here
- String vboxUUid = "{" + newuuid.toString() + "}";
+ String vboxUUid = "{" + newuuid.toString() + "}";
config.changeAttribute( "HardDisk", "uuid", vboxUUid );
config.changeAttribute( "Image", "uuid", vboxUUid );
+
+ /*Long longl = newuuid.getLeastSignificantBits();
+ Long longr = newuuid.getMostSignificantBits();*/
+
+ // TODO test this
+ byte[] bytesToWrite = new byte[ 16 ];
+
+ int[] numberOfBytes = {32, 40, 48, 56, 16, 24, 0, 8, 56, 48, 40, 32, 24, 16, 8, 0};
- Long longl = newuuid.getLeastSignificantBits();
- Long longr = newuuid.getMostSignificantBits();
+ int offset = 0;
+ for (int i = 0; i < 2; i++) {
+ Long uuidlong = null;
+ if ( i == 0 ) {
+ uuidlong = newuuid.getMostSignificantBits();
+ } else {
+ uuidlong = newuuid.getLeastSignificantBits();
+ }
+
+ for ( int j = 0; j < 8; j++) {
+ int index = j + offset;
+ bytesToWrite[index] = (byte) (uuidlong >>> numberOfBytes[index]);
+ }
+ offset = 8;
+ }
+
+ /*
byte l56 = (byte) (longl >>> 56);
byte l48 = (byte) (longl >>> 48);
byte l40 = (byte) (longl >>> 40);
@@ -141,13 +165,13 @@ public class VboxMetaData extends VmMetaData
byte r8 = (byte) (longr >>> 0);
byte r0 = (byte) (longr >>> 8);
- byte[] bytesToWrite = {r56, r48, r40, r32, r24, r16, r8, r0, l56, l48, l40, l32, l24, l16, l8, l0};
-
- try( RandomAccessFile file = new RandomAccessFile( diskImage, "rw" ) ) {
-
+ byte[] bytesToWrite = {r56, r48, r40, r32, r24, r16, r8, r0, l56, l48, l40, l32, l24, l16, l8, l0}; */
+
+ try ( RandomAccessFile file = new RandomAccessFile( diskImage, "rw" ) ) {
+
file.seek( 392 );
file.write( bytesToWrite, 0, 16 );
- } catch (Exception e) {
+ } catch ( Exception e ) {
LOGGER.warn( "could not patch new uuid in the vdi", e );
}
return true;