problem to check if the rollback is complete.


New Member
Apr 20, 2023
I'm creating a program that lets me run unit tests on a Python application. The principle is that each test must be independent of the other. That's why I do a rollback of the vm at the desired moment at the end of each test. To rollback the vm, I use the Proxmox api and in particular the following command: api.nodes(name_of_node).qemu(id_of_the_vm).snapshot(name_of_the_snapshot).rollback().post().
Here's my problem:
At the start of each test, I create a test set-up to ensure that my test is applied in a particular context. So I can use libraries like Paramiko to instantiate an ssh connection and perform commands.
At the start of some tests, I notice that they fail because 'connection.timeout' or something like that. I've checked that my ssh connection function is good. I use it in other projects. I suppose it's because the rollback hasn't had time to take place that it's blocking the process. So I use time.sleep(x) everywhere to wait for the rollback to finish, but sometimes it doesn't work, and at the very least it slows down the program enormously for nothing.
Knowing that the vm is in 'running' status at rollback, it's not possible to play on this criteria. I don't know how to check that my vm's rollback is complete.

Thanks for your feedback
Is this a rollback including memory contents?

Can't you do some kind of zfs snapshots inside of you test vm to have a faster rollback method? Or you Docker containers to properly test your software? I also played in the past with automating VM rollbacks, but with Docker up and running everywhere, testing is so much easier.
Yes the rollback includes memory contents, but very little. the goal is to start from a point where there's virtually no setup on the vm.
on the other hand, I can't work on docker because I don't have the skills.
But the real question, other than optimizing rollback time, is whether it's possible to retrieve the vm status during a rollback and know that it's 'ok' so that I can move on to the next test.
the rollback API call returns the task ID, you can then pass that to the task API to see if the rollback is finished before proceeding.
In addition, you can also ping (icmp or an application ping) to your VMs services and continue if the application answers. This is done often in Docker stacks, where you can also not control if something is already responsing.

I can't work on docker because I don't have the skills.
Invest in this, it is a major game changer for anything CI related.
it works @fabian.
@LnxBil yes i did it with the ping but sometimes there are still some problems. But yeah, i know i have to begin with docker, i'm already interested for little personal project but I'm not comfortable enough to use it for development in the context in which I find myself.

Thank you both for your help.


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!