[pve-devel] [PATCH 14/31] plugin : add volume_clone
Alexandre Derumier
aderumier at odiso.com
Tue Jan 8 15:45:20 CET 2013
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 9bdcf0d..b35d624 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -586,6 +586,25 @@ sub volume_has_feature {
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