From 1a848fd4517820981b542e0d10e64c0426414229 Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Wed, 30 Oct 2013 10:44:46 -0400 Subject: block: vhdx - add region overlap detection for image files Regions in the image file cannot overlap - the log, region tables, and metdata must all be unique and non-overlapping. This adds region checking by means of a QLIST; there can be a variable number of regions and metadata (there may be metadata or region tables that we do not recognize / know about, but are not required). This adds the capability to register a region for later checking, and to check against registered regions for any overlap. Also, if neither the BAT or Metadata region tables are found, return error. Signed-off-by: Jeff Cody Signed-off-by: Stefan Hajnoczi --- block/vhdx.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'block/vhdx.h') diff --git a/block/vhdx.h b/block/vhdx.h index 584ebec..d906559 100644 --- a/block/vhdx.h +++ b/block/vhdx.h @@ -230,6 +230,7 @@ typedef struct QEMU_PACKED VHDXLogDataSector { other bits are reserved */ #define VHDX_BAT_STATE_BIT_MASK 0x07 #define VHDX_BAT_FILE_OFF_BITS (64 - 44) +#define VHDX_BAT_FILE_OFF_MASK 0xFFFFFFFFFFF00000 /* upper 44 bits */ typedef uint64_t VHDXBatEntry; /* ---- METADATA REGION STRUCTURES ---- */ @@ -334,6 +335,12 @@ typedef struct VHDXLogEntries { uint32_t tail; } VHDXLogEntries; +typedef struct VHDXRegionEntry { + uint64_t start; + uint64_t end; + QLIST_ENTRY(VHDXRegionEntry) entries; +} VHDXRegionEntry; + typedef struct BDRVVHDXState { CoMutex lock; @@ -374,6 +381,8 @@ typedef struct BDRVVHDXState { VHDXParentLocatorEntry *parent_entries; Error *migration_blocker; + + QLIST_HEAD(VHDXRegionHead, VHDXRegionEntry) regions; } BDRVVHDXState; void vhdx_guid_generate(MSGUID *guid); -- cgit v1.1