[pve-devel] [PATCH] rbd: monhost string : escape only ":" character

Alexandre Derumier aderumier at odiso.com
Thu Mar 5 10:29:29 CET 2015


we need to escape ":" used to defined mon ports

"10.5.0.11:6789; 10.5.0.12:6789; 10.5.0.13:6789"

->

"10.5.0.11\:6789; 10.5.0.12\:6789; 10.5.0.13\:6789"

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage/RBDPlugin.pm |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 2c1f615..2c45a68 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -177,13 +177,6 @@ sub rbd_volume_info {
     return ($size, $parent, $format, $protected);
 }
 
-sub addslashes {
-    my $text = shift;
-    $text =~ s/;/\\;/g;
-    $text =~ s/:/\\:/g;
-    return $text;
-}
-
 # Configuration
 
 PVE::JSONSchema::register_format('pve-storage-monhost', \&parse_monhost);
@@ -258,7 +251,9 @@ sub path {
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     $name .= '@'.$snapname if $snapname;
 
-    my $monhost = addslashes($scfg->{monhost});
+    my $monhost = $scfg->{monhost};
+    $monhost =~ s/:/\\:/g;
+
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
     my $username =  $scfg->{username} ? $scfg->{username} : 'admin';
 
-- 
1.7.10.4




More information about the pve-devel mailing list