[pve-devel] [PATCH 14/20] plugin : add volume_clone

Alexandre Derumier aderumier at odiso.com
Wed Dec 12 13:54:57 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 1427fa1..7521e3f 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, $read_only) = @_;
 
-- 
1.7.10.4




More information about the pve-devel mailing list