From owner-svn-src-head@FreeBSD.ORG Sun Jun 21 01:44:28 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 62D9E895; Sun, 21 Jun 2015 01:44:28 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FAC57F0; Sun, 21 Jun 2015 01:44:28 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5L1iSbZ006619; Sun, 21 Jun 2015 01:44:28 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5L1iSah006618; Sun, 21 Jun 2015 01:44:28 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201506210144.t5L1iSah006618@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Sun, 21 Jun 2015 01:44:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284656 - head/usr.bin/mkimg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jun 2015 01:44:28 -0000 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)); }