[pve-devel] [PATCH container 1/3] Set backup lock during stop and suspend backups
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Jan 15 10:03:31 CET 2016
Correctly set a 'backup' lock while a 'stop' or 'suspend'
mode backup is in progress.
---
src/PVE/VZDump/LXC.pm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index 7f27f0b..7cd557c 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -94,6 +94,24 @@ my $check_mountpoint_empty = sub {
});
};
+my $lockconfig = sub {
+ my ($self, $vmid) = @_;
+ my $conf = PVE::LXC::load_config($vmid);
+ PVE::LXC::check_lock($conf);
+ $conf->{lock} = 'backup';
+ PVE::LXC::write_config($vmid, $conf);
+};
+
+my $unlockconfig = sub {
+ my ($self, $vmid) = @_;
+ my $conf = PVE::LXC::load_config($vmid);
+
+ if ($conf->{lock} && $conf->{lock} eq 'backup') {
+ delete $conf->{lock};
+ PVE::LXC::write_config($vmid, $conf);
+ }
+};
+
sub prepare {
my ($self, $task, $vmid, $mode) = @_;
@@ -144,11 +163,13 @@ sub prepare {
# set snapshot_count (freezes CT it snapshot_count > 1)
$task->{snapshot_count} = scalar(@$volid_list);
} elsif ($mode eq 'stop') {
+ PVE::LXC::lock_container($vmid, 10, $lockconfig, $self, $vmid);
my $rootdir = $default_mount_point;
mkpath $rootdir;
&$check_mountpoint_empty($rootdir);
PVE::Storage::activate_volumes($storage_cfg, $volid_list);
} elsif ($mode eq 'suspend') {
+ PVE::LXC::lock_container($vmid, 10, $lockconfig, $self, $vmid);
my $pid = PVE::LXC::find_lxc_pid($vmid);
foreach my $disk (@$disks) {
$disk->{dir} = "/proc/$pid/root$disk->{mp}";
@@ -175,6 +196,7 @@ sub lock_vm {
sub unlock_vm {
my ($self, $vmid) = @_;
+ PVE::LXC::lock_container($vmid, 10, $unlockconfig, $self, $vmid);
PVE::LXC::lock_release($vmid);
}
@@ -262,6 +284,7 @@ sub assemble {
mkpath "$tmpdir/etc/vzdump/";
my $conf = PVE::LXC::load_config($vmid);
+ delete $conf->{lock};
delete $conf->{snapshots};
delete $conf->{'pve.parent'};
--
2.1.4
More information about the pve-devel
mailing list