diff options
Diffstat (limited to 'src/main/java/org/openslx/util/vm/DiskImage.java')
-rw-r--r-- | src/main/java/org/openslx/util/vm/DiskImage.java | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/main/java/org/openslx/util/vm/DiskImage.java b/src/main/java/org/openslx/util/vm/DiskImage.java index 2b24a3f..30fea99 100644 --- a/src/main/java/org/openslx/util/vm/DiskImage.java +++ b/src/main/java/org/openslx/util/vm/DiskImage.java @@ -19,9 +19,6 @@ public class DiskImage */ private static final int VMDK_MAGIC = 0x4b444d56; private static final int VDI_MAGIC = 0x7f10dabe; - /** - * Big endian representation of the 4 bytes 'QFI\xFB' - */ private static final int QEMU_MAGIC = 0x514649fb; public enum ImageFormat @@ -163,19 +160,30 @@ public class DiskImage return; } - // TODO: qcow - file.seek( 0 ); - if ( file.readInt() == QEMU_MAGIC ) { - // dummy values - this.isStandalone = true; - this.isCompressed = false; - this.isSnapshot = false; - this.format = ImageFormat.QCOW2; - this.subFormat = null; - this.diskDescription = null; - this.hwVersion = 0; - return; - } + file.seek(0); + //TODO: Standalone & Snapshot + if (file.readInt() == QEMU_MAGIC) { + //skip the next 14 ints as they don't interest us + // - QFI version (4 bytes) + // - backing file offset (8 bytes) + // - backing (8 bytes) + // - crypt method (4 bytes) + // - l1 size (4 bytes) + // - l1 table offset (8 bytes) + // - refcount table offset (8 bytes) + // - refcount cluster (4 bytes) + file.skipBytes( 14 * 4 ); + this.isSnapshot = file.readInt() > 0; + //skip the next 14 ints as they don't interest us + file.seek(374); + this.isCompressed = file.read() == 1; + this.diskDescription = null; + this.format = ImageFormat.QCOW2; + this.isStandalone = true; + this.subFormat = null; + this.hwVersion = 0; + return; + } } throw new UnknownImageFormatException(); } |