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-devel

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

To: keir.fraser@xxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 2/2] tools - fix empty QCOW images (bug 1430 part 2)
From: Andre Przywara <andre.przywara@xxxxxxx>
Date: Wed, 3 Jun 2009 01:28:32 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 02 Jun 2009 16:28:49 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.18 (X11/20081105)
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
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/2] tools - fix empty QCOW images (bug 1430 part 2), Andre Przywara <=