qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-arg


From: Matthew Fortune
Subject: Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument
Date: Thu, 2 Apr 2015 14:27:52 +0000

Liviu Ionescu <address@hidden> writes:
> > On 02 Apr 2015, at 13:36, Leon Alrae <address@hidden> wrote:
> >
> >> How would you pass arguments containing whitespaces via
> >> -semihosting-config cmdline without having to reinvent shell within
> QEMU?
> >
> > I missed the fact that you already provided the implementation for
> > this below...
> 
> 
> for completeness:
> 
> ilg-mbp:gnuarmeclipse-qemu.git ilg$ "/Applications/GNU ARM
> Eclipse/QEMU/2.2.91-201504021111-dev/bin/qemu-system-gnuarmeclipse" -
> verbose -machine STM32-H103 -gdb tcp::1234 -semihosting-config
> enable=on,target=native,cmdline='n "1 a" 2 3'

I see here that you have switched quotes because you know that you are
providing a double quoted argument within the string. The root of all
argument passing issues tends to boil down to how to quote and or escape
characters appropriately. Because you know the arguments you can quote
correctly but for an unknown user-provided set of arguments (where they
do not know how their arguments will flow down to an application) then
the appropriate quoting and escaping becomes harder.

The problem characters are obviously single and double quotes. Having
different quoting rules for any of the layers between a user and
the emulated program is always going to cause some confusion so when
quoting is necessary I have always found that following the standard
argument passing rules of the native application is the least
problematic.

qemu-system... -semihosting-config "arg=foo bar" -semihosting-config 
"arg=second"

This should give an argv of ["foo bar", "second"]

I'd propose that the cmdline option is retained for those cases that
do not need to cope with spaces (and also can avoid commas in the
cmdline or have them automatically doubled) and introduce arg= as a
more flexible case such that both commas and spaces are naturally
handled (the arg= just needs chopping off the start).

This could be implemented by saying that as soon as the parser sees
arg= then the rest of the string is one argument. The comma issue for
cmdline could be avoided like this too by mandating that cmdline is
the last part of the config options.

Just my thoughts :-)

Matthew





reply via email to

[Prev in Thread] Current Thread [Next in Thread]