[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/2] tools - fix empty QCOW images (bug 1430 part 2)



Hi,

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.
Please also apply to all bugfix trees.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

Regards,
Andre.

--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 488-3567-12
----to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Jochen Polster; Thomas M. McCoy; Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
# HG changeset patch
# User Andre Przywara <andre.przywara@xxxxxxx>
# Date 1243981771 -7200
# Node ID aef9bba654f1d2ce5c7b451da7a5f5c92408c42b
# Parent  3c62e9afafc6a70cb897ea77a99d5da1f6b9652e
allow empty QCOW images in blktap

diff -r 3c62e9afafc6 -r aef9bba654f1 tools/blktap/drivers/block-qcow.c
--- a/tools/blktap/drivers/block-qcow.c Wed Jun 03 00:25:25 2009 +0200
+++ b/tools/blktap/drivers/block-qcow.c Wed Jun 03 00:29:31 2009 +0200
@@ -824,7 +824,7 @@
        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 @@
 
                        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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.