[pve-devel] [PATCH 2/2] vm_clone : add running vm drive mirror

Alexandre Derumier aderumier at odiso.com
Thu May 2 18:18:04 CEST 2013


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 8e24cb4..6388795 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1896,8 +1896,6 @@ __PACKAGE__->register_method({
 
 	my $running = PVE::QemuServer::check_running($vmid) || 0;
 
-	die "Clone running VM $vmid not implemented\n" if $running; # fixme: implement this
-
 	# exclusive lock if VM is running - else shared lock is enough;
 	my $shared_lock = $running ? 0 : 1;
 
@@ -2014,7 +2012,12 @@ __PACKAGE__->register_method({
 			    $newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newid, $fmt, undef, ($size/1024));
 			    push @$newvollist, $newvolid;
 
-			    PVE::QemuServer::qemu_img_convert($drive->{file}, $newvolid, $size, $snapname);
+			    if(!$running || $snapname){
+				PVE::QemuServer::qemu_img_convert($drive->{file}, $newvolid, $size, $snapname);
+			    }else{
+				PVE::QemuServer::qemu_drive_mirror($vmid, $opt, $newvolid, $newid);
+			    }
+
 			}
 
 			my ($size) = PVE::Storage::volume_size_info($storecfg, $newvolid, 3);
-- 
1.7.10.4




More information about the pve-devel mailing list