<html><head><meta http-equiv="content-type" content="text/html; charset=GB2312"><style>body { line-height: 1.5; }p { margin-top: 0px; margin-bottom: 0px; }body { font-size: 10.5pt; font-family: Î¢ÈíÑźÚ; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><span style="background-color: rgba(0, 0, 0, 0);">Hosts for rbd are ceph monitor daemons. These have fixed IP addresses,
<br>so they are often referenced by IP rather than hostname for
<br>convenience, or to avoid relying on DNS. Using IPv4 addresses as the
<br>host name works already, but IPv6 addresses require rbd-specific
<br>escaping because the colon is used as an option separator in the
<br>string passed to librados.
<br>
<br>Escape these colons, and enclose the IPv6 address in square brackets
<br>so it is distinguished from the port, which is currently mandatory.
<br>
<br>Signed-off-by: Yi Li <yili@winhong.com>
<br>---
<br> docs/schemas/storagepool.rng                  |  5 ++++-
<br> src/storage/storage_backend_rbd.c             | 13 ++++++++++---
<br> tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml  | 13 +++++++++++++
<br> tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml | 16 ++++++++++++++++
<br> tests/storagepoolxml2xmltest.c                |  1 +
<br> 5 files changed, 44 insertions(+), 4 deletions(-)
<br> create mode 100644 tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
<br> create mode 100644 tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
<br>
<br>diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
<br>index 3ca8e79..976a02b 100644
<br>--- a/docs/schemas/storagepool.rng
<br>+++ b/docs/schemas/storagepool.rng
<br>@@ -305,7 +305,10 @@
<br>     <oneOrMore>
<br>       <element name='host'>
<br>         <attribute name='name'>
<br>-          <text/>
<br>+          <choice>
<br>+            <ref name="dnsName"/>
<br>+            <ref name="ipAddr"/>
<br>+          </choice>
<br>         </attribute>
<br>         <optional>
<br>           <attribute name='port'>
<br>diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
<br>index f8c968e..3056563 100644
<br>--- a/src/storage/storage_backend_rbd.c
<br>+++ b/src/storage/storage_backend_rbd.c
<br>@@ -268,9 +268,16 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
<br>                               source->hosts[i].name);
<br>         } else if (source->hosts[i].name != NULL &&
<br>             source->hosts[i].port) {
<br>-            virBufferAsprintf(&mon_host, "%s:%d,",
<br>-                              source->hosts[i].name,
<br>-                              source->hosts[i].port);
<br>+            /* assume host containing : is ipv6 */
<br>+            if (strchr(source->hosts[i].name, ':')) {
<br>+                virBufferAsprintf(&mon_host, "[%s]:%d,",
<br>+                                  source->hosts[i].name,
<br>+                                  source->hosts[i].port);
<br>+            } else {
<br>+                virBufferAsprintf(&mon_host, "%s:%d,",
<br>+                                  source->hosts[i].name,
<br>+                                  source->hosts[i].port);
<br>+            }
<br>         } else {
<br>             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
<br>                            _("received malformed monitor, check the XML definition"));
<br>diff --git a/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
<br>new file mode 100644
<br>index 0000000..0744b33
<br>--- /dev/null
<br>+++ b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
<br>@@ -0,0 +1,13 @@
<br>+<pool type='rbd'>
<br>+  <name>ceph</name>
<br>+  <uuid>47c1faee-0207-e741-f5ae-d9b019b98fe2</uuid>
<br>+  <source>
<br>+    <name>rbd</name>
<br>+    <host name='localhost' port='6789'/>
<br>+    <host name='localhost' port='6790'/>
<br>+    <host name='2205::192:168:205:141' port='6789'/>
<br>+    <auth username='admin' type='ceph'>
<br>+      <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
<br>+    </auth>
<br>+  </source>
<br>+</pool>
<br>diff --git a/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
<br>new file mode 100644
<br>index 0000000..cc2a379
<br>--- /dev/null
<br>+++ b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
<br>@@ -0,0 +1,16 @@
<br>+<pool type='rbd'>
<br>+  <name>ceph</name>
<br>+  <uuid>47c1faee-0207-e741-f5ae-d9b019b98fe2</uuid>
<br>+  <capacity unit='bytes'>0</capacity>
<br>+  <allocation unit='bytes'>0</allocation>
<br>+  <available unit='bytes'>0</available>
<br>+  <source>
<br>+    <host name='localhost' port='6789'/>
<br>+    <host name='localhost' port='6790'/>
<br>+    <host name='2205::192:168:205:141' port='6789'/>
<br>+    <name>rbd</name>
<br>+    <auth type='ceph' username='admin'>
<br>+      <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
<br>+    </auth>
<br>+  </source>
<br>+</pool>
<br>diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
<br>index 2ae514f..b6f4cb4 100644
<br>--- a/tests/storagepoolxml2xmltest.c
<br>+++ b/tests/storagepoolxml2xmltest.c
<br>@@ -95,6 +95,7 @@ mymain(void)
<br>     DO_TEST("pool-zfs-sourcedev");
<br>     DO_TEST("pool-rbd");
<br> #ifdef WITH_STORAGE_RBD
<br>+    DO_TEST("pool-rbd-ipv6");
<br>     DO_TEST("pool-rbd-refresh-volume-allocation");
<br>     DO_TEST("pool-rbd-ns-configopts");
<br> #endif
<br>-- 
<br>2.7.5
<br>
<br></span></div>
<div><br></div><br><div><span><p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: ËÎÌå; text-align: justify; line-height: 19px;"><span lang="EN-US" style="font-family: Î¢ÈíÑźÚ, sans-serif;"> </span></p>
<!--EndFragment--><div>
<!--EndFragment--></div></span></div>
</body></html>