From: Prasad Joshi <prasadjoshi124@gmail.com>
To: prasadjoshi124@gmail.com
Cc: mingo@elte.hu, kvm@vger.kernel.org, penberg@kernel.org,
asias.hejun@gmail.com, gorcunov@gmail.com,
levinsasha928@gmail.com, kwolf@redhat.com,
stefanha@linux.vnet.ibm.com, chaitanyakulkarni15@gmail.com
Subject: [PATCH 2/4] kvm tool: avoid byte-order conversion during each read operation
Date: Fri, 15 Apr 2011 15:18:56 +0100 [thread overview]
Message-ID: <1302877138-6695-2-git-send-email-prasadjoshi124@gmail.com> (raw)
In-Reply-To: <1302877138-6695-1-git-send-email-prasadjoshi124@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
---
tools/kvm/qcow.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/kvm/qcow.c b/tools/kvm/qcow.c
index 219fd6b..243bfa8 100644
--- a/tools/kvm/qcow.c
+++ b/tools/kvm/qcow.c
@@ -58,7 +58,7 @@ static int qcow1_read_sector(struct disk_image *self, uint64_t sector, void *dst
if (l1_idx >= q->table.table_size)
goto out_error;
- l2_table_offset = be64_to_cpu(q->table.l1_table[l1_idx]);
+ l2_table_offset = q->table.l1_table[l1_idx];
if (!l2_table_offset)
goto zero_sector;
@@ -128,16 +128,23 @@ struct disk_image_operations qcow1_disk_ops = {
static int qcow_read_l1_table(struct qcow *q)
{
struct qcow1_header *header = q->header;
+ struct qcow_table *table = &q->table;
+ u64 i;
- q->table.table_size = header->size / ((1 << header->l2_bits) * (1 << header->cluster_bits));
+ table->table_size = header->size / ((1 << header->l2_bits) *
+ (1 << header->cluster_bits));
- q->table.l1_table = calloc(q->table.table_size, sizeof(uint64_t));
- if (!q->table.l1_table)
+ table->l1_table = calloc(table->table_size, sizeof(u64));
+ if (!table->l1_table)
return -1;
- if (pread_in_full(q->fd, q->table.l1_table, sizeof(uint64_t) * q->table.table_size, header->l1_table_offset) < 0)
+ if (pread_in_full(q->fd, table->l1_table, sizeof(u64) *
+ table->table_size, header->l1_table_offset) < 0)
return -1;
+ for (i = 0; i < table->table_size; i++)
+ be64_to_cpus(&table->l1_table[i]);
+
return 0;
}
--
1.7.1
next prev parent reply other threads:[~2011-04-15 14:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 14:18 [PATCH 1/4] kvm tool: use correct function names Prasad Joshi
2011-04-15 14:18 ` Prasad Joshi [this message]
2011-04-15 14:18 ` [PATCH 3/4] kvm tool: deallocate the cached l1_table in qcow1_disk_close() and in error path of qcow1_probe() Prasad Joshi
2011-04-15 14:18 ` [PATCH 4/4] kvm tool: check the cluster boundary in the qcow read code Prasad Joshi
2011-04-16 9:23 ` Pekka Enberg
2011-04-16 11:28 ` Prasad Joshi
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=1302877138-6695-2-git-send-email-prasadjoshi124@gmail.com \
--to=prasadjoshi124@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=chaitanyakulkarni15@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=stefanha@linux.vnet.ibm.com \
/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