From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA1Du-00031N-MF for qemu-devel@nongnu.org; Wed, 23 Jul 2014 14:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XA1Dp-00076g-Tw for qemu-devel@nongnu.org; Wed, 23 Jul 2014 14:25:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA1Dp-000735-MW for qemu-devel@nongnu.org; Wed, 23 Jul 2014 14:25:01 -0400 Message-ID: <53CFFDF3.4010200@redhat.com> Date: Wed, 23 Jul 2014 12:24:51 -0600 From: Eric Blake MIME-Version: 1.0 References: <1406125538-27992-1-git-send-email-yanghy@cn.fujitsu.com> <1406125538-27992-8-git-send-email-yanghy@cn.fujitsu.com> In-Reply-To: <1406125538-27992-8-git-send-email-yanghy@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dU1ge3qFch1rctDP5g9fCL0LGIF69aJUL" Subject: Re: [Qemu-devel] [RFC PATCH 07/17] COLO buffer: implement colo buffer as well as QEMUFileOps based on it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yang Hongyang , qemu-devel@nongnu.org Cc: GuiJianfeng@cn.fujitsu.com, mrhines@linux.vnet.ibm.com, eddie.dong@intel.com, dgilbert@redhat.com, kvm@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dU1ge3qFch1rctDP5g9fCL0LGIF69aJUL Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/23/2014 08:25 AM, Yang Hongyang wrote: > We need a buffer to store migration data. >=20 > On save side: > all saved data was write into colo buffer first, so that we can know s/was write/is written/ > the total size of the migration data. this can also separate the data > transmission from colo control data, we use colo control data over > socket fd to synchronous both side's stat. >=20 > On restore side: > all migration data was read into colo buffer first, then load data > from the buffer: If network error happens while data transmission, s/while/during/ > the slaver can still functinal because the migration data are not yet s/slaver/slave/ s/functinal/function/ s/are/is/ > loaded. >=20 > Signed-off-by: Yang Hongyang > --- > migration-colo.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 112 insertions(+) >=20 > +/* colo buffer */ > + > +#define COLO_BUFFER_BASE_SIZE (1000*1000*4ULL) > +#define COLO_BUFFER_MAX_SIZE (1000*1000*1000*10ULL) Spaces around binary operators. > + > +typedef struct colo_buffer { For consistency with the rest of the code base, name this ColoBuffer, not colo_buffer. > + uint8_t *data; > + uint64_t used; > + uint64_t freed; > + uint64_t size; > +} colo_buffer_t; HACKING says to NOT name types with a trailing _t. Just name the typedef ColoBuffer. > +static void colo_buffer_destroy(void) > +{ > + if (colo_buffer.data) { > + g_free(colo_buffer.data); > + colo_buffer.data =3D NULL; g_free(NULL) behaves sanely, just make these two lines unconditional. > +static void colo_buffer_extend(uint64_t len) > +{ > + if (len > colo_buffer.size - colo_buffer.used) { > + len =3D len + colo_buffer.used - colo_buffer.size; > + len =3D ROUND_UP(len, COLO_BUFFER_BASE_SIZE) + COLO_BUFFER_BAS= E_SIZE; > + > + colo_buffer.size +=3D len; > + if (colo_buffer.size > COLO_BUFFER_MAX_SIZE) { > + error_report("colo_buffer overflow!\n"); No trailing \n in error_report(). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --dU1ge3qFch1rctDP5g9fCL0LGIF69aJUL 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/ iQEcBAEBCAAGBQJTz/3zAAoJEKeha0olJ0NqU1MH/jxrYniyCnNdJ0GEzPjnE/3x zJ1sR4SwawMGTJv55sP8SEkYnLKVeeSLhGW4MGxm3gfYlGKocaznyR8kaVnYDf4u OM28xYx91zhugNDhuYgyglcNgvx1wGNmCZ9cmJF5UsSo+7s2Lfvq7OwklVpXOqRJ vFCFYIH5dL44LSAfQXSURgIJYbXk7ya1ses5e8tOn6qLn/xyEXVPb6vQ7+Hxxnx3 fUGiT2q/NhqTKsHv9Sly4DkCCFiq5BByvODLTfUY0KO/iwW9LGLGd2oLMsdYoaP0 bzaPa0kUXR5GuaRvIsQwpltDGHNE+5GOy8M96VYt89RyfPvQim6sSt/m84gCxII= =qJFb -----END PGP SIGNATURE----- --dU1ge3qFch1rctDP5g9fCL0LGIF69aJUL--