public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 pve-guest-common/pve-docs] Add pre/post/failed-snapshot hooks
@ 2022-12-12 13:43 Stefan Hanreich
  2022-12-12 13:43 ` [pve-devel] [PATCH pve-docs 1/1] examples: add pre/post/failed-snapshot hooks to example hookscript Stefan Hanreich
  2022-12-12 13:43 ` [pve-devel] [PATCH pve-guest-common 1/1] partially fix #2530: snapshots: add pre/post/failed-snapshot hooks Stefan Hanreich
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Hanreich @ 2022-12-12 13:43 UTC (permalink / raw)
  To: pve-devel

This patch series introduces the pre/post/failed-snapshot hooks that run before/
after a snapshot is taken, or after failing to take a snapshot.

I used the new example script from pve-docs as template for my test hookscripts.

What I tested:
- Normal snapshotting, without VM state, without hookscript
  - snapshot works, no hooks executed
- Normal snapshotting, with VM state, without hookscript
  - snapshot works, no hooks executed
- Normal snapshotting, without VM state, with hookscript
  - snapshot works, pre/post hooks work
- Normal snapshotting, with VM state, with hookscript
  - snapshot works, pre/post hooks work
- Taking snapshot with existing name, with hookscript
  - fails, no hookscripts get executed
- Failed at wrong storage config, with hookscript
  - pre/failed get executed, lock gets released
- Failed at taking RAM Snapshot (simulated with monkey-patched die), with hookscript
  - pre/failed get executed, lock gets released
- Add hookscript that attaches/detaches unsnapshottable disk (without --skiplock)
  - snapshotting fails, attach/detach fails, pre/failed get executed, lock released
- Add hookscript that attaches/detaches unsnapshottable disk (with --skiplock)
  - snapshotting works, attach/detach works, pre/post get executed
  - restoring works, detached disk is detached after restoring
- pre-snapshot hookscript exits with code > 0
  - only pre-snapshot gets executed and fails, snapshot fails, lock gets released
- Taking snapshot of template
  - fails, no hookscripts get executed
- execute commands in VM in pre/post via qm guest exec during snapshotting
  - snapshot succeeds, commands get executed, pre/post executed

Changes from v1:
- added failed-snapshot hook that runs after a failed snapshot
  - this enables users to revert any changes made in pre-snapshot hooks
  in case of errors
- running cfs_update() after every hookscript invocation
- adjusted the call sites of exec_hookscript()
  - particularly interesting for pre-snapshot since some checks now run
  before the hook runs
- VM/CT config is now locked during hookscript execution

Thanks to Fiona and Fabian for their valuable input/help!


pve-guest-common:

Stefan Hanreich (1):
  partially fix #2530: snapshots: add pre/post/failed-snapshot hooks

 src/PVE/AbstractConfig.pm | 49 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 6 deletions(-)


pve-docs:

Stefan Hanreich (1):
  examples: add pre/post/failed-snapshot hooks to example hookscript

 examples/guest-example-hookscript.pl | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

-- 
2.30.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-21 12:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 13:43 [pve-devel] [PATCH v2 pve-guest-common/pve-docs] Add pre/post/failed-snapshot hooks Stefan Hanreich
2022-12-12 13:43 ` [pve-devel] [PATCH pve-docs 1/1] examples: add pre/post/failed-snapshot hooks to example hookscript Stefan Hanreich
2022-12-12 13:43 ` [pve-devel] [PATCH pve-guest-common 1/1] partially fix #2530: snapshots: add pre/post/failed-snapshot hooks Stefan Hanreich
2022-12-21 10:44   ` Fabian Grünbichler
2022-12-21 11:26     ` Stefan Hanreich
2022-12-21 12:41       ` Fabian Grünbichler
2022-12-21 12:57         ` Stefan Hanreich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal