From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHXa2-0001We-4v for qemu-devel@nongnu.org; Mon, 27 Jun 2016 10:32:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHXZw-00059Z-Bo for qemu-devel@nongnu.org; Mon, 27 Jun 2016 10:32:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHXZw-00059T-3Q for qemu-devel@nongnu.org; Mon, 27 Jun 2016 10:32:00 -0400 References: <1466941986-4587-1-git-send-email-lma@suse.com> <8760svcffe.fsf@dusky.pond.sub.org> From: Eric Blake Message-ID: <577138DE.1090106@redhat.com> Date: Mon, 27 Jun 2016 08:31:58 -0600 MIME-Version: 1.0 In-Reply-To: <8760svcffe.fsf@dusky.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BMMPHMRvkPDn4T3rd6wqI0GXLnoIHlxBg" Subject: Re: [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Lin Ma Cc: mst@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BMMPHMRvkPDn4T3rd6wqI0GXLnoIHlxBg From: Eric Blake To: Markus Armbruster , Lin Ma Cc: mst@redhat.com, qemu-devel@nongnu.org Message-ID: <577138DE.1090106@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ? References: <1466941986-4587-1-git-send-email-lma@suse.com> <8760svcffe.fsf@dusky.pond.sub.org> In-Reply-To: <8760svcffe.fsf@dusky.pond.sub.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/27/2016 12:29 AM, Markus Armbruster wrote: > Lin Ma writes: >=20 >> If there is any filename in current path matching wildcard ?, This fil= ename will >> be passed into -device ? while 'pathname expansion' isn't disabled by = noglob of >> shell built-in option, qemu reports error in this case. And if there is more than one such file, then the glob expands to all such files, turning '-device ?' into '-device a b', which your patch does not handle. You CANNOT reliably detect if a glob was expanded, so it is pointless to try. (At one point, glibc+bash had a tentative patch that would set an environment variable according to the pre-glob command line passed through the shell, so that the child app could reverse engineer what globs had been expanded, but it was discarded YEARS ago as not worth the overhead). >> >> Signed-off-by: Lin Ma >> --- >> qdev-monitor.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/qdev-monitor.c b/qdev-monitor.c >> index e19617f..f6443cd 100644 >> --- a/qdev-monitor.c >> +++ b/qdev-monitor.c >> @@ -257,6 +257,11 @@ int qdev_device_help(QemuOpts *opts) >> DevicePropertyInfoList *prop; >> =20 >> driver =3D qemu_opt_get(opts, "driver"); >> + >> + if (driver && access(driver, F_OK =3D=3D 0) && strlen(driver) =3D= =3D 1) { >> + driver =3D "?"; >> + } NACK. >> + >> if (driver && is_help_option(driver)) { >> qdev_print_devinfos(false); >> return 1; >=20 > I'm afraid this would silently interpret any one-character driver name > as a request for help when a file with this name exists. Not a good > idea. Example: "-device .". >=20 > "-device ?" and similar use of "?" elsewhere is deprecated. Please use= > "-device help". Agreed - we invented 'help' as a synonym for '?' precisely because '?' can't be worked around. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --BMMPHMRvkPDn4T3rd6wqI0GXLnoIHlxBg 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/ iQEcBAEBCAAGBQJXcTjeAAoJEKeha0olJ0NqRDgH/RUhnmGiCyZu80zeORWz/dyr NFE0S6QyyBpVLfQik8odjbBMHqG36AhLj8B793OIafeW/U46Zpaas2ZuGYCPIIQQ BueV+1Fa8NUykQQi0GRB0OnYs6fQNVH2/gobkjt1uuUy3IKJ+pzwl/riMl4c5Vam dJ28aMULjseH5S7vsxO6qlLguLiS0OMMRZQrKbBMGhDUsFR1JcsKm1FRjSFXRXWW jkO34h2Jk1vPb1NXB9LI1gTlq5WHRGlYcoLC9SPsiy/H9LkTEAR5WetbyOWezS+q HS3HViS9fBPbrXXBniIwYFV8D/uVr0/oKgALCIo4A92um8yP9jIwie49wdO/zxs= =717K -----END PGP SIGNATURE----- --BMMPHMRvkPDn4T3rd6wqI0GXLnoIHlxBg--