[libvirt] [PATCH] storage: escape ipv6 for ceph mon hosts to librados
Ján Tomko
jtomko at redhat.com
Tue Jun 18 15:15:53 UTC 2019
Oops, I forgot about this patch.
On Sun, Apr 28, 2019 at 01:25:05PM +0800, Yi Li wrote:
>>From 4af765cb6ee87eb7a131901057a8b6d0e859ac63 Mon Sep 17 00:00:00 2001
>From: Yi Li <yili at winhong.com>
>Date: Sun, 28 Apr 2019 10:29:53 +0800
>Subject: [PATCH v2] storage: escape ipv6 for ceph mon hosts to librados
>
>Hosts for rbd are ceph monitor daemons. These have fixed IP addresses,
>so they are often referenced by IP rather than hostname for
>convenience, or to avoid relying on DNS. Using IPv4 addresses as the
>host name works already, but IPv6 addresses require rbd-specific
>escaping because the colon is used as an option separator in the
>string passed to librados.
>
>Escape these colons, and enclose the IPv6 address in square brackets
>so it is distinguished from the port, which is currently mandatory.
>
>Signed-off-by: Yi Li <yili at winhong.com>
>---
> docs/schemas/storagepool.rng | 5 ++++-
> src/storage/storage_backend_rbd.c | 15 ++++++++++++---
> tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml | 13 +++++++++++++
> tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml | 16 ++++++++++++++++
> tests/storagepoolxml2xmltest.c | 1 +
> 5 files changed, 46 insertions(+), 4 deletions(-)
> create mode 100644 tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
> create mode 100644 tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
>
>diff --git a/src/storage/storage_backend_rbd.c
>b/src/storage/storage_backend_rbd.c
>index f8c968e..d6d7356 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,9 +269,17 @@
>virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
> source->hosts[i].name);
> } else if (source->hosts[i].name != NULL &&
> source->hosts[i].port) {
>- virBufferAsprintf(&mon_host, "%s:%d,",
>- source->hosts[i].name,
>- source->hosts[i].port);
>+ 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);
The indentation here is off.
> } else {
> virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> _("received malformed monitor, check the
>XML definition"));
Reviewed-by: Ján Tomko <jtomko at redhat.com>
and finally pushed.
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190618/0d96c37a/attachment-0001.sig>
More information about the libvir-list
mailing list