From 9dbf9b541755575694b2b685b2584dce7258afcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 1 Jul 2016 14:18:31 +0200 Subject: [PATCH] fix #1040: warn early about moving a snapshotted disk 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 c0a72c03..b64619cc 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);