From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Jeff Cody <jcody@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL v2 21/37] block: vhdx - log support struct and defines
Date: Fri, 8 Nov 2013 11:12:15 +0100 [thread overview]
Message-ID: <1383905551-16411-22-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1383905551-16411-1-git-send-email-stefanha@redhat.com>
From: Jeff Cody <jcody@redhat.com>
This adds some magic number defines, and internal structure definitions
for VHDX log replay support. The struct VHDXLogEntries does not reflect
an on-disk data structure, and thus does not need to be packed.
Some minor code style fixes are applied as well.
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/vhdx.h | 46 ++++++++++++++++++++++++++++++----------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/block/vhdx.h b/block/vhdx.h
index 2f7461d..154c55a 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -30,12 +30,12 @@
* 0.........64KB...........128KB........192KB..........256KB................1MB
*/
-#define VHDX_HEADER_BLOCK_SIZE (64*1024)
+#define VHDX_HEADER_BLOCK_SIZE (64 * 1024)
#define VHDX_FILE_ID_OFFSET 0
-#define VHDX_HEADER1_OFFSET (VHDX_HEADER_BLOCK_SIZE*1)
-#define VHDX_HEADER2_OFFSET (VHDX_HEADER_BLOCK_SIZE*2)
-#define VHDX_REGION_TABLE_OFFSET (VHDX_HEADER_BLOCK_SIZE*3)
+#define VHDX_HEADER1_OFFSET (VHDX_HEADER_BLOCK_SIZE * 1)
+#define VHDX_HEADER2_OFFSET (VHDX_HEADER_BLOCK_SIZE * 2)
+#define VHDX_REGION_TABLE_OFFSET (VHDX_HEADER_BLOCK_SIZE * 3)
/*
@@ -77,10 +77,10 @@ typedef struct QEMU_PACKED MSGUID {
#define guid_eq(a, b) \
(memcmp(&(a), &(b), sizeof(MSGUID)) == 0)
-#define VHDX_HEADER_SIZE (4*1024) /* although the vhdx_header struct in disk
- is only 582 bytes, for purposes of crc
- the header is the first 4KB of the 64KB
- block */
+#define VHDX_HEADER_SIZE (4 * 1024) /* although the vhdx_header struct in disk
+ is only 582 bytes, for purposes of crc
+ the header is the first 4KB of the 64KB
+ block */
/* The full header is 4KB, although the actual header data is much smaller.
* But for the checksum calculation, it is over the entire 4KB structure,
@@ -92,7 +92,7 @@ typedef struct QEMU_PACKED VHDXHeader {
VHDX file has 2 of these headers,
and only the header with the highest
sequence number is valid */
- MSGUID file_write_guid; /* 128 bit unique identifier. Must be
+ MSGUID file_write_guid; /* 128 bit unique identifier. Must be
updated to new, unique value before
the first modification is made to
file */
@@ -151,7 +151,10 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
/* ---- LOG ENTRY STRUCTURES ---- */
+#define VHDX_LOG_MIN_SIZE (1024 * 1024)
+#define VHDX_LOG_SECTOR_SIZE 4096
#define VHDX_LOG_HDR_SIZE 64
+#define VHDX_LOG_SIGNATURE 0x65676f6c
typedef struct QEMU_PACKED VHDXLogEntryHeader {
uint32_t signature; /* "loge" in ASCII */
uint32_t checksum; /* CRC-32C hash of the 64KB table */
@@ -174,7 +177,8 @@ typedef struct QEMU_PACKED VHDXLogEntryHeader {
} VHDXLogEntryHeader;
#define VHDX_LOG_DESC_SIZE 32
-
+#define VHDX_LOG_DESC_SIGNATURE 0x63736564
+#define VHDX_LOG_ZERO_SIGNATURE 0x6f72657a
typedef struct QEMU_PACKED VHDXLogDescriptor {
uint32_t signature; /* "zero" or "desc" in ASCII */
union {
@@ -194,6 +198,7 @@ typedef struct QEMU_PACKED VHDXLogDescriptor {
vhdx_log_entry_header */
} VHDXLogDescriptor;
+#define VHDX_LOG_DATA_SIGNATURE 0x61746164
typedef struct QEMU_PACKED VHDXLogDataSector {
uint32_t data_signature; /* "data" in ASCII */
uint32_t sequence_high; /* 4 MSB of 8 byte sequence_number */
@@ -219,12 +224,12 @@ typedef struct QEMU_PACKED VHDXLogDataSector {
#define SB_BLOCK_PRESENT 6
/* per the spec */
-#define VHDX_MAX_SECTORS_PER_BLOCK (1<<23)
+#define VHDX_MAX_SECTORS_PER_BLOCK (1 << 23)
/* upper 44 bits are the file offset in 1MB units lower 3 bits are the state
other bits are reserved */
#define VHDX_BAT_STATE_BIT_MASK 0x07
-#define VHDX_BAT_FILE_OFF_BITS (64-44)
+#define VHDX_BAT_FILE_OFF_BITS (64 - 44)
typedef uint64_t VHDXBatEntry;
/* ---- METADATA REGION STRUCTURES ---- */
@@ -252,8 +257,8 @@ typedef struct QEMU_PACKED VHDXMetadataTableEntry {
metadata region */
/* note: if length = 0, so is offset */
uint32_t length; /* length of metadata. <= 1MB. */
- uint32_t data_bits; /* least-significant 3 bits are flags, the
- rest are reserved (see above) */
+ uint32_t data_bits; /* least-significant 3 bits are flags,
+ the rest are reserved (see above) */
uint32_t reserved2;
} VHDXMetadataTableEntry;
@@ -265,8 +270,8 @@ typedef struct QEMU_PACKED VHDXMetadataTableEntry {
typedef struct QEMU_PACKED VHDXFileParameters {
uint32_t block_size; /* size of each payload block, always
power of 2, <= 256MB and >= 1MB. */
- uint32_t data_bits; /* least-significant 2 bits are flags, the rest
- are reserved (see above) */
+ uint32_t data_bits; /* least-significant 2 bits are flags,
+ the rest are reserved (see above) */
} VHDXFileParameters;
typedef struct QEMU_PACKED VHDXVirtualDiskSize {
@@ -318,6 +323,13 @@ typedef struct VHDXMetadataEntries {
uint16_t present;
} VHDXMetadataEntries;
+typedef struct VHDXLogEntries {
+ uint64_t offset;
+ uint64_t length;
+ uint32_t head;
+ uint32_t tail;
+} VHDXLogEntries;
+
typedef struct BDRVVHDXState {
CoMutex lock;
@@ -351,6 +363,8 @@ typedef struct BDRVVHDXState {
MSGUID session_guid;
+ VHDXLogEntries log;
+
VHDXParentLocatorHeader parent_header;
VHDXParentLocatorEntry *parent_entries;
--
1.8.3.1
next prev parent reply other threads:[~2013-11-08 10:14 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 10:11 [Qemu-devel] [PULL v2 00/37] Block patches Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 01/37] qapi: Fix comment for create-type to match code Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 02/37] qemu-iotests: Filter out actual image size in 067 Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 03/37] block/raw-posix: fix FreeBSD compilation Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 04/37] block: qemu-iotests, add quotes to $TEST_IMG usage io pattern tests Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 05/37] block: qemu-iotests, fix _make_test_img() to work with spaced pathnames Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 06/37] block: qemu-iotests, add quotes to $TEST_IMG.base usage in 017 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 07/37] block: qemu-iotests, add quotes to $TEST_IMG usage in 019 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 08/37] block: qemu-iotests, removes duplicate double quotes in 039 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 09/37] block: qemu-iotests, add quotes to $TEST_IMG usage for 051 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 10/37] block: qemu-iotests, add quotes to $TEST_IMG usage in 061 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 11/37] blockdev: fix drive_init() opts and bs_opts leaks Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 12/37] libqtest: rename qmp() to qmp_discard_response() Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 13/37] libqtest: add qmp(fmt, ...) -> QDict* function Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 14/37] blockdev-test: add test case for drive_add duplicate IDs Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 15/37] qdev-monitor-test: add device_add leak test cases Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 16/37] block: Save errno before error_setg_errno Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 17/37] block/vpc: fix virtual size for images created with disk2vhd Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 18/37] block: vhdx - minor comments and typo correction Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 19/37] block: vhdx - add header update capability Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 20/37] block: vhdx code movement - VHDXMetadataEntries and BDRVVHDXState to header Stefan Hajnoczi
2013-11-08 10:12 ` Stefan Hajnoczi [this message]
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 22/37] block: vhdx - break endian translation functions out Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 23/37] block: vhdx - update log guid in header, and first write tracker Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 24/37] block: vhdx code movement - move vhdx_close() above vhdx_open() Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 25/37] block: vhdx - log parsing, replay, and flush support Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 26/37] block: vhdx - add region overlap detection for image files Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 27/37] block: vhdx - add log write support Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 28/37] block: vhdx " Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 29/37] block: vhdx - remove BAT file offset bit shifting Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 30/37] block: vhdx - move more endian translations to vhdx-endian.c Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 31/37] block: vhdx - break out code operations to functions Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 32/37] block: vhdx - fix comment typos in header, fix incorrect struct fields Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 33/37] block: vhdx - add .bdrv_create() support Stefan Hajnoczi
2014-02-21 12:06 ` Alexander Graf
2014-02-21 14:15 ` Jeff Cody
2014-02-24 8:47 ` Stefan Hajnoczi
2014-03-03 19:58 ` Jeff Cody
2014-03-04 0:10 ` Alexander Graf
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 34/37] block: vhdx - update _make_test_img() to filter out vhdx options Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 35/37] block: qemu-iotests for vhdx, add write test support Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 36/37] block: vhdx qemu-iotest - log replay of data sector Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 37/37] block: Round up total_sectors Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1383905551-16411-22-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@amazon.com \
--cc=jcody@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).