From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8BDW-0005aD-L1 for qemu-devel@nongnu.org; Mon, 05 Jan 2015 12:13:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8BDS-0001LR-FF for qemu-devel@nongnu.org; Mon, 05 Jan 2015 12:13:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8BDS-0001LK-6X for qemu-devel@nongnu.org; Mon, 05 Jan 2015 12:13:18 -0500 Message-ID: <54AAC62A.2030906@redhat.com> Date: Mon, 05 Jan 2015 10:13:14 -0700 From: Eric Blake MIME-Version: 1.0 References: <1420436129-8467-1-git-send-email-tiejun.chen@intel.com> In-Reply-To: <1420436129-8467-1-git-send-email-tiejun.chen@intel.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bFhOAsUJ91n6Dde8D2g5FnohPA5BNkEAk" Subject: Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tiejun Chen , marcel.a@redhat.com, peter.maydell@linaro.org, agraf@suse.de, greg.bellows@linaro.org Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --bFhOAsUJ91n6Dde8D2g5FnohPA5BNkEAk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/04/2015 10:35 PM, Tiejun Chen wrote: > After one commit 49d2e648e808, "machine: remove qemu_machine_opts > global list", is introduced, QEMU doesn't keep a global list of > options but set desc lately. Then we can see the following, >=20 > $ x86_64-softmmu/qemu-system-x86_64 -usb > qemu-system-x86_64: util/qemu-option.c:387: qemu_opt_get_bool_helper: \= > Assertion `opt->desc && opt->desc->type =3D=3D QEMU_OPT_BOOL' faile= d. > Aborted (core dumped) >=20 > So inside qemu_opt_get_bool_helper, we need to call find_desc_by_name()= > to work parse_option_bool() out just in case of !opt->desc. >=20 > Signed-off-by: Tiejun Chen > --- > util/qemu-option.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/util/qemu-option.c b/util/qemu-option.c > index a708241..7cb3601 100644 > --- a/util/qemu-option.c > +++ b/util/qemu-option.c > @@ -377,7 +377,7 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts= , const char *name, > } > =20 > opt =3D qemu_opt_find(opts, name); > - if (opt =3D=3D NULL) { > + if ((opt =3D=3D NULL) || !opt->desc) { Over-parenthesized, and looks like you also introduced a spurious space. Simpler to just have: if (!opt || !opt->desc) { Also, there are other threads about the same topic. https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --bFhOAsUJ91n6Dde8D2g5FnohPA5BNkEAk 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/ iQEcBAEBCAAGBQJUqsYqAAoJEKeha0olJ0NqkXwH/125fgq+9H6P6KG44//T7qGJ szFB8x0Wt7DWIcs3P9G5IiyRJq7g+UWE3DpLl2noTEYeYh/OAMmGPpCdQFyhYm47 ipXyP5tRl8odIDC7LGOY13HNtHKARrz1ffYLIKWpZ4Md+wa7gehkDHdBxzHk0q1S aaMFmqiBZwT+07GcnLWy5Cw5NgBDexvPNbStEYQSJeXnj0nJZ8mBvv4grMUwNHBe NQ6E+MKEKeJz+cx551AVZkpoXZWEHUgkxuL2vjYkpQQlins/o9Y117HWGUsWmXdo YtAh21mrARIZyoBoC1J34EwSleJFbW0Er9+RA00UJ6A5rfYdiLN3Pz4tBwMjSLM= =dxWr -----END PGP SIGNATURE----- --bFhOAsUJ91n6Dde8D2g5FnohPA5BNkEAk--