svn commit: r284656 - head/usr.bin/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Sun Jun 21 01:44:28 UTC 2015


Author: marcel
Date: Sun Jun 21 01:44:27 2015
New Revision: 284656
URL: https://svnweb.freebsd.org/changeset/base/284656

Log:
  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@

Modified:
  head/usr.bin/mkimg/vhd.c

Modified: head/usr.bin/mkimg/vhd.c
==============================================================================
--- head/usr.bin/mkimg/vhd.c	Sun Jun 21 01:35:32 2015	(r284655)
+++ head/usr.bin/mkimg/vhd.c	Sun Jun 21 01:44:27 2015	(r284656)
@@ -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));
 }
 


More information about the svn-src-all mailing list