00001 #if !defined(__QCOW_IMAGE_HPP__) 00002 #define __QCOW_IMAGE_HPP__ 00003 00004 // 00005 // local includes 00006 // 00007 #include "block_driver.hpp" 00008 00009 /* 00010 * The QCOW image format is one of the disk image formats supported by the QEMU processor emulator. 00011 * It is a representation of a fixed size block device in a file. Benefits it offers over using 00012 * raw dump representation include: 00013 * 00014 * 1. Smaller file size, even on filesystems which don't support holes (i.e. sparse files). 00015 * 2. Snapshot support, where the image only represents changes made to an underlying disk image. 00016 * 3. Optional zlib based compression. 00017 * 4. Optional AES encryption. 00018 */ 00019 struct qcow_image_header 00020 { 00021 // 00022 // The first 4 bytes contain the characters 'Q', 'F', 'I' followed by 0xfb 00023 // 00024 be_uint32_t magic; 00025 00026 // 00027 // The next 4 bytes contain the format version used by the file. 00028 // Currently, there has only been a single version of the format, version 1. 00029 // 00030 be_uint32_t version; 00031 00032 // 00033 // The backing_file_offset field gives the offset from the beginning of the file to a string 00034 // containing the path to a file; backing_file_size gives the length of this string, which 00035 // isn't nul-terminated. If this image is a snapshot image, then this will be the path to 00036 // the original file. 00037 // 00038 be_uint64_t backing_file_offset; 00039 be_uint32_t backing_file_size; 00040 00041 // 00042 // The mtime field can be ignored. 00043 // 00044 be_uint32_t mtime; 00045 00046 // 00047 // The next 8 bytes contain the size, in bytes, of the block device represented by the image. 00048 // 00049 be_uint64_t size; 00050 00051 // 00052 // The cluster_bits and l2_bits fields, between them, describe how to map an image offset 00053 // address to a location within the file. The cluster_bits field determines the number of 00054 // lower bits of the offset address are used as an index within a cluster; the l2_bits 00055 // field gives the number of bits used as an index withing the L2 table. 00056 // 00057 uint8_t cluster_bits; 00058 uint8_t l2_bits; 00059 00060 // 00061 // The crypt_method field is 0 if no encryption has been used, 00062 // and 1 if AES encryption has been used. 00063 // 00064 be_uint32_t crypt_method; 00065 00066 // 00067 // The l1_table_offset gives the offset within the file of the L1 table. 00068 // 00069 be_uint64_t l1_table_offset; 00070 }; 00071 00072 struct qcow_image : public block_driver 00073 { 00074 // 00075 // ... to be implemented ... 00076 // ... file size may grow. how to handle that in an L4 dataspace? ... 00077 // 00078 }; 00079 00080 #endif 00081 00082 // ***** end of source ***** // 00083