mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-29 20:58:54 +00:00
fix bug #81: do no deactivate volumes in vzdump stop mode
We add a keepActive parameter to stop/shutdown API.
This commit is contained in:
parent
97439670bc
commit
254575e971
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 <support@proxmox.com> Tue, 17 Jan 2012 11:24:56 +0100
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user