diff options
author | marcel <marcel@FreeBSD.org> | 2015-06-21 01:44:27 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2015-06-21 01:44:27 +0000 |
commit | 149795a98acb288cb2bf7a8a85110373a8df845f (patch) | |
tree | 80cd521cf5d660974fe11d0833f75e66b663f616 /usr.bin | |
parent | 162b419db0120c29b07529d37bbb99ec2b79ffbd (diff) | |
download | FreeBSD-src-149795a98acb288cb2bf7a8a85110373a8df845f.zip FreeBSD-src-149795a98acb288cb2bf7a8a85110373a8df845f.tar.gz |
Microsoft Azure demands that fixed VHD images are a whole number
of megabytes. This is on top of having the image rounded to the
matching geometry of the image size.
By rounding up to the next MB after rounding to the geometry, we
lost idempotency. Subsequent calls to resize the image will keep
increasing the image size.
Tested by: gjb@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mkimg/vhd.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.bin/mkimg/vhd.c b/usr.bin/mkimg/vhd.c index 6860c16..4040752 100644 --- a/usr.bin/mkimg/vhd.c +++ b/usr.bin/mkimg/vhd.c @@ -365,6 +365,11 @@ vhd_fix_resize(lba_t imgsz) struct vhd_geom geom; int64_t imagesz; + /* + * Round the image size to the pre-determined geometry that + * matches the image size. This circular dependency implies + * that we need to loop to handle boundary conditions. + */ imgsz *= secsz; imagesz = imgsz; while (1) { @@ -375,6 +380,10 @@ vhd_fix_resize(lba_t imgsz) break; imagesz += geom.heads * geom.sectors * VHD_SECTOR_SIZE; } + /* + * Azure demands that images are a whole number of megabytes. + */ + imagesz = (imagesz + 0xfffffULL) & ~0xfffffULL; return (image_set_size(imagesz / secsz)); } |