Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 04, 2016, 08:17:53 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Automated Snapshots with VirtualBox  (Read 6266 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Automated Snapshots with VirtualBox
« on: June 04, 2011, 01:59:25 AM »
Those hard to reproduce bugs...sometimes we reproduce them, but then subsequently don't seem to be able to...

Perhaps we'd have a better chance if we could start from a snapshot of a virtual machine which was taken shortly before a successful reproduction -- may be also having frequent screenshots of the system.

So with disk space being on the cheaper side these days, may be automatically taking snapshots of one's system every X minutes would be practical (can delete stuff that older than some time for keeping the amount of used space manageable).

May be this wouldn't work so well for certain situations -- e.g. some involving a network.  But FWIW, it looks somewhat doable using VirtualBox's vboxmanage (host) and vboxcontrol (guest via guest additions) command line tools.

One way to do this would be to leverage the guestproperty (get, set, wait) and snapshot subcommands.

Has anyone seen anything that does this sort of thing already?

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,778
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #1 on: June 04, 2011, 08:03:13 AM »
You'd probably have a look at VBoxManage: http://www.virtualbo...org/manual/ch08.html

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #2 on: June 04, 2011, 08:07:57 AM »
Err...

May be this wouldn't work so well for certain situations -- e.g. some involving a network.  But FWIW, it looks somewhat doable using VirtualBox's vboxmanage (host) and vboxcontrol (guest via guest additions) command line tools.

Sorry I didn't get the capitalization correct...

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,778
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #3 on: June 04, 2011, 08:13:44 AM »
Sorry I didn't get the capitalization correct...
Sorry I didn't get the content of your post in my head correctly (must have been reading backward :-[)

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,778
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #4 on: June 04, 2011, 08:26:14 AM »
Would this help in some way? http://tirania.org/b...ive/2007/Aug-28.html

Haven't seen any tooling that handles that, so far.
I'd go for a scheduler and a few scripts, just a few lines either in Windows or Linux scripting, and both have a decent scheduler.
Creating snapshots to often could put such a drain on the disksystem, that it influences the performance or behavior of the virtual system, so some experimenting would be needed.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #5 on: June 04, 2011, 12:21:17 PM »
Thanks for the link -- I'd just come across:

  http://www.virtualbox.org/manual/ch11.html

where I saw COM, XPCOM, and other things of potential interest mentioned.  This triggered some poking around the VirtualBox site's documentation section, where I noticed the SDK Programming Guide, but haven't really looked at it in any detail yet.

I'm not sure how nasty taking a snapshot becomes, so some real-world experience via a prototype using easy-to-develop scripts and some scheduling code as you suggested is a path that seems reasonable.  FWIW, it looks like the tool on the guest end, vboxcontrol, is headed in the direction of being able to initiate a snapshot.  In my locally installed version, I get some message about not implemented yet, so ATM it's looking like a host+guest idea.

On a related note, I started to use Workrave recently and got to thinking that if I was going to be taking breaks so frequently, may be snapshotting could happen during some of those times :)

This idea seems pretty obvious in retrospect though, so I'm wondering if someone hasn't already done something similar.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,778
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #6 on: June 05, 2011, 06:45:01 AM »
The scripts should be fairly easy, I guess, haven't any VM's available in VBox to test ATM, but if needed I could create one (on Windows).

I've been using Workrave for some time a couple of years back (I stopped using any of those softwares, to annoying), but can't recall if it does support running some kind of user actions on a break/pause. You could ask on the Bugzilla e-mail group if you can't find this feature, they seem rather responsive.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #7 on: June 05, 2011, 09:33:50 PM »
Thanks for the ideas and suggestions :)

Am trying to digest the SDK Programming Guide ATM.  It looks pretty clear so far that using Python would make certain things easier than using some other alternatives.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Automated Snapshots with VirtualBox
« Reply #8 on: June 06, 2011, 12:10:56 AM »
To give a taste of what it might be like to use Python to work with VirtualBox, below is a modified example from the SDK docs to start a virtual machine.  The code runs on a host and starts up an already configured guest.  It seemed to work ok with a locally installed VirtualBox 4.0.8.

Code: Python [Select]
  1. from vboxapi import VirtualBoxManager
  2. virtualBoxManager = VirtualBoxManager(None, None)
  3.  
  4. vbox = virtualBoxManager.vbox
  5. mgr = virtualBoxManager.mgr
  6. print "Version is", vbox.version
  7.  
  8. def machById(id):
  9.     mach = None
  10.     for m in virtualBoxManager.getArray(vbox, 'machines'):
  11.         if m.name == id or mach.id == id:
  12.             mach = m
  13.             break
  14.     return mach
  15.  
  16. name = "Windows XP SP3"
  17. mach = machById(name)
  18.  
  19. if mach is None:
  20.     print "cannot find machine", name
  21. else:
  22.     session = mgr.getSessionObject(vbox)
  23.     progress = mach.launchVMProcess(session, "gui", mach.id)
  24.     progress.waitForCompletion(-1)
  25.     session.close()