[pve-devel] [PATCH qemu-server 1/2] fix #1040: warn early about moving a snapshotted disk

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jul 1 14:18:31 CEST 2016


die if "delete source disk" is enabled, because a disk that
is referenced by snapshots must not be deleted.
---
 PVE/API2/Qemu.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c0a72c0..6a1a459 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2525,6 +2525,11 @@ __PACKAGE__->register_method({
 	    die "you can't move on the same storage with same format\n" if $oldstoreid eq $storeid &&
                 (!$format || !$oldfmt || $oldfmt eq $format);
 
+	    # this only checks snapshots because $disk is passed!
+	    my $snapshotted = PVE::QemuServer::is_volume_in_use($storecfg, $conf, $disk, $old_volid);
+	    die "you can't move a disk with snapshots and delete the source\n"
+		if $snapshotted && $param->{delete};
+
 	    PVE::Cluster::log_msg('info', $authuser, "move disk VM $vmid: move --disk $disk --storage $storeid");
 
 	    my $running = PVE::QemuServer::check_running($vmid);
@@ -2538,6 +2543,9 @@ __PACKAGE__->register_method({
 		eval {
 		    local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = sub { die "interrupted by signal\n"; };
 
+		    warn "moving disk with snapshots, snapshots will not be moved!\n"
+			if $snapshotted;
+
 		    my $newdrive = PVE::QemuServer::clone_disk($storecfg, $vmid, $running, $disk, $drive, undef,
 							       $vmid, $storeid, $format, 1, $newvollist);
 
-- 
2.1.4





More information about the pve-devel mailing list