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-4.0-testing] blktap: Fix old QCow tapdisk image han

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] blktap: Fix old QCow tapdisk image handling
From: "Xen patchbot-4.0-testing" <patchbot-4.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 May 2010 00:41:28 -0700
Delivery-date: Fri, 14 May 2010 00:46:34 -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 1273481158 -3600
# Node ID fa3117958940f701d11e9a9775974b8e3e09762e
# Parent  ca9a5b6f1c203873437820e219684015f82f67bd
blktap: Fix old QCow tapdisk image handling

When I tried to use QCow image, I found that only each second boot is
successful. As I discovered, this is caused by wrong handling old qcow
tapdisk images. Extended header flag is not stored correctly so the
blktap tries to change endian fo L1 table on each startup.

From: Miroslav Rezanina <mrezanin@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   21269:d6cf080505cd
xen-unstable date:        Tue May 04 12:38:19 2010 +0100
---
 tools/blktap/drivers/block-qcow.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff -r ca9a5b6f1c20 -r fa3117958940 tools/blktap/drivers/block-qcow.c
--- a/tools/blktap/drivers/block-qcow.c Mon May 10 09:45:34 2010 +0100
+++ b/tools/blktap/drivers/block-qcow.c Mon May 10 09:45:58 2010 +0100
@@ -862,17 +862,23 @@ static int tdqcow_open (struct disk_driv
                be32_to_cpus(&exthdr->xmagic);
                if(exthdr->xmagic != XEN_MAGIC) 
                        goto end_xenhdr;
-    
+       
+               be32_to_cpus(&exthdr->flags);
                /* Try to detect old tapdisk images. They have to be fixed 
because 
                 * they don't use big endian but native endianess for the L1 
table */
                if ((exthdr->flags & EXTHDR_L1_BIG_ENDIAN) == 0) {
-
+                       QCowHeader_ext *tmphdr = (QCowHeader_ext *)(buf2 + 
sizeof(QCowHeader));
                        /* 
                           The image is broken. Fix it. The L1 table has 
already been 
                           byte-swapped, so we can write it to the image file 
as it is
                           currently in memory. Then swap it back to native 
endianess
                           for operation.
                         */
+
+                       /* Change ENDIAN flag and copy it to store buffer */
+                       exthdr->flags |= EXTHDR_L1_BIG_ENDIAN;
+                       tmphdr->flags = cpu_to_be32(exthdr->flags);
+
 
                        DPRINTF("qcow: Converting image to big endian L1 
table\n");
 
@@ -888,13 +894,6 @@ static int tdqcow_open (struct disk_driv
                                cpu_to_be64s(&s->l1_table[i]);
                        }
 
-                       /* Write the big endian flag to the extended header */
-                       exthdr->flags |= EXTHDR_L1_BIG_ENDIAN;
-
-                       if (write(fd, buf, 512) != 512) {
-                               DPRINTF("qcow: Failed to write extended 
header\n");
-                               goto fail;
-                       }
                }
 
                /*Finally check the L1 table cksum*/
@@ -905,7 +904,6 @@ static int tdqcow_open (struct disk_driv
                        goto end_xenhdr;
                        
                be32_to_cpus(&exthdr->min_cluster_alloc);
-               be32_to_cpus(&exthdr->flags);
                s->sparse = (exthdr->flags & SPARSE_FILE);
                s->min_cluster_alloc = exthdr->min_cluster_alloc; 
        }
@@ -1263,6 +1261,7 @@ int qcow_create(const char *filename, ui
        } else
                flags = SPARSE_FILE;
 
+       flags |= EXTHDR_L1_BIG_ENDIAN;
        exthdr.flags = cpu_to_be32(flags);
        
        /* write all the data */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] blktap: Fix old QCow tapdisk image handling, Xen patchbot-4.0-testing <=