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

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Jul 1 15:12:27 CEST 2016


One minor remark: I find error messages should get to the point early
and think a simple "can't delete [source] disks with snapshots" would be
sufficient. Personally I parse messages by looking for keywords first
making "you can't move a disk with snapshots" a confusing first half of
a sentence.

On Fri, Jul 01, 2016 at 02:18:31PM +0200, Fabian Grünbichler wrote:
> die if "delete source disk" is enabled, because a disk that
> is referenced by snapshots must not be deleted.

Acked-by: Wolfgang Bumiller <w.bumiller at proxmox.com>

> ---
>  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