提交 5f2fa393 编写于 作者: P Peter Krempa

util: storagefile: Properly set transport type when parsing NBD strings

When parsing legacy NBD backing file strings such as
'nbd:unix:/tmp/sock:exportname=/' we'd fail to set the transport to
VIR_STORAGE_NET_HOST_TRANS_UNIX. This started to be a problem once we
actually started to generate config of the backing store on the command
line with -blockdev as the JSON code would try to format it as TCP and
fail with:

 internal error: argument key 'host' must not have null value

Set the type properly and add a test.

This bug was found by the libguestfs test suite in:

https://bugzilla.redhat.com/show_bug.cgi?id=1791614Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reported-by: NMing Xie <mxie@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Tested-by: NRichard W.M. Jones <rjones@redhat.com>
上级 9bb3571f
......@@ -2964,7 +2964,7 @@ virStorageSourceParseNBDColonString(const char *nbdstr,
}
src->hosts->socket = g_strdup(backing[2]);
src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
} else {
src->hosts->name = g_strdup(backing[1]);
......
......@@ -1258,6 +1258,10 @@ mymain(void)
"<source protocol='nbd' name=':test'>\n"
" <host name='example.org' port='6000'/>\n"
"</source>\n");
TEST_BACKING_PARSE("nbd:unix:/tmp/sock:exportname=/",
"<source protocol='nbd' name='/'>\n"
" <host transport='unix' socket='/tmp/sock'/>\n"
"</source>\n");
TEST_BACKING_PARSE("nbd://example.org:1234",
"<source protocol='nbd'>\n"
" <host name='example.org' port='1234'/>\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册