|
|
9ae3a8 |
From a60094cdc27c9913ad93fc42383161ed40015e44 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 20 Nov 2013 19:43:53 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 10/25] block: vhdx - log support struct and defines
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Message-id: <2dae7f05c8661b506f3bbaa60cd8b3ad35d7a7e4.1384975172.git.jcody@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55803
|
|
|
9ae3a8 |
O-Subject: [RHEL7 qemu-kvm PATCH 10/26] block: vhdx - log support struct and defines
|
|
|
9ae3a8 |
Bugzilla: 879234
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This adds some magic number defines, and internal structure definitions
|
|
|
9ae3a8 |
for VHDX log replay support. The struct VHDXLogEntries does not reflect
|
|
|
9ae3a8 |
an on-disk data structure, and thus does not need to be packed.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Some minor code style fixes are applied as well.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 625565d27e8d7c7f7238ccd118a2cd49c1c52963)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/vhdx.h | 46 ++++++++++++++++++++++++++++++----------------
|
|
|
9ae3a8 |
1 file changed, 30 insertions(+), 16 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/vhdx.h | 46 ++++++++++++++++++++++++++++++----------------
|
|
|
9ae3a8 |
1 files changed, 30 insertions(+), 16 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/vhdx.h b/block/vhdx.h
|
|
|
9ae3a8 |
index 57375ff..76ce4aa 100644
|
|
|
9ae3a8 |
--- a/block/vhdx.h
|
|
|
9ae3a8 |
+++ b/block/vhdx.h
|
|
|
9ae3a8 |
@@ -30,12 +30,12 @@
|
|
|
9ae3a8 |
* 0.........64KB...........128KB........192KB..........256KB................1MB
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define VHDX_HEADER_BLOCK_SIZE (64*1024)
|
|
|
9ae3a8 |
+#define VHDX_HEADER_BLOCK_SIZE (64 * 1024)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define VHDX_FILE_ID_OFFSET 0
|
|
|
9ae3a8 |
-#define VHDX_HEADER1_OFFSET (VHDX_HEADER_BLOCK_SIZE*1)
|
|
|
9ae3a8 |
-#define VHDX_HEADER2_OFFSET (VHDX_HEADER_BLOCK_SIZE*2)
|
|
|
9ae3a8 |
-#define VHDX_REGION_TABLE_OFFSET (VHDX_HEADER_BLOCK_SIZE*3)
|
|
|
9ae3a8 |
+#define VHDX_HEADER1_OFFSET (VHDX_HEADER_BLOCK_SIZE * 1)
|
|
|
9ae3a8 |
+#define VHDX_HEADER2_OFFSET (VHDX_HEADER_BLOCK_SIZE * 2)
|
|
|
9ae3a8 |
+#define VHDX_REGION_TABLE_OFFSET (VHDX_HEADER_BLOCK_SIZE * 3)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
@@ -77,10 +77,10 @@ typedef struct QEMU_PACKED MSGUID {
|
|
|
9ae3a8 |
#define guid_eq(a, b) \
|
|
|
9ae3a8 |
(memcmp(&(a), &(b), sizeof(MSGUID)) == 0)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define VHDX_HEADER_SIZE (4*1024) /* although the vhdx_header struct in disk
|
|
|
9ae3a8 |
- is only 582 bytes, for purposes of crc
|
|
|
9ae3a8 |
- the header is the first 4KB of the 64KB
|
|
|
9ae3a8 |
- block */
|
|
|
9ae3a8 |
+#define VHDX_HEADER_SIZE (4 * 1024) /* although the vhdx_header struct in disk
|
|
|
9ae3a8 |
+ is only 582 bytes, for purposes of crc
|
|
|
9ae3a8 |
+ the header is the first 4KB of the 64KB
|
|
|
9ae3a8 |
+ block */
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* The full header is 4KB, although the actual header data is much smaller.
|
|
|
9ae3a8 |
* But for the checksum calculation, it is over the entire 4KB structure,
|
|
|
9ae3a8 |
@@ -92,7 +92,7 @@ typedef struct QEMU_PACKED VHDXHeader {
|
|
|
9ae3a8 |
VHDX file has 2 of these headers,
|
|
|
9ae3a8 |
and only the header with the highest
|
|
|
9ae3a8 |
sequence number is valid */
|
|
|
9ae3a8 |
- MSGUID file_write_guid; /* 128 bit unique identifier. Must be
|
|
|
9ae3a8 |
+ MSGUID file_write_guid; /* 128 bit unique identifier. Must be
|
|
|
9ae3a8 |
updated to new, unique value before
|
|
|
9ae3a8 |
the first modification is made to
|
|
|
9ae3a8 |
file */
|
|
|
9ae3a8 |
@@ -151,7 +151,10 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* ---- LOG ENTRY STRUCTURES ---- */
|
|
|
9ae3a8 |
+#define VHDX_LOG_MIN_SIZE (1024 * 1024)
|
|
|
9ae3a8 |
+#define VHDX_LOG_SECTOR_SIZE 4096
|
|
|
9ae3a8 |
#define VHDX_LOG_HDR_SIZE 64
|
|
|
9ae3a8 |
+#define VHDX_LOG_SIGNATURE 0x65676f6c
|
|
|
9ae3a8 |
typedef struct QEMU_PACKED VHDXLogEntryHeader {
|
|
|
9ae3a8 |
uint32_t signature; /* "loge" in ASCII */
|
|
|
9ae3a8 |
uint32_t checksum; /* CRC-32C hash of the 64KB table */
|
|
|
9ae3a8 |
@@ -174,7 +177,8 @@ typedef struct QEMU_PACKED VHDXLogEntryHeader {
|
|
|
9ae3a8 |
} VHDXLogEntryHeader;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define VHDX_LOG_DESC_SIZE 32
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
+#define VHDX_LOG_DESC_SIGNATURE 0x63736564
|
|
|
9ae3a8 |
+#define VHDX_LOG_ZERO_SIGNATURE 0x6f72657a
|
|
|
9ae3a8 |
typedef struct QEMU_PACKED VHDXLogDescriptor {
|
|
|
9ae3a8 |
uint32_t signature; /* "zero" or "desc" in ASCII */
|
|
|
9ae3a8 |
union {
|
|
|
9ae3a8 |
@@ -194,6 +198,7 @@ typedef struct QEMU_PACKED VHDXLogDescriptor {
|
|
|
9ae3a8 |
vhdx_log_entry_header */
|
|
|
9ae3a8 |
} VHDXLogDescriptor;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+#define VHDX_LOG_DATA_SIGNATURE 0x61746164
|
|
|
9ae3a8 |
typedef struct QEMU_PACKED VHDXLogDataSector {
|
|
|
9ae3a8 |
uint32_t data_signature; /* "data" in ASCII */
|
|
|
9ae3a8 |
uint32_t sequence_high; /* 4 MSB of 8 byte sequence_number */
|
|
|
9ae3a8 |
@@ -219,12 +224,12 @@ typedef struct QEMU_PACKED VHDXLogDataSector {
|
|
|
9ae3a8 |
#define SB_BLOCK_PRESENT 6
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* per the spec */
|
|
|
9ae3a8 |
-#define VHDX_MAX_SECTORS_PER_BLOCK (1<<23)
|
|
|
9ae3a8 |
+#define VHDX_MAX_SECTORS_PER_BLOCK (1 << 23)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* upper 44 bits are the file offset in 1MB units lower 3 bits are the state
|
|
|
9ae3a8 |
other bits are reserved */
|
|
|
9ae3a8 |
#define VHDX_BAT_STATE_BIT_MASK 0x07
|
|
|
9ae3a8 |
-#define VHDX_BAT_FILE_OFF_BITS (64-44)
|
|
|
9ae3a8 |
+#define VHDX_BAT_FILE_OFF_BITS (64 - 44)
|
|
|
9ae3a8 |
typedef uint64_t VHDXBatEntry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* ---- METADATA REGION STRUCTURES ---- */
|
|
|
9ae3a8 |
@@ -252,8 +257,8 @@ typedef struct QEMU_PACKED VHDXMetadataTableEntry {
|
|
|
9ae3a8 |
metadata region */
|
|
|
9ae3a8 |
/* note: if length = 0, so is offset */
|
|
|
9ae3a8 |
uint32_t length; /* length of metadata. <= 1MB. */
|
|
|
9ae3a8 |
- uint32_t data_bits; /* least-significant 3 bits are flags, the
|
|
|
9ae3a8 |
- rest are reserved (see above) */
|
|
|
9ae3a8 |
+ uint32_t data_bits; /* least-significant 3 bits are flags,
|
|
|
9ae3a8 |
+ the rest are reserved (see above) */
|
|
|
9ae3a8 |
uint32_t reserved2;
|
|
|
9ae3a8 |
} VHDXMetadataTableEntry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -265,8 +270,8 @@ typedef struct QEMU_PACKED VHDXMetadataTableEntry {
|
|
|
9ae3a8 |
typedef struct QEMU_PACKED VHDXFileParameters {
|
|
|
9ae3a8 |
uint32_t block_size; /* size of each payload block, always
|
|
|
9ae3a8 |
power of 2, <= 256MB and >= 1MB. */
|
|
|
9ae3a8 |
- uint32_t data_bits; /* least-significant 2 bits are flags, the rest
|
|
|
9ae3a8 |
- are reserved (see above) */
|
|
|
9ae3a8 |
+ uint32_t data_bits; /* least-significant 2 bits are flags,
|
|
|
9ae3a8 |
+ the rest are reserved (see above) */
|
|
|
9ae3a8 |
} VHDXFileParameters;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef struct QEMU_PACKED VHDXVirtualDiskSize {
|
|
|
9ae3a8 |
@@ -318,6 +323,13 @@ typedef struct VHDXMetadataEntries {
|
|
|
9ae3a8 |
uint16_t present;
|
|
|
9ae3a8 |
} VHDXMetadataEntries;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+typedef struct VHDXLogEntries {
|
|
|
9ae3a8 |
+ uint64_t offset;
|
|
|
9ae3a8 |
+ uint64_t length;
|
|
|
9ae3a8 |
+ uint32_t head;
|
|
|
9ae3a8 |
+ uint32_t tail;
|
|
|
9ae3a8 |
+} VHDXLogEntries;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
typedef struct BDRVVHDXState {
|
|
|
9ae3a8 |
CoMutex lock;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -351,6 +363,8 @@ typedef struct BDRVVHDXState {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
MSGUID session_guid;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ VHDXLogEntries log;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
VHDXParentLocatorHeader parent_header;
|
|
|
9ae3a8 |
VHDXParentLocatorEntry *parent_entries;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|