Received: from eggs.gnu.org ([2001:4830:134:3::10]:37238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWMrs-0001yF-0A for qemu-devel@nongnu.org; Tue, 23 Sep 2014 05:58:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWMrl-0007yh-QZ for qemu-devel@nongnu.org; Tue, 23 Sep 2014 05:58:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWMrl-0007yI-Ja for qemu-devel@nongnu.org; Tue, 23 Sep 2014 05:58:37 -0400 Date: Tue, 23 Sep 2014 10:58:24 +0100 From: Stefan Hajnoczi Message-ID: <20140923095824.GJ2713@stefanha-thinkpad.redhat.com> References: <1411120786-28764-1-git-send-email-lpetrut@cloudbasesolutions.com> <20140922121700.GD12513@stefanha-thinkpad.redhat.com> <64050966FCE0B948BCE2B28DB6E0B7D5F156DA@CBSEX1.cloudbase.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mPTHnM80CEnHQ2WJ" Content-Disposition: inline In-Reply-To: <64050966FCE0B948BCE2B28DB6E0B7D5F156DA@CBSEX1.cloudbase.local> Subject: Re: [Qemu-devel] [[PATCH v2] 1/1] vpc.c: Add VHD resize support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lucian Petrut Cc: Petrut Lucian , "kwolf@redhat.com" , "sw@weilnetz.de" , "jcody@redhat.com" , "qemu-devel@nongnu.org" , Alessandro Pilotti --mPTHnM80CEnHQ2WJ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 22, 2014 at 01:24:16PM +0000, Lucian Petrut wrote: > >> + if (cpu_to_be32(footer->type) =3D=3D VHD_DIFFERENCING) { > >footer_buf is big-endian so this should be be32_to_cpu() >=20 > My bad, I=E2=80=99ll fix the BE related issues. The existing block/vpc.c code confuses beX_to_cpu() and cpu_to_beX(). I have sent a patch to fix that ("[PATCH] vpc: fix beX_to_cpu() and cpu_to_beX() confusion"). > >> + error_report("Resizing differencing vhd images is not suppor= ted."); > >> + return -ENOTSUP; > >> + } > >> + > >> + old_bat_size =3D (s->max_table_entries * 4 + 511) & ~511; > >> + new_total_sectors =3D offset / BDRV_SECTOR_SIZE; > >> + > >> + for (index =3D 0; new_total_sectors > (int64_t)cyls * heads * se= cs_per_cyl; > >> + index++) { > >> + if (calculate_geometry(new_total_sectors + index, &cyls, &he= ads, > >> + &secs_per_cyl)) { > >> + return -EFBIG; > >> + } > >> + } > >> + new_total_sectors =3D (int64_t) cyls * heads * secs_per_cyl; > >> + new_num_bat_entries =3D (new_total_sectors + s->block_size / 512= ) / > >> + (s->block_size / 512); > >This expression doesn't just round up, it always adds an extra block. > >Is this intentional? > >I expected the numerator for rounding up to be: > > new_total_sectors + s->block_size / 512 - 1 >=20 > This was intended, it may just add an extra entry. Also, the number > of entries is calculated in the same way in the existing code which > creates dynamic VHDs, so I wanted to keep consistency with that > as well. Okay, if existing code already does it like this it makes sense to be consistent. --mPTHnM80CEnHQ2WJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUIURAAAoJEJykq7OBq3PIQRsH/RxKPyRCg9d4Oex0UY3O5myQ LL1O0CsMW9TgeXGl1g+5D1p4VakX5ou9BVioR+XEFjlbvGpeFx1MembgT9z3Mlc/ duYnrC/7Qoxe0k6tLPcloXtPFJHoxAcDLzCIDfm6Jx0eyKW6m0SxWjvV70fy//iF pZ3GZ6lxpD5BznvncbFBlqonNN015rN+u+3dfw8Zj6LXEL2fzcu2JJGMsCkSpY84 5lBjKg0Lc+w6JB87Uq5qAydCcwFrY7XdhXP4mo4Ge3kxVTL9WrWtFymvzUlwHKf7 N9VNMILcfmpV1ByL5wEK0bZoEOBEApRyVjVRcmKxTS2hsxdmDr1ZcLYJ7nuhkEQ= =5pXZ -----END PGP SIGNATURE----- --mPTHnM80CEnHQ2WJ--