[pve-devel] [PATCH 15/48] plugin : add volume_clone

Alexandre Derumier aderumier at odiso.com
Tue Jan 29 17:13:57 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 ef6b0fd..6ec02de 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -587,6 +587,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 "$volname/$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