[libvirt] Which symbols can be used in file paths in libvirt's XMLs?

Hello, There is an absFilePatch type in docs/schemas/basictypes.rng rng schema: <define name="absFilePath"> <data type="string"> <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%,:]+</param> </data> </define> There are quite few symbols in this set of the ones, which linux allows to have in file paths. For example spaces or curly braces are not allowed. There are a lot of elements of this type in other rng schems, for example: <define name="diskSourceFile"> <optional> <attribute name="type"> <value>file</value> </attribute> </optional> <interleave> <optional> <element name="source"> <optional> <attribute name="file"> <ref name="absFilePath"/> </attribute> There is no checks in libvirt if the the xml, given to, for example, virDomainDefineXML function conforms to this schema. I've added a disk to the domain with curly braces in path and there were no errors: <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/home/libvirt/{123}.qcow2'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> The domain was successfully defined and virsh dumpxml shows this path in output. So the question is, where did this path pattern come from? Is it possible to use file paths with another symbols or there will be some problems? -- Dmitry Guryanov

On Wed, Jul 01, 2015 at 07:22:33PM +0300, Dmitry Guryanov wrote:
Hello,
There is an absFilePatch type in docs/schemas/basictypes.rng rng schema:
<define name="absFilePath"> <data type="string"> <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%,:]+</param> </data> </define>
There are quite few symbols in this set of the ones, which linux allows to have in file paths. For example spaces or curly braces are not allowed. There are a lot of elements of this type in other rng schems, for example:
[snip]
So the question is, where did this path pattern come from? Is it possible to use file paths with another symbols or there will be some problems?
I think this regex pattern is a bit of a misguided attempt to perform semantic validation on the XML content. I'd probably be inclined to simplify it to '/.*' and just delegate all other validation to drivers as they desire. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 07/01/2015 07:36 PM, Daniel P. Berrange wrote:
On Wed, Jul 01, 2015 at 07:22:33PM +0300, Dmitry Guryanov wrote:
Hello,
There is an absFilePatch type in docs/schemas/basictypes.rng rng schema:
<define name="absFilePath"> <data type="string"> <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%,:]+</param> </data> </define>
There are quite few symbols in this set of the ones, which linux allows to have in file paths. For example spaces or curly braces are not allowed. There are a lot of elements of this type in other rng schems, for example: [snip]
So the question is, where did this path pattern come from? Is it possible to use file paths with another symbols or there will be some problems? I think this regex pattern is a bit of a misguided attempt to perform semantic validation on the XML content. I'd probably be inclined to simplify it to '/.*' and just delegate all other validation to drivers as they desire.
Thanks, Daniel. I've sent a patch, which changes rng scheme.
Regards, Daniel
participants (2)
-
Daniel P. Berrange
-
Dmitry Guryanov