Patchwork qemu_find_file: check name as a straight path even if it has no '/'

login
register
mail settings
Submitter Peter Maydell
Date May 25, 2012, 12:07 p.m.
Message ID <1337947621-8610-1-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/161324/
State New
Headers show

Comments

Peter Maydell - May 25, 2012, 12:07 p.m.
Make qemu_find_file() check for the passed in name as a straight
pathname even if it doesn't have any path separator character in it.
This means that "-bios foo", "-dtb foo" etc will find a file 'foo'
in the current directory.
This removes an inconsistency with -kernel and -initrd, which both
accept plain filenames as meaning files in the current directory.
It's also less confusing for the user than an undocumented restriction
that "this option accepts a filename, except for the special case
where the filename you pass happens not to have a '/' in it, in
which case we'll ignore it."

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 vl.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
Andreas Färber - May 25, 2012, 12:21 p.m.
Am 25.05.2012 14:07, schrieb Peter Maydell:
> Make qemu_find_file() check for the passed in name as a straight
> pathname even if it doesn't have any path separator character in it.
> This means that "-bios foo", "-dtb foo" etc will find a file 'foo'
> in the current directory.
> This removes an inconsistency with -kernel and -initrd, which both
> accept plain filenames as meaning files in the current directory.
> It's also less confusing for the user than an undocumented restriction
> that "this option accepts a filename, except for the special case
> where the filename you pass happens not to have a '/' in it, in
> which case we'll ignore it."
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Speaking of inconsistencies, I also noticed that the ppc virtex-ml507
machine relies on the .dtb being in the current directory with
apparently no way to override. Any chance this can be fixed, Edgar?
Maybe it can be unified with the dtb handling on ARM or share the same
QemuOpts?

Andreas
Edgar Iglesias - May 25, 2012, 12:23 p.m.
On Fri, May 25, 2012 at 02:21:55PM +0200, Andreas Färber wrote:
> Am 25.05.2012 14:07, schrieb Peter Maydell:
> > Make qemu_find_file() check for the passed in name as a straight
> > pathname even if it doesn't have any path separator character in it.
> > This means that "-bios foo", "-dtb foo" etc will find a file 'foo'
> > in the current directory.
> > This removes an inconsistency with -kernel and -initrd, which both
> > accept plain filenames as meaning files in the current directory.
> > It's also less confusing for the user than an undocumented restriction
> > that "this option accepts a filename, except for the special case
> > where the filename you pass happens not to have a '/' in it, in
> > which case we'll ignore it."
> > 
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> 
> Speaking of inconsistencies, I also noticed that the ppc virtex-ml507
> machine relies on the .dtb being in the current directory with
> apparently no way to override. Any chance this can be fixed, Edgar?
> Maybe it can be unified with the dtb handling on ARM or share the same
> QemuOpts?

Yes, absolutely!

Best regards,
Edgar
Peter Maydell - June 19, 2012, 3:13 p.m.
Ping? (patch still applies cleanly to current master; patchwork URL
http://patchwork.ozlabs.org/patch/161324/ )

-- PMM

On 25 May 2012 13:07, Peter Maydell <peter.maydell@linaro.org> wrote:
> Make qemu_find_file() check for the passed in name as a straight
> pathname even if it doesn't have any path separator character in it.
> This means that "-bios foo", "-dtb foo" etc will find a file 'foo'
> in the current directory.
> This removes an inconsistency with -kernel and -initrd, which both
> accept plain filenames as meaning files in the current directory.
> It's also less confusing for the user than an undocumented restriction
> that "this option accepts a filename, except for the special case
> where the filename you pass happens not to have a '/' in it, in
> which case we'll ignore it."
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  vl.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 23ab3a3..4639526 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1801,9 +1801,8 @@ char *qemu_find_file(int type, const char *name)
>     const char *subdir;
>     char *buf;
>
> -    /* If name contains path separators then try it as a straight path.  */
> -    if ((strchr(name, '/') || strchr(name, '\\'))
> -        && access(name, R_OK) == 0) {
> +    /* Try the name as a straight path first */
> +    if (access(name, R_OK) == 0) {
>         return g_strdup(name);
>     }
>     switch (type) {
> --
> 1.7.1
Peter Maydell - June 28, 2012, 11:23 a.m.
Ping^2?

-- PMM

On 19 June 2012 16:13, Peter Maydell <peter.maydell@linaro.org> wrote:
> Ping? (patch still applies cleanly to current master; patchwork URL
> http://patchwork.ozlabs.org/patch/161324/ )
>
> -- PMM
>
> On 25 May 2012 13:07, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Make qemu_find_file() check for the passed in name as a straight
>> pathname even if it doesn't have any path separator character in it.
>> This means that "-bios foo", "-dtb foo" etc will find a file 'foo'
>> in the current directory.
>> This removes an inconsistency with -kernel and -initrd, which both
>> accept plain filenames as meaning files in the current directory.
>> It's also less confusing for the user than an undocumented restriction
>> that "this option accepts a filename, except for the special case
>> where the filename you pass happens not to have a '/' in it, in
>> which case we'll ignore it."
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  vl.c |    5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 23ab3a3..4639526 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -1801,9 +1801,8 @@ char *qemu_find_file(int type, const char *name)
>>     const char *subdir;
>>     char *buf;
>>
>> -    /* If name contains path separators then try it as a straight path.  */
>> -    if ((strchr(name, '/') || strchr(name, '\\'))
>> -        && access(name, R_OK) == 0) {
>> +    /* Try the name as a straight path first */
>> +    if (access(name, R_OK) == 0) {
>>         return g_strdup(name);
>>     }
>>     switch (type) {
>> --
>> 1.7.1
Peter Maydell - July 10, 2012, 2:18 p.m.
Ping^3? This patch has been on the list over six weeks now...

-- PMM

On 28 June 2012 12:23, Peter Maydell <peter.maydell@linaro.org> wrote:
> Ping^2?
>
> -- PMM
>
> On 19 June 2012 16:13, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Ping? (patch still applies cleanly to current master; patchwork URL
>> http://patchwork.ozlabs.org/patch/161324/ )
>>
>> -- PMM
>>
>> On 25 May 2012 13:07, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> Make qemu_find_file() check for the passed in name as a straight
>>> pathname even if it doesn't have any path separator character in it.
>>> This means that "-bios foo", "-dtb foo" etc will find a file 'foo'
>>> in the current directory.
>>> This removes an inconsistency with -kernel and -initrd, which both
>>> accept plain filenames as meaning files in the current directory.
>>> It's also less confusing for the user than an undocumented restriction
>>> that "this option accepts a filename, except for the special case
>>> where the filename you pass happens not to have a '/' in it, in
>>> which case we'll ignore it."
>>>
>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> ---
>>>  vl.c |    5 ++---
>>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/vl.c b/vl.c
>>> index 23ab3a3..4639526 100644
>>> --- a/vl.c
>>> +++ b/vl.c
>>> @@ -1801,9 +1801,8 @@ char *qemu_find_file(int type, const char *name)
>>>     const char *subdir;
>>>     char *buf;
>>>
>>> -    /* If name contains path separators then try it as a straight path.  */
>>> -    if ((strchr(name, '/') || strchr(name, '\\'))
>>> -        && access(name, R_OK) == 0) {
>>> +    /* Try the name as a straight path first */
>>> +    if (access(name, R_OK) == 0) {
>>>         return g_strdup(name);
>>>     }
>>>     switch (type) {
>>> --
>>> 1.7.1

Patch

diff --git a/vl.c b/vl.c
index 23ab3a3..4639526 100644
--- a/vl.c
+++ b/vl.c
@@ -1801,9 +1801,8 @@  char *qemu_find_file(int type, const char *name)
     const char *subdir;
     char *buf;
 
-    /* If name contains path separators then try it as a straight path.  */
-    if ((strchr(name, '/') || strchr(name, '\\'))
-        && access(name, R_OK) == 0) {
+    /* Try the name as a straight path first */
+    if (access(name, R_OK) == 0) {
         return g_strdup(name);
     }
     switch (type) {