[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] blktap: fix empty QCOW images (bug 1430 part 2)
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |