From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8Vb1-0008Ib-2K for qemu-devel@nongnu.org; Tue, 06 Jan 2015 09:59:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8Vax-0003xq-0j for qemu-devel@nongnu.org; Tue, 06 Jan 2015 09:58:59 -0500 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:63481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8Vaw-0003xl-Mg for qemu-devel@nongnu.org; Tue, 06 Jan 2015 09:58:54 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so5512432wiw.15 for ; Tue, 06 Jan 2015 06:58:54 -0800 (PST) Date: Tue, 6 Jan 2015 14:58:51 +0000 From: Stefan Hajnoczi Message-ID: <20150106145851.GN29775@stefanha-thinkpad.redhat.com> References: <1420456961-19631-1-git-send-email-stefanha@redhat.com> <54AA7791.9060705@siemens.com> <54AA801A.8050605@redhat.com> <54AB4A65.2020503@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="McpcKDxJRrEJVmOH" Content-Disposition: inline In-Reply-To: <54AB4A65.2020503@intel.com> Subject: Re: [Qemu-devel] [PATCH] vl.c: fix -usb option assertion failure in qemu_opt_get_bool_helper() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Chen, Tiejun" Cc: Peter Maydell , Marcel Apfelbaum , Jan Kiszka , qemu-devel , plucinski.mariusz@gmail.com, Stefan Hajnoczi , Marcel Apfelbaum --McpcKDxJRrEJVmOH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 06, 2015 at 10:37:25AM +0800, Chen, Tiejun wrote: > On 2015/1/5 20:14, Marcel Apfelbaum wrote: > >On 01/05/2015 01:50 PM, Stefan Hajnoczi wrote: > >>On Mon, Jan 5, 2015 at 11:37 AM, Jan Kiszka > >>wrote: > >>>On 2015-01-05 12:22, Stefan Hajnoczi wrote: > >>>>Commit 49d2e648e8087d154d8bf8b91f27c8e05e79d5a6 ("machine: remove > >>>>qemu_machine_opts global list") removed option descriptions from the > >>>>-machine QemuOptsList to avoid repeating MachineState's QOM propertie= s. > >>>> > >>>>This change broke vl.c:usb_enabled() because qemu_opt_get_bool() cann= ot > >>>>be used on QemuOptsList without option descriptions since QemuOpts > >>>>doesn't know the type and therefore left an unparsed string value. > >>>> > >>>>This patch avoids calling qemu_opt_get_bool() to fix the assertion > >>>>failure: > >>>> > >>>> $ qemu-system-x86_64 -usb > >>>> qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type > >>>>=3D=3D QEMU_OPT_BOOL' failed. > >>>> > >>>>Test the presence of -usb using qemu_opt_find() but use the > >>>>MachineState->usb field instead of qemu_opt_get_bool(). > >>>> > >>>>Cc: Marcel Apfelbaum > >>>>Cc: Tiejun Chen > >>>>Signed-off-by: Stefan Hajnoczi > >>>>--- > >>>> vl.c | 7 +++++-- > >>>> 1 file changed, 5 insertions(+), 2 deletions(-) > >>>> > >>>>diff --git a/vl.c b/vl.c > >>>>index bea9656..6e8889c 100644 > >>>>--- a/vl.c > >>>>+++ b/vl.c > >>>>@@ -999,8 +999,11 @@ static int parse_name(QemuOpts *opts, void > >>>>*opaque) > >>>> > >>>> bool usb_enabled(bool default_usb) > >>>> { > >>>>- return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", > >>>>- has_defaults && default_usb); > >>>>+ if (qemu_opt_find(qemu_get_machine_opts(), "usb")) { > >>>>+ return current_machine->usb; > >>>>+ } else { > >>>>+ return has_defaults && default_usb; > >>>>+ } > >>>> } > >>>> > >>>> #ifndef _WIN32 > >>>> > >>> > >>>That still leaves the other boolean machine options broken. A generic > >>>fix would be good. Or revert the original commit until we have one. > >> > >>I think we should revert the original commit. > >> > >>qemu_option_get_*() callers need to be converted to query MachineState > >>fields instead of using QemuOpts functions. >=20 > Can this work out currently? >=20 > --- > util/qemu-option.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) >=20 > diff --git a/util/qemu-option.c b/util/qemu-option.c > index a708241..933b885 100644 > --- a/util/qemu-option.c > +++ b/util/qemu-option.c > @@ -317,7 +317,7 @@ const char *qemu_opt_get(QemuOpts *opts, const char > *name) > } >=20 > opt =3D qemu_opt_find(opts, name); > - if (!opt) { > + if (!opt || !opt->desc) { No, this is incorrect because now it just assigns the default value and ignores the value from the command-line! Stefan --McpcKDxJRrEJVmOH Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUq/grAAoJEJykq7OBq3PICSwH/jAtIhPWa4NE6WQ+uUbSj3mX Ai/9NoVWoeA+SagqHKa35qg8zD9PZr0JoAe6gEoVrecgabmqJenufuwJh8Iyriwy Pm3P+/OShiDNtB/W5fMQGlMFx96CptNG5fOjSQLQxMW5ffW5daLo7SdpKi7D8MvM 8hkCgqdybaL2N6Yw3WK9M1TvvevttwBf0/awoPeCIW3DIxHbALYEevm3FbrkArI4 BJI+9wpKyo/LJH5ctLMNOUPYLW+L7SCH7b0NqfA70mU8HyvO2KWc5ng1NQ67D5rE ohTACTq6F4JrqPcSd3r7+Xm4lbmNFQtlf2cfqdrmzrCnyrgi2Bkl8zwN5d+r7oU= =Ct8i -----END PGP SIGNATURE----- --McpcKDxJRrEJVmOH--