Issue take and restore snapshot commands from guest

Discussions related to using the OSE version of VirtualBox.

Issue take and restore snapshot commands from guest

Postby sorindev » 26. Jun 2015, 15:23


I'm working on a project where I need to issue two commands from the guest. The first one is to take a snapshot of the system and the other one is to revert the guest to the last snapshot.

I have added a new HGCM service and added functionality in the additions code so that I send it commands through the VBoxControl utility. The take snapshot functionality is working, but i'm having issues with the restoring of the snapshot.

When I get the restore command in my HGCM service, I start a new process that does the following:
- issue a power off for my machine
- get the last snapshot
- restore the snapshot
- start the vm

Things work fine and the machine is in the state that was right when i issued the take snapshot request. The problem is that the process that issued that command (VBoxControl.exe) is blocked, waiting for the service to unblock it, after it performed the ioctl operation.

When taking the snapshot, the process is unblocked when the service calls the pfnCallComplete callback on the message that the guest used to request the snapshot. But when the machine is restored to the snapshot, that message is lost, as the process hosting the service got killed and the message queue is stateless. One solution would be to implement the pfnSaveState and pfnLoadState callbacks for my service and try to save this message. The problem is that the message itself is too complex. It has fields which are not visible in my service and also has pointers to other dynamic structures (e.g. from the VMXDevHGCM driver).

I noticed that the VMMDevHGCM driver is saving its list of active commands. Is there any way to use this commands to unblock the guest process directly?

Thank you in advance,
Posts: 2
Joined: 26. Jun 2015, 09:58

Re: Issue take and restore snapshot commands from guest

Postby noteirak » 26. Jun 2015, 15:49

Moved to "VirtualBox OSE".
This will need an answer from the developpers directly. You can also ask on the dev mailing list and point to here.
Hyperbox - Virtual Infrastructure Manager -
Manage your VirtualBox infrastructure the free way!
Site Moderator
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: Issue take and restore snapshot commands from guest

Postby sorindev » 29. Jun 2015, 14:26


The VMMDevHGCM driver was correctly loading the pending command list and executing them. So, when restoring the machine, the handle for the take snapshot command got called and my code just tried to do the snapshot as it would normally do. But this failed as the machine was in the restoring state. So now I am just handling this case and return directly when the state of the machine is restoring and everything works fine.

Posts: 2
Joined: 26. Jun 2015, 09:58

Return to VirtualBox OSE

Who is online

Users browsing this forum: No registered users and 1 guest