From 3536c79204aa16d87846d262520882526b9d3f54 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 21 Dec 2010 14:18:39 +0100
Subject: [PATCH] Allow customisation of the disk index separator

As per issue 124, some Xen versions (or packaging) don't deal nicely
with the colon being part of a disk name. Therefore we add a
configure-time option for customising this.

Note: setting the separator to interesting values like / is not
handled by the code. This being a configure-time option (e.g. to be
set by distribution packagers), we assume the person building the code
knows what they are doing.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 Makefile.am      | 1 +
 configure.ac     | 9 +++++++++
 lib/backend.py   | 4 ++--
 lib/constants.py | 2 ++
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0be0edbbc..283c10412 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -661,6 +661,7 @@ lib/_autoconf.py: Makefile vcs-version | lib/.dir
 	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
 	  echo "NODED_USER = '$(NODED_USER)'"; \
 	  echo "VCS_VERSION = '$$VCSVER'"; \
+	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
 	} > $@
 
 $(REPLACE_VARS_SED): Makefile
diff --git a/configure.ac b/configure.ac
index 33d55f71b..aab7d6546 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,6 +223,15 @@ then
 fi
 AC_SUBST(SYSLOG_USAGE, $SYSLOG)
 
+# --with-disk-separator=...
+AC_ARG_WITH([disk-separator],
+  [AS_HELP_STRING([--with-disk-separator=STRING],
+    [Disk index separator, useful if the default of ':' is handled specially by the hypervisor]
+  )],
+  [disk_separator="$withval"],
+  [disk_separator=":"])
+AC_SUBST(DISK_SEPARATOR, $disk_separator)
+
 # Check common programs
 AC_PROG_INSTALL
 AC_PROG_LN_S
diff --git a/lib/backend.py b/lib/backend.py
index 57c2ce403..45b4b4607 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -941,8 +941,8 @@ def RunRenameInstance(instance, old_name, debug):
 
 
 def _GetBlockDevSymlinkPath(instance_name, idx):
-  return utils.PathJoin(constants.DISK_LINKS_DIR,
-                        "%s:%d" % (instance_name, idx))
+  return utils.PathJoin(constants.DISK_LINKS_DIR, "%s%s%d" %
+                        (instance_name, constants.DISK_SEPARATOR, idx))
 
 
 def _SymlinkBlockDev(instance_name, device_path, idx):
diff --git a/lib/constants.py b/lib/constants.py
index b9aea1685..871aa5045 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -488,6 +488,8 @@ DEFAULT_SHUTDOWN_TIMEOUT = 120
 NODE_MAX_CLOCK_SKEW = 150
 # Time for an intra-cluster disk transfer to wait for a connection
 DISK_TRANSFER_CONNECT_TIMEOUT = 30
+# Disk index separator
+DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
 
 # runparts results
 (RUNPARTS_SKIP,
-- 
GitLab