diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 3ca8e790ea..976a02baeb 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -305,7 +305,10 @@ - + + + + diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index f8c968e682..bd6e3d509d 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -261,6 +261,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, VIR_DEBUG("Found %zu RADOS cluster monitors in the pool configuration", source->nhost); + /* combine host and port into portal */ for (i = 0; i < source->nhost; i++) { if (source->hosts[i].name != NULL && !source->hosts[i].port) { @@ -268,7 +269,15 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, source->hosts[i].name); } else if (source->hosts[i].name != NULL && source->hosts[i].port) { - virBufferAsprintf(&mon_host, "%s:%d,", + const char *incFormat; + if (virSocketAddrNumericFamily(source->hosts[i].name) == AF_INET6) { + /* IPv6 address must be escaped in brackets on the cmd line */ + incFormat = "[%s]:%d"; + } else { + /* listenAddress is a hostname or IPv4 */ + incFormat = "%s:%d"; + } + virBufferAsprintf(&mon_host, incFormat, source->hosts[i].name, source->hosts[i].port); } else { diff --git a/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml new file mode 100644 index 0000000000..0744b3382c --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml @@ -0,0 +1,13 @@ + + ceph + 47c1faee-0207-e741-f5ae-d9b019b98fe2 + + rbd + + + + + + + + diff --git a/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml new file mode 100644 index 0000000000..cc2a37975d --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml @@ -0,0 +1,16 @@ + + ceph + 47c1faee-0207-e741-f5ae-d9b019b98fe2 + 0 + 0 + 0 + + + + + rbd + + + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 2ae514f346..b6f4cb4226 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -95,6 +95,7 @@ mymain(void) DO_TEST("pool-zfs-sourcedev"); DO_TEST("pool-rbd"); #ifdef WITH_STORAGE_RBD + DO_TEST("pool-rbd-ipv6"); DO_TEST("pool-rbd-refresh-volume-allocation"); DO_TEST("pool-rbd-ns-configopts"); #endif