On 11/18/19 11:42 AM, Eric Blake wrote:
+++ b/tests/qemu-iotests/common.filter
@@ -127,7 +127,8 @@ _filter_img_create()
-e "s#$TEST_DIR#TEST_DIR#g" \
-e "s#$SOCK_DIR#SOCK_DIR#g" \
-e "s#$IMGFMT#IMGFMT#g" \
- -e 's#nbd:127.0.0.1:10810#TEST_DIR/t.IMGFMT#g' \
+ -e 's#nbd:127.0.0.1:[0-9]\\+#TEST_DIR/t.IMGFMT#g' \
+ -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \
Why the second question mark? I thought the ? after the /// was
mandatory.
Some of our code outputs:
nbd+unix://?socket=...
when there is no export name, while other outputs:
nbd+unix:///?socket=...
Re-reading
https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md and RFC
3986, I see that both forms appear to be valid URIs (both have empty
authority, the first has empty path and the second has path '/', but NBD
says leading / in path is stripped to form the export name). However,
the NBD document does not mention the 2-slash form with no URI authority
or export name; perhaps we should amend that document to make it obvious
that it is indeed valid.
When there IS an export name, it outputs
nbd+unix:///name?socket=...
While in this case, the 3-slash form is essential - with only two
slashes, the URI 'nbd+unix://name?socket' would be trying to access a
URI authority of 'name' with an empty path, rather than the intended
empty authority and path of '/name' which gets translated to the NBD
export 'name'.
So the regex is matching 2 or 3 / (using \? to make the third optional),
then a mandatory ?.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org