Diff for /qemu/block-bochs.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2018/04/24 16:37:52 version 1.1.1.2, 2018/04/24 16:45:05
Line 28 Line 28
 /**************************************************************/  /**************************************************************/
   
 #define HEADER_MAGIC "Bochs Virtual HD Image"  #define HEADER_MAGIC "Bochs Virtual HD Image"
 #define HEADER_VERSION 0x00010000  #define HEADER_VERSION 0x00020000
   #define HEADER_V1 0x00010000
 #define HEADER_SIZE 512  #define HEADER_SIZE 512
   
 #define REDOLOG_TYPE "Redolog"  #define REDOLOG_TYPE "Redolog"
Line 37 Line 38
 // not allocated: 0xffffffff  // not allocated: 0xffffffff
   
 // always little-endian  // always little-endian
 struct bochs_header {  struct bochs_header_v1 {
     char magic[32]; // "Bochs Virtual HD Image"      char magic[32]; // "Bochs Virtual HD Image"
     char type[16]; // "Redolog"      char type[16]; // "Redolog"
     char subtype[16]; // "Undoable" / "Volatile" / "Growing"      char subtype[16]; // "Undoable" / "Volatile" / "Growing"
Line 56  struct bochs_header { Line 57  struct bochs_header {
     } extra;      } extra;
 };  };
   
   // always little-endian
   struct bochs_header {
       char magic[32]; // "Bochs Virtual HD Image"
       char type[16]; // "Redolog"
       char subtype[16]; // "Undoable" / "Volatile" / "Growing"
       uint32_t version;
       uint32_t header; // size of header
       
       union {
           struct {
               uint32_t catalog; // num of entries
               uint32_t bitmap; // bitmap size
               uint32_t extent; // extent size
               uint32_t reserved; // for ???
               uint64_t disk; // disk size
               char padding[HEADER_SIZE - 64 - 8 - 24];
           } redolog;
           char padding[HEADER_SIZE - 64 - 8];
       } extra;
   };
   
 typedef struct BDRVBochsState {  typedef struct BDRVBochsState {
     int fd;      int fd;
   
Line 79  static int bochs_probe(const uint8_t *bu Line 101  static int bochs_probe(const uint8_t *bu
     if (!strcmp(bochs->magic, HEADER_MAGIC) &&      if (!strcmp(bochs->magic, HEADER_MAGIC) &&
         !strcmp(bochs->type, REDOLOG_TYPE) &&          !strcmp(bochs->type, REDOLOG_TYPE) &&
         !strcmp(bochs->subtype, GROWING_TYPE) &&          !strcmp(bochs->subtype, GROWING_TYPE) &&
         (le32_to_cpu(bochs->version) == HEADER_VERSION))          ((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
           (le32_to_cpu(bochs->version) == HEADER_V1)))
         return 100;          return 100;
   
     return 0;      return 0;
 }  }
   
 static int bochs_open(BlockDriverState *bs, const char *filename)  static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
 {  {
     BDRVBochsState *s = bs->opaque;      BDRVBochsState *s = bs->opaque;
     int fd, i;      int fd, i;
     struct bochs_header bochs;      struct bochs_header bochs;
       struct bochs_header_v1 header_v1;
   
     fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);      fd = open(filename, O_RDWR | O_BINARY);
     if (fd < 0) {      if (fd < 0) {
         fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);          fd = open(filename, O_RDONLY | O_BINARY);
         if (fd < 0)          if (fd < 0)
             return -1;              return -1;
     }      }
Line 109  static int bochs_open(BlockDriverState * Line 133  static int bochs_open(BlockDriverState *
     if (strcmp(bochs.magic, HEADER_MAGIC) ||      if (strcmp(bochs.magic, HEADER_MAGIC) ||
         strcmp(bochs.type, REDOLOG_TYPE) ||          strcmp(bochs.type, REDOLOG_TYPE) ||
         strcmp(bochs.subtype, GROWING_TYPE) ||          strcmp(bochs.subtype, GROWING_TYPE) ||
         (le32_to_cpu(bochs.version) != HEADER_VERSION)) {          ((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
           (le32_to_cpu(bochs.version) != HEADER_V1))) {
         goto fail;          goto fail;
     }      }
   
     bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;      if (le32_to_cpu(bochs.version) == HEADER_V1) {
         memcpy(&header_v1, &bochs, sizeof(bochs));
         bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512;
       } else {
         bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
       }
   
     lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);      lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);
   

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


unix.superglobalmegacorp.com