From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Whm-0002N8-Dl for qemu-devel@nongnu.org; Wed, 25 May 2016 07:10:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Whh-0004jc-0r for qemu-devel@nongnu.org; Wed, 25 May 2016 07:10:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Whg-0004jY-Ob for qemu-devel@nongnu.org; Wed, 25 May 2016 07:10:20 -0400 References: <20160525084629.27127.82209.malonedeb@gac.canonical.com> From: Eric Blake Message-ID: <5745881B.3010105@redhat.com> Date: Wed, 25 May 2016 05:10:19 -0600 MIME-Version: 1.0 In-Reply-To: <20160525084629.27127.82209.malonedeb@gac.canonical.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uThnpsKjLxJ3nFJjMqDDiMjrcrPCQ8gx2" Subject: Re: [Qemu-devel] [Bug 1585533] [NEW] cache-miss-rate / Invalid JSON List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bug 1585533 <1585533@bugs.launchpad.net>, qemu-devel@nongnu.org, "libvir-list@redhat.com" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uThnpsKjLxJ3nFJjMqDDiMjrcrPCQ8gx2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/25/2016 02:46 AM, Marc Brothier wrote: > Public bug reported: >=20 > Hi, >=20 > We have VMs which were started with an older version than qemu 2.1 whic= h > added "cache-miss-rate" property for XBZRLECacheStats. While trying to > migrate the VM to a new host which is running a higher version (2.3) of= > Qemu we got an exception: >=20 > virJSONValueFromString:1642 : internal error: cannot parse json {"retur= n": {"expected-downtime": 1, "xbzrle-cache": {"bytes": 0, "cache-size": 6= 7108864, "cache-miss-rate": -nan, "pages": 0, "overflow": 0, "cache-miss"= : 8933}, "status": "active", "disk": {"total": 429496729600, "dirty-sync-= count": 0, "remaining": 193896382464, "mbps": 0, "transferred": 235600347= 136, "duplicate": 0, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes":= 0, "normal": 0}, "setup-time": 13, "total-time": 1543124, "ram": {"total= ": 8599183360, "dirty-sync-count": 4, "remaining": 30695424, "mbps": 830.= 636997, "transferred": 3100448901, "duplicate": 1358341, "dirty-pages-rat= e": 7, "skipped": 0, "normal-bytes": 3082199040, "normal": 752490}}, "id"= : "libvirt-186200"}: lexical error: malformed number, a digit is required= after the minus sign. > 67108864, "cache-miss-rate": -nan, "pages": 0, "overflow": 0 > (right here) ------^ >=20 > virNetClientStreamRaiseError:191 : stream aborted at client request Wow - I've known we have a problem with qemu emitting non-compliant JSON, but this proves that it is fatal to libvirt. I guess my series on improving the JSON parser [1] should consider doing a fallback to s/NaN/0/ and s/Inf/DBL_MAX/ rather than completely erroring out when a client tries to request it. Meanwhile, it's an easy patch to qemu to avoid division by zero when generating cache-miss-rate. [1] https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg03424.html >=20 >=20 > Would it be possible to improve the JSON parser to skip the key if the = value is incorrect Libvirt uses libyajl to parse JSON, and libyajl has an outstanding bug request to support extensions to JSON such as parsing non-finite floats. Since there has been no upstream reaction to the bug request, I seriously doubt it will happen any time soon, so any change to tolerate NaN in libvirt would have to be a one-off patch. It sounds like the better fix is to make qemu emit valid JSON in the first place, rather than making libvirt deal with broken JSON from qemu. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uThnpsKjLxJ3nFJjMqDDiMjrcrPCQ8gx2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXRYgbAAoJEKeha0olJ0Nq/P4H/2Pcq6OrCrphcHuiRk4S6xHr 8BoHih1Ph+3r1vntRnv0AYzgzPM4hSnWvu6dK+HYulixoeLA0WegtPPBaVVvgHWS umaeQ5mj09TRpbDjQiLiPFPWB5onzFdY3BbZ1idOR0ZZ47rOowiIdjj8l5BULQfv /t2ZGo+75f07Igl6XaEBLNbnrzvJcmuOHTMbyNXuJr4ta6oMsp1DQvjVbYmQ9EzI GeuRVh/7LkrEwFzER73fmvoVLkntCVi6uj5NHcpJhZ8bHqnA2ndjHc7e1q5i1e03 3QcaMBBSacoOzKRh1+IoudVe2kFveoM4dIGSGhl3b3nzsif0LDvI6pVZV+JEwwo= =QLGa -----END PGP SIGNATURE----- --uThnpsKjLxJ3nFJjMqDDiMjrcrPCQ8gx2--