Skip to contentSkip to conversation

VHDX endian fixes, error reporting

PATCH Applied Jeff Cody 3 participants 5 messages Aug 6, 2014 – Aug 7, 2014 Block layer

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

cover VHDX endian fixes, error reporting

This series is mainly for some bug fixes related to VHDX endianness, stemming from code reviews done by Markus Armbruster and Paolo Bonzini. Once I did some testing on a big-endian machine, several more endian related errors were discovered, as well. All endian related fixes are in patch 2.

Jeff Cody (2):
block: vhdx - add error check
block: VHDX endian fixes

 block/vhdx-endian.c | 11 +++++--
 block/vhdx-log.c    | 48 ++++++++++++++++++-----------
 block/vhdx.c        | 89 +++++++++++++++++++++++++++++++----------------------
 block/vhdx.h        |  1 +
 4 files changed, 93 insertions(+), 56 deletions(-)
Signature · 1 line
1.9.3
author
#1 lore raw

PATCH 1/2 block: vhdx - add error check

This add an error check for an invalid descriptor entry signature, when flushing the log descriptor entries.

---
 block/vhdx-log.c | 5 +++++
 1 file changed, 5 insertions(+)
block/vhdx-log.c +5 -0
index a77c040..7c2630d 100644
@@ -435,6 +435,11 @@ static int vhdx_log_flush_desc(BlockDriverState *bs, VHDXLogDescriptor *desc,
         /* write 'count' sectors of sector */
         memset(buffer, 0, VHDX_LOG_SECTOR_SIZE);
         count = desc->zero_length / VHDX_LOG_SECTOR_SIZE;
+    } else {
+        error_report("Invalid VHDX log descriptor entry signature 0x%" PRIx32,
+                      desc->signature);
+        ret = -EINVAL;
+        goto exit;
     }
 
     file_offset = desc->file_offset;
Signature · 1 line
1.9.3
author
#2 lore raw

PATCH 2/2 block: VHDX endian fixes

In reply to Jeff Cody

This patch contains several changes for endian conversion fixes for VHDX, particularly for big-endian machines (multibyte values in VHDX are all on disk in LE format).

Tests were done with existing qemu-iotests on an IBM POWER7 (8406-71Y). This includes sample images created by Hyper-V, both with dirty logs and without.

In addition, VHDX image files created (and written to) on a BE machine were tested on a LE machine, and vice-versa.

---
 block/vhdx-endian.c | 11 +++++--
 block/vhdx-log.c    | 43 +++++++++++++++-----------
 block/vhdx.c        | 89 +++++++++++++++++++++++++++++++----------------------
 block/vhdx.h        |  1 +
 4 files changed, 88 insertions(+), 56 deletions(-)
block/vhdx-endian.c +9 -2
index fe879ed..0640d3f 100644
@@ -82,8 +82,6 @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d)
     assert(d != NULL);
 
     le32_to_cpus(&d->signature);
-    le32_to_cpus(&d->trailing_bytes);
-    le64_to_cpus(&d->leading_bytes);
     le64_to_cpus(&d->file_offset);
     le64_to_cpus(&d->sequence_number);
 }
@@ -99,6 +97,15 @@ void vhdx_log_desc_le_export(VHDXLogDescriptor *d)
     cpu_to_le64s(&d->sequence_number);
 }
 
+void vhdx_log_data_le_import(VHDXLogDataSector *d)
+{
+    assert(d != NULL);
+
+    le32_to_cpus(&d->data_signature);
+    le32_to_cpus(&d->sequence_high);
+    le32_to_cpus(&d->sequence_low);
+}
+
 void vhdx_log_data_le_export(VHDXLogDataSector *d)
 {
     assert(d != NULL);
block/vhdx-log.c +25 -18

151 lines not on this page · raw message

block/vhdx.c +53 -36

195 lines not on this page · raw message

block/vhdx.h +1 -0
index 5370010..b4a12a0 100644
@@ -435,6 +435,7 @@ void vhdx_header_le_import(VHDXHeader *h);
 void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h);
 void vhdx_log_desc_le_import(VHDXLogDescriptor *d);
 void vhdx_log_desc_le_export(VHDXLogDescriptor *d);
+void vhdx_log_data_le_import(VHDXLogDataSector *d);
 void vhdx_log_data_le_export(VHDXLogDataSector *d);
 void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr);
 void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr);
Signature · 1 line
1.9.3
Reviewed-by on the v1 series
#3 lore raw
In reply to Jeff Cody
Quoted 9 lines · Jeff Cody

This series is mainly for some bug fixes related to VHDX endianness, stemming from code reviews done by Markus Armbruster and Paolo Bonzini. Once I did some testing on a big-endian machine, several more endian related errors were discovered, as well. All endian related fixes are in patch 2.

Jeff Cody (2):
block: vhdx - add error check
block: VHDX endian fixes

Quoted 5 lines
 block/vhdx-endian.c | 11 +++++--
 block/vhdx-log.c    | 48 ++++++++++++++++++-----------
 block/vhdx.c        | 89 +++++++++++++++++++++++++++++++----------------------
 block/vhdx.h        |  1 +
 4 files changed, 93 insertions(+), 56 deletions(-)
Applied
#4 lore raw

Am 07.08.2014 um 12:05 hat Stefan Hajnoczi geschrieben:

Quoted 10 lines · Jeff Cody
Quoted 9 lines

This series is mainly for some bug fixes related to VHDX endianness, stemming from code reviews done by Markus Armbruster and Paolo Bonzini. Once I did some testing on a big-endian machine, several more endian related errors were discovered, as well. All endian related fixes are in patch 2.

Jeff Cody (2):
block: vhdx - add error check
block: VHDX endian fixes

Quoted 7 lines
Quoted 5 lines
 block/vhdx-endian.c | 11 +++++--
 block/vhdx-log.c    | 48 ++++++++++++++++++-----------
 block/vhdx.c        | 89 +++++++++++++++++++++++++++++++----------------------
 block/vhdx.h        |  1 +
 4 files changed, 93 insertions(+), 56 deletions(-)

Thanks, applied to the block branch.

Kevin