mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
util: storage: Fix parsing of IPv6 portal address for iSCSI
Split on the last colon and avoid parsing port if the split remainder contains the closing square bracket, so that IPv6 addresses are interpreted correctly.
This commit is contained in:
parent
ab81dafe80
commit
0a3bae7d22
@ -3016,7 +3016,8 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
|
||||
if (VIR_STRDUP(src->hosts->name, portal) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((port = strchr(src->hosts->name, ':'))) {
|
||||
if ((port = strrchr(src->hosts->name, ':')) &&
|
||||
!strchr(port, ']')) {
|
||||
if (virStringParsePort(port + 1, &src->hosts->port) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
@ -1578,6 +1578,26 @@ mymain(void)
|
||||
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
||||
" <host name='test.org' port='1234'/>\n"
|
||||
"</source>\n");
|
||||
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
|
||||
"\"transport\":\"tcp\","
|
||||
"\"portal\":\"[2001::0]:1234\","
|
||||
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
|
||||
"\"lun\":6"
|
||||
"}"
|
||||
"}",
|
||||
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
||||
" <host name='[2001::0]' port='1234'/>\n"
|
||||
"</source>\n");
|
||||
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
|
||||
"\"transport\":\"tcp\","
|
||||
"\"portal\":\"[2001::0]\","
|
||||
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
|
||||
"\"lun\":6"
|
||||
"}"
|
||||
"}",
|
||||
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
||||
" <host name='[2001::0]' port='3260'/>\n"
|
||||
"</source>\n");
|
||||
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"sheepdog\","
|
||||
"\"vdi\":\"test\","
|
||||
"\"server\":{ \"type\":\"inet\","
|
||||
|
Loading…
Reference in New Issue
Block a user