vm rollback in hookscript

bingsin

Member
Dec 9, 2021
29
2
8
29
Hello,
I want to auto rollback when vm is stop. the same as PXE.
use hookscript:

Perl:
my $cmd ="qm rollback $vmid snapshot";
......
.......
elsif($phase eq 'post-stop') {
  print "$vmid stopped. Doing cleanup.\n";
  system($cmd);

Both tasks will lock the vm at the same time,and post error
Bash:
GUEST HOOK: 801 pre-stop
801 will be stopped.
trying to acquire lock...
can't lock file '/var/lock/qemu-server/lock-801.conf' - got timeout
 
i did it!
use qemu-img
Code:
my $cmd ="qemu-img snapshot -a snapshot /mnt/pve/Nvme/images/$vmid/vm-$vmid-disk-0.qcow2";
...
...
elsif($phase eq 'post-stop') {
  print "$vmid stopped. Doing cleanup.\n";
  system("$cmd");
 
system("unlink /var/lock/qemu-server/lock-$vmid.conf");
Hello,
I want to auto rollback when vm is stop. the same as PXE.
use hookscript:

Perl:
my $cmd ="qm rollback $vmid snapshot";
......
.......
elsif($phase eq 'post-stop') {
  print "$vmid stopped. Doing cleanup.\n";
  system($cmd);

Both tasks will lock the vm at the same time,and post error
Bash:
GUEST HOOK: 801 pre-stop
801 will be stopped.
trying to acquire lock...
can't lock file '/var/lock/qemu-server/lock-801.conf' - got timeout
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!