[pve-devel] [PATCH] rbdplugin : add support for krbd

Alexandre Derumier aderumier at odiso.com
Wed Nov 12 14:30:25 CET 2014


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

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 1026d81..eee661f 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -226,6 +226,10 @@ sub properties {
 	    description => "Authsupported.",
 	    type => 'string',
 	},
+	krbd => {
+	    description => "Access rbd through krbd kernel module.",
+	    type => 'boolean',
+	},
     };
 }
 
@@ -237,6 +241,7 @@ sub options {
 	pool => { optional => 1 },
 	username => { optional => 1 },
 	content => { optional => 1 },
+	krbd => { optional => 1 },
     };
 }
 
@@ -271,6 +276,8 @@ sub path {
 	$path .= ":auth_supported=none";
     }
 
+    $path = "/dev/rbd/$pool/$name" if $scfg->{krbd};
+
     return ($path, $vmid, $vtype);
 }
 
@@ -486,11 +493,29 @@ sub deactivate_storage {
 
 sub activate_volume {
     my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+
+    return 1 if !$scfg->{krbd};
+
+    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+
+    my $cmd = &$rbd_cmd($scfg, $storeid, 'map', $name);
+    run_rbd_command($cmd, errmsg => "can't mount rbd volume $name");
+
     return 1;
 }
 
 sub deactivate_volume {
     my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+
+    return 1 if !$scfg->{krbd};
+
+    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
+
+    my $path = "/dev/rbd/$pool/$name";
+    my $cmd = &$rbd_cmd($scfg, $storeid, 'unmap', $path);
+    run_rbd_command($cmd, errmsg => "can't unmount rbd volume $name");
+
     return 1;
 }
 
-- 
1.7.10.4




More information about the pve-devel mailing list