* [PATCH 2/2] tools - fix empty QCOW images (bug 1430 part 2)
@ 2009-06-02 23:28 Andre Przywara
0 siblings, 0 replies; only message in thread
From: Andre Przywara @ 2009-06-02 23:28 UTC (permalink / raw)
To: keir.fraser; +Cc: xen-devel
[-- Attachment #1: Type: text/plain, Size: 879 bytes --]
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@amd.com>
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
[-- Attachment #2: empty_blktap_qcow.patch --]
[-- Type: text/plain, Size: 1152 bytes --]
# HG changeset patch
# User Andre Przywara <andre.przywara@amd.com>
# 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;
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-02 23:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 23:28 [PATCH 2/2] tools - fix empty QCOW images (bug 1430 part 2) Andre Przywara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.