[pve-devel] [PATCH 14/20] plugin : add volume_clone
Alexandre Derumier
aderumier at odiso.com
Tue Dec 18 10:15:53 CET 2012
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage/Plugin.pm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index ed75d02..0c3909c 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -568,6 +568,25 @@ sub volume_snapshot_delete {
return undef;
}
+sub volume_clone {
+ my ($class, $scfg, $storeid, $volname, $snap, $vmid) = @_;
+
+ die "you can't create a linked clone from a qcow2 snapshot" if $snap;
+
+ 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, $read_only) = @_;
--
1.7.10.4
More information about the pve-devel
mailing list