util: storage: fill in default ports when parsing backing chain

Similarly to when parsing XML we need to fill in default ports for the
backing chain. This was missed in commit 5bda835466
This commit is contained in:
Peter Krempa 2017-07-20 14:18:04 +02:00
parent 615e34a73d
commit 8444419f8c
2 changed files with 10 additions and 7 deletions

View File

@ -3340,6 +3340,9 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
if (rc < 0) if (rc < 0)
goto error; goto error;
if (virStorageSourceNetworkAssignDefaultPorts(ret) < 0)
goto error;
} }
return ret; return ret;

View File

@ -1349,7 +1349,7 @@ mymain(void)
TEST_BACKING_PARSE("://", NULL); TEST_BACKING_PARSE("://", NULL);
TEST_BACKING_PARSE("http://example.com/file", TEST_BACKING_PARSE("http://example.com/file",
"<source protocol='http' name='file'>\n" "<source protocol='http' name='file'>\n"
" <host name='example.com'/>\n" " <host name='example.com' port='80'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("rbd:testshare:id=asdf:mon_host=example.com", TEST_BACKING_PARSE("rbd:testshare:id=asdf:mon_host=example.com",
"<source protocol='rbd' name='testshare'>\n" "<source protocol='rbd' name='testshare'>\n"
@ -1385,14 +1385,14 @@ mymain(void)
TEST_BACKING_PARSE("json:{\"file.driver\":\"http\", " TEST_BACKING_PARSE("json:{\"file.driver\":\"http\", "
"\"file.url\":\"http://example.com/file\"}", "\"file.url\":\"http://example.com/file\"}",
"<source protocol='http' name='file'>\n" "<source protocol='http' name='file'>\n"
" <host name='example.com'/>\n" " <host name='example.com' port='80'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("json:{\"file\":{ \"driver\":\"http\"," TEST_BACKING_PARSE("json:{\"file\":{ \"driver\":\"http\","
"\"url\":\"http://example.com/file\"" "\"url\":\"http://example.com/file\""
"}" "}"
"}", "}",
"<source protocol='http' name='file'>\n" "<source protocol='http' name='file'>\n"
" <host name='example.com'/>\n" " <host name='example.com' port='80'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("json:{\"file.driver\":\"ftp\", " TEST_BACKING_PARSE("json:{\"file.driver\":\"ftp\", "
"\"file.url\":\"http://example.com/file\"}", "\"file.url\":\"http://example.com/file\"}",
@ -1400,7 +1400,7 @@ mymain(void)
TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\", " TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\", "
"\"file.filename\":\"gluster://example.com/vol/file\"}", "\"file.filename\":\"gluster://example.com/vol/file\"}",
"<source protocol='gluster' name='vol/file'>\n" "<source protocol='gluster' name='vol/file'>\n"
" <host name='example.com'/>\n" " <host name='example.com' port='24007'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"gluster\"," TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"gluster\","
"\"volume\":\"testvol\"," "\"volume\":\"testvol\","
@ -1421,7 +1421,7 @@ mymain(void)
"<source protocol='gluster' name='testvol/img.qcow2'>\n" "<source protocol='gluster' name='testvol/img.qcow2'>\n"
" <host name='example.com' port='1234'/>\n" " <host name='example.com' port='1234'/>\n"
" <host transport='unix' socket='/path/socket'/>\n" " <host transport='unix' socket='/path/socket'/>\n"
" <host name='example.com'/>\n" " <host name='example.com' port='24007'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\"," TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\","
"\"file.volume\":\"testvol\"," "\"file.volume\":\"testvol\","
@ -1441,7 +1441,7 @@ mymain(void)
"<source protocol='gluster' name='testvol/img.qcow2'>\n" "<source protocol='gluster' name='testvol/img.qcow2'>\n"
" <host name='example.com' port='1234'/>\n" " <host name='example.com' port='1234'/>\n"
" <host transport='unix' socket='/path/socket'/>\n" " <host transport='unix' socket='/path/socket'/>\n"
" <host name='example.com'/>\n" " <host name='example.com' port='24007'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\"," TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\","
"\"path\":\"/path/to/socket\"" "\"path\":\"/path/to/socket\""
@ -1552,7 +1552,7 @@ mymain(void)
"}" "}"
"}", "}",
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/0'>\n" "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/0'>\n"
" <host name='test.org'/>\n" " <host name='test.org' port='3260'/>\n"
"</source>\n"); "</source>\n");
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
"\"transport\":\"tcp\"," "\"transport\":\"tcp\","