mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-16 20:33:20 +00:00
Introduce __snapshot_create_vol_snapshots_hook
This hook runs before and after creating volume snapshots, as well as after unfreezing. Only needed for Qemu right now, so the base case in PVE::AbstractConfig is a noop.
This commit is contained in:
parent
bf536088d7
commit
ba9db5df17
@ -221,6 +221,14 @@ sub __snapshot_freeze {
|
|||||||
die "abstract method - implement me\n";
|
die "abstract method - implement me\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Code run before and after creating all the volume snapshots
|
||||||
|
# base: noop
|
||||||
|
sub __snapshot_create_vol_snapshots_hook {
|
||||||
|
my ($class, $vmid, $snap, $running, $hook) = @_;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# Create the volume snapshots for the VM/CT.
|
# Create the volume snapshots for the VM/CT.
|
||||||
sub __snapshot_create_vol_snapshot {
|
sub __snapshot_create_vol_snapshot {
|
||||||
my ($class, $vmid, $vs, $volume, $snapname) = @_;
|
my ($class, $vmid, $vs, $volume, $snapname) = @_;
|
||||||
@ -413,6 +421,8 @@ sub snapshot_create {
|
|||||||
$class->__snapshot_freeze($vmid, 0);
|
$class->__snapshot_freeze($vmid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "before");
|
||||||
|
|
||||||
$class->__snapshot_foreach_volume($snap, sub {
|
$class->__snapshot_foreach_volume($snap, sub {
|
||||||
my ($vs, $volume) = @_;
|
my ($vs, $volume) = @_;
|
||||||
|
|
||||||
@ -423,9 +433,11 @@ sub snapshot_create {
|
|||||||
my $err = $@;
|
my $err = $@;
|
||||||
|
|
||||||
if ($running) {
|
if ($running) {
|
||||||
|
$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "after");
|
||||||
if ($freezefs) {
|
if ($freezefs) {
|
||||||
$class->__snapshot_freeze($vmid, 1);
|
$class->__snapshot_freeze($vmid, 1);
|
||||||
}
|
}
|
||||||
|
$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "after-unfreeze");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user