From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl8Tu-0002Mv-Ki for qemu-devel@nongnu.org; Sun, 02 Nov 2014 22:39:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xl8Tq-0007M9-Ho for qemu-devel@nongnu.org; Sun, 02 Nov 2014 22:39:02 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:44398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl8Tq-0007LM-71 for qemu-devel@nongnu.org; Sun, 02 Nov 2014 22:38:58 -0500 Date: Mon, 3 Nov 2014 13:39:17 +1100 From: David Gibson Message-ID: <20141103023917.GD8949@voom.redhat.com> References: <1412358473-31398-1-git-send-email-dgilbert@redhat.com> <1412358473-31398-7-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UfEAyuTBtIjiZzX6" Content-Disposition: inline In-Reply-To: <1412358473-31398-7-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 06/47] Add qemu_get_counted_string to read a string prefixed by a count byte List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com, cristian.klein@cs.umu.se, qemu-devel@nongnu.org, amit.shah@redhat.com, yanghy@cn.fujitsu.com --UfEAyuTBtIjiZzX6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 03, 2014 at 06:47:12PM +0100, Dr. David Alan Gilbert (git) wrot= e: > From: "Dr. David Alan Gilbert" >=20 > and use it in loadvm_state. >=20 > Signed-off-by: Dr. David Alan Gilbert > --- > include/migration/qemu-file.h | 2 ++ > qemu-file.c | 15 +++++++++++++++ > savevm.c | 18 ++++++++++-------- > 3 files changed, 27 insertions(+), 8 deletions(-) >=20 > diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h > index 6ef8ebc..a8cac7a 100644 > --- a/include/migration/qemu-file.h > +++ b/include/migration/qemu-file.h > @@ -300,4 +300,6 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64= _t *pv) > { > qemu_get_be64s(f, (uint64_t *)pv); > } > + > +int qemu_get_counted_string(QEMUFile *f, uint8_t *buf); I'd suggest writing the prototype as int qemu_get_counted_string(QEMUFile *f, uint8_t buf[256]); The compiled code will be identical, of course, but it helps to document what the function expects. > #endif > diff --git a/qemu-file.c b/qemu-file.c > index ccc516c..a057b3e 100644 > --- a/qemu-file.c > +++ b/qemu-file.c > @@ -879,6 +879,21 @@ uint64_t qemu_get_be64(QEMUFile *f) > return v; > } > =20 > +/* > + * Get a string whose length is determined by a single preceding byte > + * A preallocated 256 byte buffer must be passed in. > + * Returns: 0 on success and a 0 terminated string in the buffer > + */ > +int qemu_get_counted_string(QEMUFile *f, uint8_t *buf) > +{ > + unsigned int len =3D qemu_get_byte(f); > + int res =3D qemu_get_buffer(f, buf, len); > + > + buf[len] =3D 0; > + > + return res !=3D len; > +} > + > #define QSB_CHUNK_SIZE (1 << 10) > #define QSB_MAX_CHUNK_SIZE (16 * QSB_CHUNK_SIZE) > =20 > diff --git a/savevm.c b/savevm.c > index c3a1f68..cb6f0de 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -908,7 +908,7 @@ int qemu_loadvm_state(QEMUFile *f) > =20 > v =3D qemu_get_be32(f); > if (v =3D=3D QEMU_VM_FILE_VERSION_COMPAT) { > - fprintf(stderr, "SaveVM v2 format is obsolete and don't work any= more\n"); > + error_report("SaveVM v2 format is obsolete and don't work anymor= e"); These changes of fprintf() to error_report() look like an unrelated cleanup. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --UfEAyuTBtIjiZzX6 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUVurVAAoJEGw4ysog2bOSLQMP/AzDw5+0auMWtqzxBdUOhpOS p/i7tyV1OH8nlQF8JozmRiVtPpASOJYNpc2MgMIfu1ssEhhj/wR4YVLu88pdqvMn t464Z7UBd0CSvHzpK/1TAAfBUGOWMYNPnRAZn3g7Y5sLShutnyb93N17RCdB7sJF b/vCdOdoZOeDG/4ft8I3Guoo2QUviB/rC3HpbVDxNxmdDC4x0FHWFKdoowy6Nb6X KOOAUnn9ly/n+bYr4oGm0gOBWSC4CAXNDPi8HogvHK1uHb81rERqu2u/qX1x6AXy 0YuR6/2kwxtV9UKyYO8szSivhGJtOvFVrWN653U44b8R6Lawhu46ceM152HkRDQh GKrq8G60gINRTZXMlrwI/Y+2UaQwCNIvig4uiViQxyzv07/CsD2XVUIjlbgk7E6v Jxpw3mcTyyXnliWYtnaIqMMLhNbyRR+O4nmyNXdwBy8PMk8UUSUIl8bd1Z9+X5VP XdpRBE6oWEmzTakJBsVEejMsomMbgNZ7yMOUprKD7MRyE5oMUKfJYLe+EEGtWoPH wIHahzvjGhL0232noVAILAJ9ytI0m3M40UdtcQJG5ovt01TV+dF5GbjoCdTqztp2 gtf+9oxGjmaJYr5oo5wskXr1hjiVvRi2COS3tuejfP3YZkX92XIWqB4y/eStMWeH CnN1ZADR/skjtTAPf1BU =WENy -----END PGP SIGNATURE----- --UfEAyuTBtIjiZzX6--