WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] blktap: fix empty QCOW images (bug 1430 p

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] blktap: fix empty QCOW images (bug 1430 part 2)
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Jun 2009 10:25:15 -0700
Delivery-date: Thu, 04 Jun 2009 10:25:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1244023910 -3600
# Node ID c5fb6374e79fba152e149cdd55a5744d43762667
# Parent  f989778298d8074ad9135f3a538d449b6baab947
blktap: fix empty QCOW images (bug 1430 part 2)

Empty QCOW images consist of only the L1 table, this results in a
file size which is not sector-aligned. Since blktap uses O_DIRECT, the
block aligned read of the L1 table will go beyond the end of file and
thus returns the actual file size and not the expected length.
This patch checks whether at least the L1 table has been read.

This should fix bug 1430.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 tools/blktap/drivers/block-qcow.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff -r f989778298d8 -r c5fb6374e79f tools/blktap/drivers/block-qcow.c
--- a/tools/blktap/drivers/block-qcow.c Wed Jun 03 11:11:04 2009 +0100
+++ b/tools/blktap/drivers/block-qcow.c Wed Jun 03 11:11:50 2009 +0100
@@ -824,7 +824,7 @@ static int tdqcow_open (struct disk_driv
        l1_table_block = ROUNDUP(l1_table_block, 512);
        ret = posix_memalign((void **)&buf2, 4096, l1_table_block);
        if (ret != 0) goto fail;
-       if (read(fd, buf2, l1_table_block) != l1_table_block)
+       if (read(fd, buf2, l1_table_block) < l1_table_size + s->l1_table_offset)
                goto fail;
        memcpy(s->l1_table, buf2 + s->l1_table_offset, l1_table_size);
 
@@ -878,7 +878,8 @@ static int tdqcow_open (struct disk_driv
 
                        memcpy(buf2 + s->l1_table_offset, s->l1_table, 
l1_table_size);
                        lseek(fd, 0, SEEK_SET);
-                       if (write(fd, buf2, l1_table_block) != l1_table_block) {
+                       if (write(fd, buf2, l1_table_block) < 
+                               l1_table_size + s->l1_table_offset) {
                                DPRINTF("qcow: Failed to write new L1 table\n");
                                goto fail;
                        }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] blktap: fix empty QCOW images (bug 1430 part 2), Xen patchbot-unstable <=