qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [6456] block-vpc: Fix disk size (Kevin Wolf)


From: Anthony Liguori
Subject: [Qemu-devel] [6456] block-vpc: Fix disk size (Kevin Wolf)
Date: Mon, 26 Jan 2009 20:26:55 +0000

Revision: 6456
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6456
Author:   aliguori
Date:     2009-01-26 20:26:54 +0000 (Mon, 26 Jan 2009)

Log Message:
-----------
block-vpc: Fix disk size (Kevin Wolf)

VirtualPC bases the virtual disk size on the geometry rather than on
the size stored in the header.

Signed-off-by: Kevin Wolf <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

Modified Paths:
--------------
    trunk/block-vpc.c

Modified: trunk/block-vpc.c
===================================================================
--- trunk/block-vpc.c   2009-01-26 20:26:49 UTC (rev 6455)
+++ trunk/block-vpc.c   2009-01-26 20:26:54 UTC (rev 6456)
@@ -150,6 +150,12 @@
     if (strncmp(footer->creator, "conectix", 8))
         goto fail;
 
+    // The visible size of a image in Virtual PC depends on the geometry
+    // rather than on the size stored in the footer (the size in the footer
+    // is too large usually)
+    bs->total_sectors = (int64_t)
+        be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl;
+
     lseek(s->fd, be64_to_cpu(footer->data_offset), SEEK_SET);
     if (read(fd, buf, HEADER_SIZE) != HEADER_SIZE)
         goto fail;
@@ -160,9 +166,6 @@
     if (strncmp(dyndisk_header->magic, "cxsparse", 8))
         goto fail;
 
-    bs->total_sectors = 
((uint64_t)be32_to_cpu(dyndisk_header->max_table_entries) *
-                       be32_to_cpu(dyndisk_header->block_size)) / 512;
-
     lseek(s->fd, be64_to_cpu(dyndisk_header->table_offset), SEEK_SET);
 
     s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries);






reply via email to

[Prev in Thread] Current Thread [Next in Thread]