[pve-devel] [PATCH] fix : signal interrupt don't delete volume on full copy

Alexandre Derumier aderumier at odiso.com
Thu May 2 06:43:37 CEST 2013


Currently we  push newvolid to newvollist after qemu-img convert,
so if signal interrupt occur during qemu-img convert, the newvollist is empty and we can't free the volume

Instead, We need to push newvolid to newvollist just after volume creation

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

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index dedb9ad..a933bdd 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1994,6 +1994,8 @@ __PACKAGE__->register_method({
 			    if (!$param->{full} && PVE::Storage::volume_is_base($storecfg,  $drive->{file})) {
 				print "clone drive $opt ($drive->{file})\n";
 				$newvolid = PVE::Storage::vdisk_clone($storecfg,  $drive->{file}, $newid);
+				push @$newvollist, $newvolid;
+
 			    } else {
 				my ($storeid, $volname) = PVE::Storage::parse_volume_id($drive->{file});
 				$storeid = $storage if $storage;
@@ -2010,6 +2012,7 @@ __PACKAGE__->register_method({
 
 				print "copy drive $opt ($drive->{file})\n";
 				$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);
 			    }
@@ -2017,7 +2020,6 @@ __PACKAGE__->register_method({
 			    my ($size) = PVE::Storage::volume_size_info($storecfg, $newvolid, 3);
 			    my $disk = { file => $newvolid, size => $size };
 			    $newconf->{$opt} = PVE::QemuServer::print_drive($vmid, $disk);
-			    push @$newvollist, $newvolid;
 
 			    PVE::QemuServer::update_config_nolock($newid, $newconf, 1);
 			}
-- 
1.7.10.4




More information about the pve-devel mailing list