[pve-devel] [PATCH 14/20] plugin : add volume_clone
Alexandre Derumier
aderumier at odiso.com
Mon Dec 3 14:32:39 CET 2012
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage/Plugin.pm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 406fa1a..5328f20 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -568,6 +568,23 @@ sub volume_snapshot_delete {
return undef;
}
+sub volume_clone {
+ my ($class, $scfg, $storeid, $volname, $snap, $vmid) = @_;
+
+ my $name = $class->find_free_volname($storeid, $scfg, $vmid, "qcow2");
+
+ my $pathsrc = $class->path($scfg, $volname);
+
+ my $imagedir = $class->get_subdir($scfg, 'images');
+ $imagedir .= "/$vmid";
+ my $pathdst = "$imagedir/$name";
+
+ my $cmd = ['/usr/bin/qemu-img', 'create','-b', $pathsrc, '-f', 'qcow2', $pathdst];
+ run_command($cmd);
+
+ return "$vmid/$name";
+}
+
sub volume_protect {
my ($class, $scfg, $storeid, $volname, $snap) = @_;
--
1.7.10.4
More information about the pve-devel
mailing list