diff options
author | Simon Rettberg | 2016-08-30 17:56:50 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-08-30 17:56:50 +0200 |
commit | d954a50ee4619b40acbedab294811de057f70e82 (patch) | |
tree | 0e1d857321601d8c97654108c346d88f9794ebe4 | |
parent | Fix: Some chunks could be dropped from the hash queue and not marked as to-be... (diff) | |
download | master-sync-shared-d954a50ee4619b40acbedab294811de057f70e82.tar.gz master-sync-shared-d954a50ee4619b40acbedab294811de057f70e82.tar.xz master-sync-shared-d954a50ee4619b40acbedab294811de057f70e82.zip |
[DiskImage] Detect snapshot vmdk
-rw-r--r-- | src/main/java/org/openslx/util/vm/DiskImage.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/util/vm/DiskImage.java b/src/main/java/org/openslx/util/vm/DiskImage.java index 1112cfc..80eec2a 100644 --- a/src/main/java/org/openslx/util/vm/DiskImage.java +++ b/src/main/java/org/openslx/util/vm/DiskImage.java @@ -48,7 +48,9 @@ public class DiskImage public final boolean isStandalone; public final boolean isCompressed; + public final boolean isSnapshot; public final ImageFormat format; + public final String subFormat; public final int hwVersion; public DiskImage( File disk ) throws FileNotFoundException, IOException, @@ -62,10 +64,13 @@ public class DiskImage byte[] buffer = new byte[ 2048 ]; file.readFully( buffer ); VmwareConfig config = new VmwareConfig( buffer, findNull( buffer ) ); - String ct = config.get( "createType" ); - this.isStandalone = isStandaloneCreateType( ct ); - this.isCompressed = ct != null - && ct.equalsIgnoreCase( "streamOptimized" ); + subFormat = config.get( "createType" ); + String parent = config.get( "parentCID" ); + this.isStandalone = isStandaloneCreateType( subFormat, parent ); + this.isCompressed = subFormat != null + && subFormat.equalsIgnoreCase( "streamOptimized" ); + this.isSnapshot = parent != null + && !parent.equalsIgnoreCase( "ffffffff" ); this.format = ImageFormat.VMDK; String hwv = config.get( "ddb.virtualHWVersion" ); if (hwv == null ) { @@ -85,10 +90,12 @@ public class DiskImage return buffer.length; } - private boolean isStandaloneCreateType( String type ) + private boolean isStandaloneCreateType( String type, String parent ) { if ( type == null ) return false; + if ( parent != null && !parent.equalsIgnoreCase( "ffffffff" ) ) + return false; return type.equalsIgnoreCase( "streamOptimized" ) || type.equalsIgnoreCase( "monolithicSparse" ); } |