From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFnH9-0005if-3F for qemu-devel@nongnu.org; Tue, 18 Feb 2014 11:12:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFnH3-0005cP-S9 for qemu-devel@nongnu.org; Tue, 18 Feb 2014 11:12:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFnH3-0005c4-JD for qemu-devel@nongnu.org; Tue, 18 Feb 2014 11:11:57 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1IGBtn8002141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Feb 2014 11:11:56 -0500 Message-ID: <5303864A.8030805@redhat.com> Date: Tue, 18 Feb 2014 09:11:54 -0700 From: Eric Blake MIME-Version: 1.0 References: <1392163249-6983-1-git-send-email-quintela@redhat.com> In-Reply-To: <1392163249-6983-1-git-send-email-quintela@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Ko4umrqR54Hkn3r1l6aG6ppr6hUXrecCk" Subject: Re: [Qemu-devel] [PATCH v2] qemu_file: use fwrite() correctly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Ko4umrqR54Hkn3r1l6aG6ppr6hUXrecCk Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/11/2014 05:00 PM, Juan Quintela wrote: > fwrite() returns the number of items written. But when there is one > error, it can return a short write. >=20 > In the particular bug that I was tracking, I did a migration to a > read-only filesystem. And it was able to finish the migration > correctly. fwrite() never returned a negative error code, the 1st > time it returns 0, after that it returns 4096. (migration writes > chunks of about 14000 bytes). And it was able to "complete" the > migration with success (yes, reading the file was a bit more > difficult). On the 1st fwrite() for the read-only filesystem, > it returns an errno of -EPIPE, that is exactly what has failed. >=20 > To add insult to injury, if your amount of memory was big enough (12GB > on my case), it overwrote some important structure, and from them, > malloc failed. This check makes the problem go away. >=20 > Signed-off-by: Juan Quintela > --- >=20 > v2: a.k.a Paolo was right >=20 > On the first call to fwrite() it returns 0, and errno is setup to > EPIPE, exactly what we wanted. >=20 > Once here, improve the commit message. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Ko4umrqR54Hkn3r1l6aG6ppr6hUXrecCk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTA4ZKAAoJEKeha0olJ0NqeIAH/14hOKuVV9FH+BwCqifqEBzs bxIbzmfR1NiNzXsSjD+T0vM0tgsAKm/TCh5BfOXCfCJpmStafHLP0KBLXZ7eKMPo aExt02RV21qXylKkZlFJBAXYZkwNnHq3KqBUIiWZ29hs2bXPBJ+HE+Iw3ACTkZmj KVYr13t0SP78GxkWH2+9e4Zat+bl4HqdwlkdIL55vXfw8+hvru3fTTFM7IwUazbL lksT2lclj5ACiu71GTzy2RuZvfWkl/GuQlBumzz7h33LOvQiNwVTZf15vGpDVNhA pE0retVy/hMOC/YgxZb2IoDm+VzW8ZDUToi9JjTtOI9KCA/ccIYK9knAW8rASf4= =tucn -----END PGP SIGNATURE----- --Ko4umrqR54Hkn3r1l6aG6ppr6hUXrecCk--