[pve-devel] [PATCH 06/16] rbd : clone_image
Alexandre Derumier
aderumier at odiso.com
Sun Feb 3 09:49:33 CET 2013
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage/RBDPlugin.pm | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 540a2d5..acfd27f 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -252,7 +252,23 @@ sub create_base {
sub clone_image {
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
- die "not implemented";
+ my $snap = '__base__';
+
+ my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
+ $class->parse_volname($volname);
+
+ die "clone_image onyl works on base images\n" if !$isBase;
+
+ my $name = &$find_free_diskname($storeid, $scfg, $vmid);
+
+ warn "clone $volname: $basename to $name\n";
+
+ my $newvol = "$basename/$name";
+
+ my $cmd = &$rbd_cmd($scfg, $storeid, 'clone', $basename, '--snap', $snap, $name);
+ run_command($cmd, errmsg => "rbd clone $basename' error", errfunc => sub {});
+
+ return $newvol;
}
my $find_free_diskname = sub {
--
1.7.10.4
More information about the pve-devel
mailing list