I have developed an alpha patch to do checkpointing and reverting in bochs.
This patch implements what I call "Poor Man's Checkpoint." It allows the user to checkpoint a running bochs simulation and revert to the checkpointed state. First you press the Checkpoint button to save the system state. Bochs will continue normally. Do some things to modify the state of your OS and then press the Revert button. The operating system will literally go back in time to when the checkpoint was made.
Use: I use this to allow me to do something dangerous with the guest and go back if something went terribly wrong. This way I don't have to reboot and don't screw up my disk if I haven't saved a copy of it.
How it works: Except for a special type of bochs disk, no hardware checkpointing is actually being done. Clicking the "Checkpoint" button simply forks the process and puts the parent to sleep. The disk begins to use a new redolog file. When you press the "Revert" button, the redolog file goes away, the child process dies, and the parent continues on its merry way. This all relies on the wonderful fact that a forked process shares all the file descriptors of its parent, and the gui is a bunch of file descriptors to bochs.
Setting up your system: This patch applies correctly against the current
(Dec 3, 2004) cvs snapshot of bochs. It will NOT correctly patch bochs-2.1.1.
#cd bochs
#patch -p1 < poor_mans_checkpoint-0.1
#./configure
#./make
Modify your .bochsrc file. Pick a FLAT file to use as your ATA device.
Change the mode from "flat" to "checkpoint". Use the journal parameter
the same way you would for a redolog setup.
Example:
ata0-master: type=disk, mode=checkpoint, path="/local/bochs/freedos-img/c.img", cylinders=306, heads=4, spt=17 journal="/local/bochs/journal.img"
Now run bochs. Three new buttons have appeared so long as all your disks have "checkpoint" as their mode.
Screenshots:
I started bochs after compiling with the patch and setting the mode to "checkpoint" in .bochsrc. Notice the three new buttons. The only one enabled is the checkpoint button.
I pressed the Checkpoint button. It disappeared and the other two showed up. The leftmost button (Revert) will be used to bring the system back to the checkpointed state. The rightmost button (Commit) has not been implemented, but will allow you to continue on with the changes made to the system.
I hit the enter key a few times so that you can see what happens when I revert.
I hit the revert button. The system has gone back to its previous state. You can now checkpoint again.
Problems:
Has only been used under Linux (RedHat 9 on a dual PIII and SuSE 9.1 on
an Athlon64)
The Commit button hasn't been implemented. In the future, this will kill the parent, continue on with the child, and commit the redolog to the flat disk.
The framebuffer isn't refreshing correctly.
Untested with anything but freedos on C: with no other drives present.
Needs cleanup.
Help me: This is useful to me both for developing volatile guest code and developing bochs itself. Please let me know if you find this useful or if there is something I could do to make it useful. I will fix and develop this patch if anyone out there cares about this kind of thing. Please give me feedback.