diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index ad8713fe..29cd4c44 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -895,6 +895,12 @@ __PACKAGE__->register_method({ type => 'integer', minimum => 0, optional => 1, + }, + keepActive => { + description => "Do not decativate storage volumes.", + type => 'boolean', + optional => 1, + default => 0, } }, }, @@ -916,6 +922,10 @@ __PACKAGE__->register_method({ raise_param_exc({ skiplock => "Only root may use this option." }) if $skiplock && $user ne 'root@pam'; + my $keepActive = extract_param($param, 'keepActive'); + raise_param_exc({ keepActive => "Only root may use this option." }) + if $keepActive && $user ne 'root@pam'; + my $storecfg = PVE::Storage::config(); my $realcmd = sub { @@ -923,7 +933,8 @@ __PACKAGE__->register_method({ syslog('info', "stop VM $vmid: $upid\n"); - PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0, $param->{timeout}); + PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0, + $param->{timeout}, 0, 1, $keepActive); return; }; @@ -1001,6 +1012,12 @@ __PACKAGE__->register_method({ type => 'boolean', optional => 1, default => 0, + }, + keepActive => { + description => "Do not decativate storage volumes.", + type => 'boolean', + optional => 1, + default => 0, } }, }, @@ -1022,6 +1039,10 @@ __PACKAGE__->register_method({ raise_param_exc({ skiplock => "Only root may use this option." }) if $skiplock && $user ne 'root@pam'; + my $keepActive = extract_param($param, 'keepActive'); + raise_param_exc({ keepActive => "Only root may use this option." }) + if $keepActive && $user ne 'root@pam'; + my $storecfg = PVE::Storage::config(); my $realcmd = sub { @@ -1029,8 +1050,8 @@ __PACKAGE__->register_method({ syslog('info', "shutdown VM $vmid: $upid\n"); - PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0, - $param->{timeout}, 1, $param->{forceStop}); + PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0, $param->{timeout}, + 1, $param->{forceStop}, $keepActive); return; }; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 5a280e6c..27030e4b 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2565,21 +2565,24 @@ sub get_vm_volumes { } sub vm_stop_cleanup { - my ($storecfg, $vmid, $conf) = @_; + my ($storecfg, $vmid, $conf, $keepActive) = @_; eval { fairsched_rmnod($vmid); # try to destroy group - my $vollist = get_vm_volumes($conf); - PVE::Storage::deactivate_volumes($storecfg, $vollist); + if (!$keepActive) { + my $vollist = get_vm_volumes($conf); + PVE::Storage::deactivate_volumes($storecfg, $vollist); + } }; warn $@ if $@; # avoid errors - just warn } # Note: use $nockeck to skip tests if VM configuration file exists. -# We need that when migration VMs to other nodes (files already moved) +# We need that when migration VMs to other nodes (files already moved) +# Note: we set $keepActive in vzdump stop mode - volumes need to stay active sub vm_stop { - my ($storecfg, $vmid, $skiplock, $nocheck, $timeout, $shutdown, $force) = @_; + my ($storecfg, $vmid, $skiplock, $nocheck, $timeout, $shutdown, $force, $keepActive) = @_; $timeout = 60 if !defined($timeout); @@ -2620,7 +2623,7 @@ sub vm_stop { die "VM quit/powerdown failed - got timeout\n"; } } else { - vm_stop_cleanup($storecfg, $vmid, $conf) if $conf; + vm_stop_cleanup($storecfg, $vmid, $conf, $keepActive) if $conf; return; } } else { @@ -2647,7 +2650,7 @@ sub vm_stop { sleep 1; } - vm_stop_cleanup($storecfg, $vmid, $conf) if $conf; + vm_stop_cleanup($storecfg, $vmid, $conf, $keepActive) if $conf; }); } diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm index 8066566b..14778f43 100644 --- a/PVE/VZDump/QemuServer.pm +++ b/PVE/VZDump/QemuServer.pm @@ -193,7 +193,7 @@ sub stop_vm { my $wait = $opts->{stopwait} * 60; # send shutdown and wait - $self->cmd ("qm shutdown $vmid --skiplock --timeout $wait"); + $self->cmd ("qm shutdown $vmid --skiplock --keepActive --timeout $wait"); } sub start_vm { diff --git a/changelog.Debian b/changelog.Debian index 4de5b22d..5d3e3937 100644 --- a/changelog.Debian +++ b/changelog.Debian @@ -1,6 +1,8 @@ qemu-server (2.0-15) unstable; urgency=low * online migration fix: close tunnel later, wait for connection close + + * fix bug #81: do no deactivate volumes in vzdump stop mode -- Proxmox Support Team Tue, 17 Jan 2012 11:24:56 +0100