[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/69] vpc: Fix size in fixed image creation
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 04/69] vpc: Fix size in fixed image creation |
Date: |
Fri, 27 Feb 2015 18:18:02 +0000 |
From: Kevin Wolf <address@hidden>
If total_sectors is rounded to match the geometry, total_size needs to
be changed as well. Otherwise we end up with an image whose geometry
describes a disk larger than the image file, which doesn't end well.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/vpc.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 46803b1..7fddbf0 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -801,6 +801,7 @@ static int vpc_create(const char *filename, QemuOpts *opts,
Error **errp)
}
total_sectors = (int64_t) cyls * heads * secs_per_cyl;
+ total_size = total_sectors * BDRV_SECTOR_SIZE;
/* Prepare the Hard Disk Footer */
memset(buf, 0, 1024);
@@ -822,13 +823,8 @@ static int vpc_create(const char *filename, QemuOpts
*opts, Error **errp)
/* Version of Virtual PC 2007 */
footer->major = cpu_to_be16(0x0005);
footer->minor = cpu_to_be16(0x0003);
- if (disk_type == VHD_DYNAMIC) {
- footer->orig_size = cpu_to_be64(total_sectors * 512);
- footer->size = cpu_to_be64(total_sectors * 512);
- } else {
- footer->orig_size = cpu_to_be64(total_size);
- footer->size = cpu_to_be64(total_size);
- }
+ footer->orig_size = cpu_to_be64(total_size);
+ footer->size = cpu_to_be64(total_size);
footer->cyls = cpu_to_be16(cyls);
footer->heads = heads;
footer->secs_per_cyl = secs_per_cyl;
--
2.1.0
- [Qemu-devel] [PULL 00/69] Block patches, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 03/69] test-coroutine: Regression test for yield bug, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 01/69] coroutine: Fix use after free with qemu_coroutine_yield(), Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 02/69] coroutine: Clean up qemu_coroutine_enter(), Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 04/69] vpc: Fix size in fixed image creation,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 07/69] block/raw-posix: fix compilation warning on OSX, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 05/69] vpc: Implement bdrv_co_get_block_status(), Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 08/69] qcow2: Remove unused struct QCowCreateState, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 09/69] virtio-blk: Check return value of blk_aio_ioctl, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 11/69] tests: Prepare virtio-blk-test for multi-arch implementation, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 10/69] libqos: Change use of pointers to uint64_t in virtio, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 12/69] libqos: Remove PCI assumptions in constants of virtio driver, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 13/69] libqos: Add malloc generic, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 06/69] sheepdog: selectable object size support, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 16/69] qcow2: Add refcount_bits to format-specific info, Stefan Hajnoczi, 2015/02/27