Skip to contentSkip to conversation

libxl and docs: small improvements in qdisk support

PATCH Superseded Jim Fehlig 3 participants 14 messages Feb 17, 2016 – Feb 23, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jim Fehlig

author
#0 lore raw

cover libxl and docs: small improvements in qdisk support

This series contains a few improvments related to libxl's support for the various qdisk types. Patch1 is a small fix for libxlu_cfg to error when encountering unknown backslash- escaped characters instead of silently dropping them. Patch2 is actually unrelated and fixes a typo noticed while reviewing xl-disk-configuration.txt, which is improved a bit in patch3 wrt target= syntax.

Jim Fehlig (3):
libxlu_cfg: reject unknown characters following '\'
docs: fix typo in xl-disk-configuration.txt
docs: add more info about target= in disk config

 docs/misc/xl-disk-configuration.txt | 12 ++++++++++--
 tools/libxl/libxlu_cfg.c            |  5 +++++
 2 files changed, 15 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.0.1
author
#1 lore raw

PATCH 1/3 libxlu_cfg: reject unknown characters following '\'

When dequoting config strings in xlu__cfgl_dequote(), unknown characters following a '\', and the '\' itself, are discarded. E.g. a disk configuration string containing

rbd:pool/image:mon_host=192.168.0.100\:6789

would be dequoted as

rbd:pool/image:mon_host=192.168.0.1006789

Instead of discarding the '\' and unknown character, reject the string and set error to EINVAL.

---
 tools/libxl/libxlu_cfg.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/libxl/libxlu_cfg.c +5 -0
index 1d70909..f8e0bc7 100644
@@ -533,6 +533,11 @@ char *xlu__cfgl_dequote(CfgParseContext *ctx, const char *src) {
                 NUMERIC_CHAR(2,2,16,"hex");
             } else if (nc>='0' && nc<='7') {
                 NUMERIC_CHAR(1,3,10,"octal");
+            } else {
+                xlu__cfgl_lexicalerror(ctx, "invalid character after backlash "
+                                       "in quoted string");
+                ctx->err= EINVAL;
+                goto x;
             }
             assert(p <= src+len-1);
         } else {
Signature · 1 line
1.8.0.1
#2 lore raw

Re: [PATCH 1/3] libxlu_cfg: reject unknown characters following '\'

Quoted 4 lines · Jim Fehlig

When dequoting config strings in xlu__cfgl_dequote(), unknown characters following a '\', and the '\' itself, are discarded. E.g. a disk configuration string containing

Quoted 8 lines

  rbd:pool/image:mon_host=192.168.0.100\:6789

would be dequoted as

  rbd:pool/image:mon_host=192.168.0.1006789

Instead of discarding the '\' and unknown character, reject the string and set error to EINVAL.

Missing your S-o-b.

Other than that:

Quoted 2 lines

+                xlu__cfgl_lexicalerror(ctx, "invalid character after backlash " +                                       "in quoted string");

Please try where possible not to split string constants (so log messages can more easily be grepped for). If that would result in more than 80 characters then it is acceptable to pull the string in more than you would normally, e.g if this is (as I expect it will be) too long:

                xlu__cfgl_lexicalerror(ctx,

                                       "invalid character after backlash in quoted string");

then it's ok to do:
                xlu__cfgl_lexicalerror(ctx,
"invalid
character after backlash in quoted string");

(I usually try and keep it to a multiple of 4 spaces indent, FWIW) or for really long strings even:

                xlu__cfgl_lexicalerror(ctx,
"invalid character after backlash in quoted string blah blah blah");

is preferable to breaking the string in half.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by
#3 lore raw

Re: [PATCH 1/3] libxlu_cfg: reject unknown characters following '\'

Quoted 16 lines · Ian Campbell
Quoted 4 lines · Jim Fehlig

When dequoting config strings in xlu__cfgl_dequote(), unknown characters following a '\', and the '\' itself, are discarded. E.g. a disk configuration string containing

Quoted 8 lines

  rbd:pool/image:mon_host=192.168.0.100\:6789

would be dequoted as

  rbd:pool/image:mon_host=192.168.0.1006789

Instead of discarding the '\' and unknown character, reject the string and set error to EINVAL.

Missing your S-o-b.

Quoted 8 lines

Other than that:

Quoted 3 lines

+                xlu__cfgl_lexicalerror(ctx, "invalid character after backlash "
+                                       "in quoted string");

Please try where possible not to split string constants (so log messages can more easily be grepped for).

I see now that this parsing code is pretty liberally ignoring this advice already. So apart from the missing S-o-b this patch is

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#4 lore raw

Re: [PATCH 1/3] libxlu_cfg: reject unknown characters following '\'

Quoted 18 lines · Ian Campbell
Quoted 17 lines · Ian Campbell
Quoted 4 lines · Jim Fehlig

When dequoting config strings in xlu__cfgl_dequote(), unknown characters following a '\', and the '\' itself, are discarded. E.g. a disk configuration string containing

Quoted 8 lines

rbd:pool/image:mon_host=192.168.0.100\:6789

would be dequoted as

rbd:pool/image:mon_host=192.168.0.1006789

Instead of discarding the '\' and unknown character, reject the string and set error to EINVAL.

Missing your S-o-b.

Other than that:

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

+ xlu__cfgl_lexicalerror(ctx, "invalid character after
backlash "
+ "in quoted string");

Please try where possible not to split string constants (so log messages can more easily be grepped for).

I see now that this parsing code is pretty liberally ignoring this advice already. So apart from the missing S-o-b this patch is

Your suggestion is a good one and is common throughout much of libxl, so I pulled back the error string indentation in V2.

Regards,
Jim

author
#5 lore raw

PATCH 2/3 docs: fix typo in xl-disk-configuration.txt

In reply to Jim Fehlig
---
 docs/misc/xl-disk-configuration.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
docs/misc/xl-disk-configuration.txt +1 -1
index 6a2118d..29f6ddb 100644
@@ -160,7 +160,7 @@ Mandatory:             No
 Default value:         Automatically determine which backend to use.
 
 This does not affect the guest's view of the device.  It controls
-which software implementation of the Xen backend driver us used.
+which software implementation of the Xen backend driver is used.
 
 Not all backend drivers support all combinations of other options.
 For example, "phy" does not support formats other than "raw".
Signature · 1 line
1.8.0.1
Acked-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] docs: fix typo in xl-disk-configuration.txt

On Tue, 2016-02-16 at 20:54 -0700, Jim Fehlig wrote:

Missing S-o-b, otherwise:

Quoted 15 lines

---
 docs/misc/xl-disk-configuration.txt | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
docs/misc/xl-disk- renamed from docs/misc/xl-disk-configuration.txt +0 -0

configuration.txt
index 6a2118d..29f6ddb 100644

docs/misc/xl-disk-configuration.txt +0 -0
@@ -160,7 +160,7 @@ Mandatory:             No

 Default value:         Automatically determine which backend to use.
 This does not affect the guest's view of the device.  It controls

docs/misc/xl-disk-configuration.txt +1 -1
-which software implementation of the Xen backend driver us used.
+which software implementation of the Xen backend driver is used.
Quoted 3 lines


 Not all backend drivers support all combinations of other options. For example, "phy" does not support formats other than "raw".

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#7 lore raw

PATCH 3/3 docs: add more info about target= in disk config

In reply to Jim Fehlig

target= in disk config can be used to convey arbitrary configuration information to backends. Add a bit more info to xl-disk-configuration.txt to clarify this, including some simple nbd and rbd qdisk configurations.

---
 docs/misc/xl-disk-configuration.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
docs/misc/xl-disk-configuration.txt +9 -1
index 29f6ddb..0918fb8 100644
@@ -75,7 +75,15 @@ Special syntax:
    the target was already specified as a positional parameter.  This
    is the only way to specify a target string containing metacharacters
    such as commas and (in some cases) colons, which would otherwise be
-   misinterpreted.
+   misinterpreted. Meta-information in a target string can be used to
+   specify configuration information for a qdisk block backend. For
+   example the nbd and rbd qdisk block backends can be configured with
+
+     target=nbd:192.168.0.1:5555
+     target=rbd:pool/image:mon_host=192.186.0.1\\:6789
+
+   Note the use of double backslash ('\\') for metacharacters that need
+   escaped.
 
    Future parameter and flag names will start with an ascii letter and
    contain only ascii alphanumerics, hyphens and underscores, and will
Signature · 1 line
1.8.0.1
#8 lore raw

Re: [PATCH 3/3] docs: add more info about target= in disk config

Quoted 4 lines · Jim Fehlig

target= in disk config can be used to convey arbitrary configuration information to backends. Add a bit more info to xl-disk-configuration.txt to clarify this, including some simple nbd and rbd qdisk configurations.

Missing S-o-b.

Quoted 17 lines

---
 docs/misc/xl-disk-configuration.txt | 10 +++++++++-

 1 file changed, 9 insertions(+), 1 deletion(-)
docs/misc/xl-disk- renamed from docs/misc/xl-disk-configuration.txt +0 -0

configuration.txt
index 29f6ddb..0918fb8 100644

docs/misc/xl-disk-configuration.txt +0 -0
@@ -75,7 +75,15 @@ Special syntax:

    the target was already specified as a positional parameter.  This is the only way to specify a target string containing metacharacters such as commas and (in some cases) colons, which would otherwise be -   misinterpreted.
+   misinterpreted. Meta-information in a target string can be used to +   specify configuration information for a qdisk block backend. For +   example the nbd and rbd qdisk block backends can be configured with

docs/misc/xl-disk-configuration.txt Special syntax: · line 86

Quoted 6 lines
docs/misc/xl-disk-configuration.txt +6 -0
+
+     target=nbd:192.168.0.1:5555
+     target=rbd:pool/image:mon_host=192.186.0.1\\:6789
+
+   Note the use of double backslash ('\\') for metacharacters that need
+   escaped.

"need to be escaped".

However I wouldn't describe "\\" that way, I think I would say "note that \
is used to escape metacharacters and therefore to get a literal backslash "\\" is required".

The general concept of escaping metacharaters is not mentioned in this doc at all, i.e. there is no mention of which characters need such escaping nor of the various "special" codes (\t and \n etc), nor of the octal and hex escape codes. Maybe that's a topic for another patch though.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#9 lore raw

Re: [PATCH 3/3] docs: add more info about target= in disk config

Quoted 32 lines · Ian Campbell
Quoted 4 lines · Jim Fehlig

target= in disk config can be used to convey arbitrary configuration information to backends. Add a bit more info to xl-disk-configuration.txt to clarify this, including some simple nbd and rbd qdisk configurations.

Missing S-o-b.

Quoted 13 lines
---
 docs/misc/xl-disk-configuration.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
docs/misc/xl-disk- renamed from docs/misc/xl-disk-configuration.txt +0 -0

configuration.txt
index 29f6ddb..0918fb8 100644

docs/misc/xl-disk-configuration.txt +0 -0
@@ -75,7 +75,15 @@ Special syntax:
    the target was already specified as a positional parameter.  This
    is the only way to specify a target string containing metacharacters
    such as commas and (in some cases) colons, which would otherwise be

docs/misc/xl-disk-configuration.txt Special syntax: · line 86

Quoted 10 lines
docs/misc/xl-disk-configuration.txt +9 -1
-   misinterpreted.
+   misinterpreted. Meta-information in a target string can be used to
+   specify configuration information for a qdisk block backend. For
+   example the nbd and rbd qdisk block backends can be configured with
+
+     target=nbd:192.168.0.1:5555
+     target=rbd:pool/image:mon_host=192.186.0.1\\:6789
+
+   Note the use of double backslash ('\\') for metacharacters that need
+   escaped.

"need to be escaped".

Quoted 3 lines

However I wouldn't describe "\\" that way, I think I would say "note that \
is used to escape metacharacters and therefore to get a literal backslash "\\" is required".

Agreed. I changed the text and sent a V2 of the series.

Quoted 5 lines

The general concept of escaping metacharaters is not mentioned in this doc at all, i.e. there is no mention of which characters need such escaping nor of the various "special" codes (\t and \n etc), nor of the octal and hex escape codes. Maybe that's a topic for another patch though.

I could do that in a follow-up, but I have no clue what those mean or how they are used.

Regards,
Jim

#10 lore raw

Re: [PATCH 3/3] docs: add more info about target= in disk config

Quoted 9 lines · Jim Fehlig
Quoted 6 lines

The general concept of escaping metacharaters is not mentioned in this doc at all, i.e. there is no mention of which characters need such escaping nor of the various "special" codes (\t and \n etc), nor of the octal and hex escape codes. Maybe that's a topic for another patch though.

I could do that in a follow-up, but I have no clue what those mean or how they are used.

Fair enough. I've some spare cycles so I'll try and reverse engineer it and write it down.

Ian.

#11 lore raw

Re: [PATCH 3/3] docs: add more info about target= in disk config

In reply to Jim Fehlig

Jim Fehlig writes ("[PATCH 3/3] docs: add more info about target= in disk config"):

Quoted 16 lines

target= in disk config can be used to convey arbitrary configuration information to backends. Add a bit more info to xl-disk-configuration.txt to clarify this, including some simple nbd and rbd qdisk configurations.

---
 docs/misc/xl-disk-configuration.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
docs/misc/xl-disk-configuration.txt +0 -0
index 29f6ddb..0918fb8 100644
@@ -75,7 +75,15 @@ Special syntax:
    the target was already specified as a positional parameter.  This
    is the only way to specify a target string containing metacharacters
    such as commas and (in some cases) colons, which would otherwise be

docs/misc/xl-disk-configuration.txt Special syntax: · line 86

Quoted 10 lines
docs/misc/xl-disk-configuration.txt +9 -1
-   misinterpreted.
+   misinterpreted. Meta-information in a target string can be used to
+   specify configuration information for a qdisk block backend. For
+   example the nbd and rbd qdisk block backends can be configured with
+
+     target=nbd:192.168.0.1:5555
+     target=rbd:pool/image:mon_host=192.186.0.1\\:6789
+
+   Note the use of double backslash ('\\') for metacharacters that need
+   escaped.

I'm not entirely comfortable with documenting this as supported. The difficulties I see are:

In the usual configuration, libxl decides for itself what (libxl) backend to use. Different versions of libxl might make different choices, so a configuration that works with one version of libxl might not work with another. That's fine for an undocumented feature but not so good if it's actually advertised. At the very least the docs need to say that to rely on this you must specify backend=qdisk.

And this is a layering violation, or rather a violation of the expected semantics of the target string.

I think it would be much better to support nbd and rbd explicitly in libxl. Maybe we should have a "protocol=" parameter, so you could write something like this:
disk=["vdev=xvda, protocol=nbd, target=192.168.0.1:5555"]

This would allow libxl to make better choices about backends, even if right now all it does is force the use of the qemu backend and pass the target string to qemu.

Finally, if this is actually true, it is a bug. The specification (docs/misc/xl-disk-configuration.txt) says:

Description: Block device or image file path. When this is
used as a path, /dev will be prepended if the path doesn't start with a '/'.

See also what is said under `script='.

Ian.

author
#12 lore raw

Re: [PATCH 3/3] docs: add more info about target= in disk config

Quoted 31 lines · Ian Jackson

Jim Fehlig writes ("[PATCH 3/3] docs: add more info about target= in disk config"):

Quoted 16 lines

target= in disk config can be used to convey arbitrary configuration information to backends. Add a bit more info to xl-disk-configuration.txt to clarify this, including some simple nbd and rbd qdisk configurations.

---
 docs/misc/xl-disk-configuration.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
docs/misc/xl-disk-configuration.txt +0 -0
index 29f6ddb..0918fb8 100644
@@ -75,7 +75,15 @@ Special syntax:
    the target was already specified as a positional parameter.  This
    is the only way to specify a target string containing metacharacters
    such as commas and (in some cases) colons, which would otherwise be

docs/misc/xl-disk-configuration.txt Special syntax: · line 86

Quoted 10 lines
docs/misc/xl-disk-configuration.txt +9 -1
-   misinterpreted.
+   misinterpreted. Meta-information in a target string can be used to
+   specify configuration information for a qdisk block backend. For
+   example the nbd and rbd qdisk block backends can be configured with
+
+     target=nbd:192.168.0.1:5555
+     target=rbd:pool/image:mon_host=192.186.0.1\\:6789
+
+   Note the use of double backslash ('\\') for metacharacters that need
+   escaped.

I'm not entirely comfortable with documenting this as supported. The difficulties I see are:

Quoted 6 lines

In the usual configuration, libxl decides for itself what (libxl) backend to use. Different versions of libxl might make different choices, so a configuration that works with one version of libxl might not work with another. That's fine for an undocumented feature but not so good if it's actually advertised. At the very least the docs need to say that to rely on this you must specify backend=qdisk.

The text I added in this patch states that meta-information can be used with qdisk. I didn't go as far as saying _only_ qdisk, since other backends might interpret such meta-information too. But I can add that if we decide to go with this doc patch.

Quoted 5 lines

And this is a layering violation, or rather a violation of the expected semantics of the target string.

Quoted 8 lines

I think it would be much better to support nbd and rbd explicitly in libxl. Maybe we should have a "protocol=" parameter, so you could write something like this:

   disk=["vdev=xvda, protocol=nbd, target=192.168.0.1:5555"]

This would allow libxl to make better choices about backends, even if right now all it does is force the use of the qemu backend and pass the target string to qemu.

I agree with your suggestion, which is why I took that approach in the original RFC post

http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg03184.html

Did you see the doc and IDL RFC patch attached to that post? IMO, we need more than just protocol. An rbd device configuration can include a pool/volume name, multiple servers, auth type, auth username, and auth passwd/data. E.g.

disk = [ 'vdev=xvda, backendtype=qdisk, backendprotocol=rbd,
server=192.168.0.1:5555, server=192.168.0.2:5555, auth=joe:joes-secret, target=some-pool/some-image' ]

Quoted 8 lines

Finally, if this is actually true, it is a bug. The specification (docs/misc/xl-disk-configuration.txt) says:

Description: Block device or image file path. When this is
used as a path, /dev will be prepended if the path doesn't start with a '/'.

That is not true. I've successfully used the following disk config

disk = [ "vdev=xvdb, backendtype=qdisk,

target=rbd:libvirtpool/image:auth_supported=none:mon_host=192.168.0.1\\:6789\\;192.168.0.2\\:6789\\;192.168.0.3\\:6789" ]

disk = [ "vdev=xvdb, backendtype=qdisk, target=nbd:192.168.0.1:5555" ]

I wouldn't call those targets "image file paths", but they don't start with a '/' and none is prepended.

Quoted 1 line

See also what is said under `script='.

Do you mean how the <script> path is determined? Or the relationship between <script> and <target>?

Regards,
Jim

#13 lore raw

Re: [PATCH 3/3] docs: add more info about target= in disk config

Quoted 101 lines · Jim Fehlig
Quoted 38 lines · Ian Jackson

Jim Fehlig writes ("[PATCH 3/3] docs: add more info about target= in disk config"):

Quoted 30 lines

target= in disk config can be used to convey arbitrary configuration information to backends. Add a bit more info to xl-disk-configuration.txt to clarify this, including some simple nbd and rbd qdisk configurations.
---
 docs/misc/xl-disk-configuration.txt | 10 +++++++++-

 1 file changed, 9 insertions(+), 1 deletion(-)
docs/misc/xl-disk- renamed from docs/misc/xl-disk-configuration.txt +0 -0

configuration.txt
index 29f6ddb..0918fb8 100644

docs/misc/xl-disk-configuration.txt +0 -0
@@ -75,7 +75,15 @@ Special syntax:

    the target was already specified as a positional parameter.  This is the only way to specify a target string containing metacharacters
    such as commas and (in some cases) colons, which would otherwise be
-   misinterpreted.
+   misinterpreted. Meta-information in a target string can be used to
+   specify configuration information for a qdisk block backend. For +   example the nbd and rbd qdisk block backends can be configured with

docs/misc/xl-disk-configuration.txt +5 -0
+
+     target=nbd:192.168.0.1:5555
+     target=rbd:pool/image:mon_host=192.186.0.1\\:6789
+
+   Note the use of double backslash ('\\') for metacharacters that
Quoted 2 lines

need
+   escaped.

I'm not entirely comfortable with documenting this as supported. The difficulties I see are:

Quoted 6 lines

In the usual configuration, libxl decides for itself what (libxl) backend to use.  Different versions of libxl might make different choices, so a configuration that works with one version of libxl might not work with another.  That's fine for an undocumented feature but not so good if it's actually advertised.  At the very least the docs need to say that to rely on this you must specify backend=qdisk.

The text I added in this patch states that meta-information can be used with
qdisk. I didn't go as far as saying _only_ qdisk, since other backends might
interpret such meta-information too. But I can add that if we decide to go with
this doc patch.

Quoted 5 lines

And this is a layering violation, or rather a violation of the expected semantics of the target string.

Quoted 8 lines

I think it would be much better to support nbd and rbd explicitly in libxl.  Maybe we should have a "protocol=" parameter, so you could write something like this:
   disk=["vdev=xvda, protocol=nbd, target=192.168.0.1:5555"]

This would allow libxl to make better choices about backends, even if right now all it does is force the use of the qemu backend and pass the target string to qemu.

I agree with your suggestion, which is why I took that approach in the original
RFC post

http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg03184.html

Did you see the doc and IDL RFC patch attached to that post? IMO, we need more
than just protocol. An rbd device configuration can include a pool/volume name,
multiple servers, auth type, auth username, and auth passwd/data. E.g.

  disk = [ 'vdev=xvda, backendtype=qdisk, backendprotocol=rbd, server=192.168.0.1:5555, server=192.168.0.2:5555, auth=joe:joes-secret, target=some-pool/some-image' ]

Quoted 8 lines

Finally, if this is actually true, it is a bug.  The specification (docs/misc/xl-disk-configuration.txt) says:

  Description:           Block device or image file path.  When this is used as a path, /dev will be prepended if the path doesn't start with a '/'.

That is not true. I've successfully used the following disk config

  disk = [ "vdev=xvdb, backendtype=qdisk,
target=rbd:libvirtpool/image:auth_supported=none:mon_host=192.168.0.1\\:6 789\\;192.168.0.2\\:6789\\;192.168.0.3\\:6789"
]

Quoted 5 lines

disk = [ "vdev=xvdb, backendtype=qdisk, target=nbd:192.168.0.1:5555" ]

I wouldn't call those targets "image file paths", but they don't start with a
'/' and none is prepended.

It has also been long expected that one can pass an iSCSI target= here.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel