* [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ?
@ 2016-06-26 11:53 Lin Ma
2016-06-27 6:29 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Lin Ma @ 2016-06-26 11:53 UTC (permalink / raw)
To: armbru, eblake, mst, qemu-devel
If there is any filename in current path matching wildcard ?, This filename will
be passed into -device ? while 'pathname expansion' isn't disabled by noglob of
shell built-in option, qemu reports error in this case.
Signed-off-by: Lin Ma <lma@suse.com>
---
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;
driver = qemu_opt_get(opts, "driver");
+
+ if (driver && access(driver, F_OK == 0) && strlen(driver) == 1) {
+ driver = "?";
+ }
+
if (driver && is_help_option(driver)) {
qdev_print_devinfos(false);
return 1;
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ?
2016-06-26 11:53 [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ? Lin Ma
@ 2016-06-27 6:29 ` Markus Armbruster
2016-06-27 14:31 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2016-06-27 6:29 UTC (permalink / raw)
To: Lin Ma; +Cc: eblake, mst, qemu-devel
Lin Ma <lma@suse.com> writes:
> If there is any filename in current path matching wildcard ?, This filename will
> be passed into -device ? while 'pathname expansion' isn't disabled by noglob of
> shell built-in option, qemu reports error in this case.
>
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
> 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;
>
> driver = qemu_opt_get(opts, "driver");
> +
> + if (driver && access(driver, F_OK == 0) && strlen(driver) == 1) {
> + driver = "?";
> + }
> +
> if (driver && is_help_option(driver)) {
> qdev_print_devinfos(false);
> return 1;
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 .".
"-device ?" and similar use of "?" elsewhere is deprecated. Please use
"-device help".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ?
2016-06-27 6:29 ` Markus Armbruster
@ 2016-06-27 14:31 ` Eric Blake
0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-06-27 14:31 UTC (permalink / raw)
To: Markus Armbruster, Lin Ma; +Cc: mst, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2001 bytes --]
On 06/27/2016 12:29 AM, Markus Armbruster wrote:
> Lin Ma <lma@suse.com> writes:
>
>> If there is any filename in current path matching wildcard ?, This filename 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 <lma@suse.com>
>> ---
>> 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;
>>
>> driver = qemu_opt_get(opts, "driver");
>> +
>> + if (driver && access(driver, F_OK == 0) && strlen(driver) == 1) {
>> + driver = "?";
>> + }
NACK.
>> +
>> if (driver && is_help_option(driver)) {
>> qdev_print_devinfos(false);
>> return 1;
>
> 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 .".
>
> "-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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-27 14:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-26 11:53 [Qemu-devel] [PATCH] qdev: Workaround for an issue caused by noglob option of shell for -device ? Lin Ma
2016-06-27 6:29 ` Markus Armbruster
2016-06-27 14:31 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).