All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] drive_add: file names with spaces
@ 2017-10-28  4:44 Programmingkid
  2017-10-28  6:00 ` Eric Blake
  0 siblings, 1 reply; 9+ messages in thread
From: Programmingkid @ 2017-10-28  4:44 UTC (permalink / raw)
  To: qemu-devel@nongnu.org qemu-devel

I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line

I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-28  4:44 [Qemu-devel] drive_add: file names with spaces Programmingkid
@ 2017-10-28  6:00 ` Eric Blake
  2017-10-29 10:21   ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Blake @ 2017-10-28  6:00 UTC (permalink / raw)
  To: Programmingkid, qemu-devel@nongnu.org qemu-devel

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

On 10/28/2017 06:44 AM, Programmingkid wrote:
> I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line
> 
> I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?

Not in HMP, which lacks quoting.  (Unless you want to patch HMP to learn
quoting)

But using spaces in filenames works fine in QMP.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-28  6:00 ` Eric Blake
@ 2017-10-29 10:21   ` Dr. David Alan Gilbert
  2017-10-30  1:38     ` Programmingkid
  0 siblings, 1 reply; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-29 10:21 UTC (permalink / raw)
  To: Eric Blake; +Cc: Programmingkid, qemu-devel@nongnu.org qemu-devel

* Eric Blake (eblake@redhat.com) wrote:
> On 10/28/2017 06:44 AM, Programmingkid wrote:
> > I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line
> > 
> > I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?
> 
> Not in HMP, which lacks quoting.  (Unless you want to patch HMP to learn
> quoting)

I think it's already got that code at least in some places.
monitor_parse_arguments calls get_str, and get_str understands " wrapped
arguments.

drive_add 1 "file=foo bar"

gives me:
Could not open 'foo bar': No such file or directory

so I think that's doing the right thing.

Dave

> But using spaces in filenames works fine in QMP.
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
> 


--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-29 10:21   ` Dr. David Alan Gilbert
@ 2017-10-30  1:38     ` Programmingkid
  2017-10-30 14:32       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 9+ messages in thread
From: Programmingkid @ 2017-10-30  1:38 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: Eric Blake, qemu-devel@nongnu.org qemu-devel


> On Oct 29, 2017, at 6:21 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> 
> * Eric Blake (eblake@redhat.com) wrote:
>> On 10/28/2017 06:44 AM, Programmingkid wrote:
>>> I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line
>>> 
>>> I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?
>> 
>> Not in HMP, which lacks quoting.  (Unless you want to patch HMP to learn
>> quoting)
> 
> I think it's already got that code at least in some places.
> monitor_parse_arguments calls get_str, and get_str understands " wrapped
> arguments.
> 
> drive_add 1 "file=foo bar"
> 
> gives me:
> Could not open 'foo bar': No such file or directory
> 
> so I think that's doing the right thing.
> 
> Dave
> 
>> But using spaces in filenames works fine in QMP.
>> 
>> -- 
>> Eric Blake, Principal Software Engineer
>> Red Hat, Inc.           +1-919-301-3266
>> Virtualization:  qemu.org | libvirt.org
>> 
> 
> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Thank you so much for this info. It solved my problem :)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-30  1:38     ` Programmingkid
@ 2017-10-30 14:32       ` Dr. David Alan Gilbert
  2017-10-30 15:22         ` Programmingkid
  2017-10-30 20:02         ` Eric Blake
  0 siblings, 2 replies; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-30 14:32 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel@nongnu.org qemu-devel

* Programmingkid (programmingkidx@gmail.com) wrote:
> 
> > On Oct 29, 2017, at 6:21 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> > 
> > * Eric Blake (eblake@redhat.com) wrote:
> >> On 10/28/2017 06:44 AM, Programmingkid wrote:
> >>> I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line
> >>> 
> >>> I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?
> >> 
> >> Not in HMP, which lacks quoting.  (Unless you want to patch HMP to learn
> >> quoting)
> > 
> > I think it's already got that code at least in some places.
> > monitor_parse_arguments calls get_str, and get_str understands " wrapped
> > arguments.
> > 
> > drive_add 1 "file=foo bar"
> > 
> > gives me:
> > Could not open 'foo bar': No such file or directory
> > 
> > so I think that's doing the right thing.
> > 
> > Dave
> > 
> >> But using spaces in filenames works fine in QMP.
> >> 
> >> -- 
> >> Eric Blake, Principal Software Engineer
> >> Red Hat, Inc.           +1-919-301-3266
> >> Virtualization:  qemu.org | libvirt.org
> >> 
> > 
> > 
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> 
> Thank you so much for this info. It solved my problem :)

Now, the real challenge is how to deal with a filename with a comma in;
   drive_add 1 "file=foo,bar"
   Could not open 'foo': No such file or directory

Dave

> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-30 14:32       ` Dr. David Alan Gilbert
@ 2017-10-30 15:22         ` Programmingkid
  2017-10-30 17:03           ` Dr. David Alan Gilbert
  2017-10-30 20:02         ` Eric Blake
  1 sibling, 1 reply; 9+ messages in thread
From: Programmingkid @ 2017-10-30 15:22 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel@nongnu.org qemu-devel


> On Oct 30, 2017, at 10:32 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> 
> * Programmingkid (programmingkidx@gmail.com) wrote:
>> 
>>> On Oct 29, 2017, at 6:21 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
>>> 
>>> * Eric Blake (eblake@redhat.com) wrote:
>>>> On 10/28/2017 06:44 AM, Programmingkid wrote:
>>>>> I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line
>>>>> 
>>>>> I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?
>>>> 
>>>> Not in HMP, which lacks quoting.  (Unless you want to patch HMP to learn
>>>> quoting)
>>> 
>>> I think it's already got that code at least in some places.
>>> monitor_parse_arguments calls get_str, and get_str understands " wrapped
>>> arguments.
>>> 
>>> drive_add 1 "file=foo bar"
>>> 
>>> gives me:
>>> Could not open 'foo bar': No such file or directory
>>> 
>>> so I think that's doing the right thing.
>>> 
>>> Dave
>>> 
>>>> But using spaces in filenames works fine in QMP.
>>>> 
>>>> -- 
>>>> Eric Blake, Principal Software Engineer
>>>> Red Hat, Inc.           +1-919-301-3266
>>>> Virtualization:  qemu.org | libvirt.org
>>>> 
>>> 
>>> 
>>> --
>>> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>> 
>> Thank you so much for this info. It solved my problem :)
> 
> Now, the real challenge is how to deal with a filename with a comma in;
>   drive_add 1 "file=foo,bar"
>   Could not open 'foo': No such file or directory

I think the logical thing to do is not to depend on characters like spaces and commas to indicate a change in field. This would mean a change to how the user could specify arguments to a command. My first thought is to use a json-like syntax like this:

CMD: drive_add
File: <full path of file>
ID: mydrive

but this would still have the problem with newline characters in the file name. Spaces, commas, single and double quotes would be usable. Newline characters in file names are rare enough that we might consider ignoring this case altogether. 

Another option is using a tag based system that would be able to handle every character. Something like this:

drive_add 0 <file> /users/user/some path </file> <id> mydrive </id>

The only way this system would fail if the text "</file>" was in the file name. 

Any solutions you wish to share?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-30 15:22         ` Programmingkid
@ 2017-10-30 17:03           ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-30 17:03 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel@nongnu.org qemu-devel

* Programmingkid (programmingkidx@gmail.com) wrote:
> 
> > On Oct 30, 2017, at 10:32 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> > 
> > * Programmingkid (programmingkidx@gmail.com) wrote:
> >> 
> >>> On Oct 29, 2017, at 6:21 AM, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> >>> 
> >>> * Eric Blake (eblake@redhat.com) wrote:
> >>>> On 10/28/2017 06:44 AM, Programmingkid wrote:
> >>>>> I'm trying to use an image file that has spaces in its file name (and sometimes in the path) to be used as a USB flash drive. When I try adding the image file using the drive_add command I see this error: drive_add: extraneous characters at the end of the line
> >>>>> 
> >>>>> I have tried using single and double quotes around the file name but this does not help. Is there a way to use files that have spaces in it's name with drive_add?
> >>>> 
> >>>> Not in HMP, which lacks quoting.  (Unless you want to patch HMP to learn
> >>>> quoting)
> >>> 
> >>> I think it's already got that code at least in some places.
> >>> monitor_parse_arguments calls get_str, and get_str understands " wrapped
> >>> arguments.
> >>> 
> >>> drive_add 1 "file=foo bar"
> >>> 
> >>> gives me:
> >>> Could not open 'foo bar': No such file or directory
> >>> 
> >>> so I think that's doing the right thing.
> >>> 
> >>> Dave
> >>> 
> >>>> But using spaces in filenames works fine in QMP.
> >>>> 
> >>>> -- 
> >>>> Eric Blake, Principal Software Engineer
> >>>> Red Hat, Inc.           +1-919-301-3266
> >>>> Virtualization:  qemu.org | libvirt.org
> >>>> 
> >>> 
> >>> 
> >>> --
> >>> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> >> 
> >> Thank you so much for this info. It solved my problem :)
> > 
> > Now, the real challenge is how to deal with a filename with a comma in;
> >   drive_add 1 "file=foo,bar"
> >   Could not open 'foo': No such file or directory
> 
> I think the logical thing to do is not to depend on characters like spaces and commas to indicate a change in field. This would mean a change to how the user could specify arguments to a command. My first thought is to use a json-like syntax like this:
> 
> CMD: drive_add
> File: <full path of file>
> ID: mydrive
> 
> but this would still have the problem with newline characters in the file name. Spaces, commas, single and double quotes would be usable. Newline characters in file names are rare enough that we might consider ignoring this case altogether. 

Well then you may as well almost use JSON.

> Another option is using a tag based system that would be able to handle every character. Something like this:
> 
> drive_add 0 <file> /users/user/some path </file> <id> mydrive </id>
> 
> The only way this system would fail if the text "</file>" was in the file name. 
> 
> Any solutions you wish to share?

There aren't many simple solutions; almost everything requires
a way to escape whatever character/tag you choose because that
could validly be in a filename.

If there's a way to escape the , so you could do something like
drive_add 1 "file=foo\,bar"

(I'm not sure if that's \, or \\, or whatever) then that would
work; but I've not dug to find the code that splits the file= opts
to find if it already has an escape mechanism)

Dave

--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-30 14:32       ` Dr. David Alan Gilbert
  2017-10-30 15:22         ` Programmingkid
@ 2017-10-30 20:02         ` Eric Blake
  2017-10-30 20:15           ` Dr. David Alan Gilbert
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Blake @ 2017-10-30 20:02 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Programmingkid; +Cc: qemu-devel@nongnu.org qemu-devel

[-- Attachment #1: Type: text/plain, Size: 605 bytes --]

On 10/30/2017 03:32 PM, Dr. David Alan Gilbert wrote:

> Now, the real challenge is how to deal with a filename with a comma in;
>    drive_add 1 "file=foo,bar"
>    Could not open 'foo': No such file or directory
> 

Does HMP use the QemuOpts parser?  If so, try:

drive_add 1 "file=foo,,bar"

(that is, reproduce the double-comma escaping mechanism that we use on
the command line).

But I haven't personally tried this, so I have no idea if it will help.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] drive_add: file names with spaces
  2017-10-30 20:02         ` Eric Blake
@ 2017-10-30 20:15           ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-30 20:15 UTC (permalink / raw)
  To: Eric Blake; +Cc: Programmingkid, qemu-devel@nongnu.org qemu-devel

* Eric Blake (eblake@redhat.com) wrote:
> On 10/30/2017 03:32 PM, Dr. David Alan Gilbert wrote:
> 
> > Now, the real challenge is how to deal with a filename with a comma in;
> >    drive_add 1 "file=foo,bar"
> >    Could not open 'foo': No such file or directory
> > 
> 
> Does HMP use the QemuOpts parser?  If so, try:
> 
> drive_add 1 "file=foo,,bar"
> 
> (that is, reproduce the double-comma escaping mechanism that we use on
> the command line).
> 
> But I haven't personally tried this, so I have no idea if it will help.

Ah yes it does;  I never knew that worked.

Dave

> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
> 



--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-10-30 20:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28  4:44 [Qemu-devel] drive_add: file names with spaces Programmingkid
2017-10-28  6:00 ` Eric Blake
2017-10-29 10:21   ` Dr. David Alan Gilbert
2017-10-30  1:38     ` Programmingkid
2017-10-30 14:32       ` Dr. David Alan Gilbert
2017-10-30 15:22         ` Programmingkid
2017-10-30 17:03           ` Dr. David Alan Gilbert
2017-10-30 20:02         ` Eric Blake
2017-10-30 20:15           ` Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.