From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Fam Zheng <famz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 10/15] vmdk: store fields of VmdkMetaData in cpu endian
Date: Fri, 3 May 2013 13:52:47 +0200 [thread overview]
Message-ID: <1367581972-4208-11-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1367581972-4208-1-git-send-email-stefanha@redhat.com>
From: Fam Zheng <famz@redhat.com>
Previously VmdkMetaData.offset is stored little endian while other
fields are cpu endian. This changes offset to cpu endian and convert
before writing to image.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/vmdk.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 0463d3b..d98f304 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -813,14 +813,15 @@ static int get_whole_cluster(BlockDriverState *bs,
static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data)
{
+ uint32_t offset;
+ QEMU_BUILD_BUG_ON(sizeof(offset) != sizeof(m_data->offset));
+ offset = cpu_to_le32(m_data->offset);
/* update L2 table */
if (bdrv_pwrite_sync(
extent->file,
((int64_t)m_data->l2_offset * 512)
+ (m_data->l2_index * sizeof(m_data->offset)),
- &(m_data->offset),
- sizeof(m_data->offset)
- ) < 0) {
+ &offset, sizeof(offset)) < 0) {
return VMDK_ERROR;
}
/* update backup L2 table */
@@ -830,8 +831,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data)
extent->file,
((int64_t)m_data->l2_offset * 512)
+ (m_data->l2_index * sizeof(m_data->offset)),
- &(m_data->offset), sizeof(m_data->offset)
- ) < 0) {
+ &offset, sizeof(offset)) < 0) {
return VMDK_ERROR;
}
}
@@ -848,7 +848,7 @@ static int get_cluster_offset(BlockDriverState *bs,
{
unsigned int l1_index, l2_offset, l2_index;
int min_index, i, j;
- uint32_t min_count, *l2_table, tmp = 0;
+ uint32_t min_count, *l2_table;
bool zeroed = false;
if (m_data) {
@@ -924,8 +924,7 @@ static int get_cluster_offset(BlockDriverState *bs,
}
*cluster_offset >>= 9;
- tmp = cpu_to_le32(*cluster_offset);
- l2_table[l2_index] = tmp;
+ l2_table[l2_index] = cpu_to_le32(*cluster_offset);
/* First of all we write grain itself, to avoid race condition
* that may to corrupt the image.
@@ -938,7 +937,7 @@ static int get_cluster_offset(BlockDriverState *bs,
}
if (m_data) {
- m_data->offset = tmp;
+ m_data->offset = *cluster_offset;
m_data->l1_index = l1_index;
m_data->l2_index = l2_index;
m_data->l2_offset = l2_offset;
--
1.8.1.4
next prev parent reply other threads:[~2013-05-03 11:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 11:52 [Qemu-devel] [PULL 00/15] Block patches Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 01/15] qemu: add castagnoli crc32c checksum algorithm Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 02/15] block: vhdx header for the QEMU support of VHDX images Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 03/15] block: initial VHDX driver support framework - supports open and probe Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 04/15] block: add read-only support to VHDX image format Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 05/15] blockdev: Replace "undefined error" in qmp_block_resize Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 06/15] vmdk: named return code Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 07/15] vmdk: add support for “zeroed‐grain” GTE Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 08/15] vmdk: Add option to create zeroed-grain image Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 09/15] vmdk: change magic number to macro Stefan Hajnoczi
2013-05-03 11:52 ` Stefan Hajnoczi [this message]
2013-05-03 11:52 ` [Qemu-devel] [PATCH 11/15] vmdk: add bdrv_co_write_zeroes Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 12/15] qemu-iotests: Filter out vmdk creation options Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 13/15] nbd: use g_slice_new() instead of a freelist Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 14/15] nbd: support large NBD requests Stefan Hajnoczi
2013-05-03 11:52 ` [Qemu-devel] [PATCH 15/15] qemu-iotests: Filter out 'adapter_type' 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=1367581972-4208-11-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=famz@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).