[vbox-dev] Virtual Box API to shutdown machine / apply snapshot
klaus.espenlaub at oracle.com
Wed Apr 25 04:42:55 PDT 2012
On 20.04.2012 18:12, Benedict, Elad wrote:
> This is my first interaction with this API so I guess I'm just using it wrong;
> My machine can be in the saved\paused\abort\running state.
> I'd like to write the simplest code that gets my machine from whatever state it is in to a running state after having restored a given snapshot.
The simplest code for this is probably at least 20-30 lines...
See below for more hints.
> Can you please advise?
> Thanks again,
> -----Original Message-----
> From: Klaus Espenlaub [mailto:klaus.espenlaub at oracle.com]
> Sent: Friday, April 20, 2012 6:42 PM
> To: vbox-dev at virtualbox.org
> Subject: Re: [vbox-dev] Virtual Box API to shutdown machine / apply snapshot
> Hi Elad,
> On 20.04.2012 17:31, Benedict, Elad wrote:
>> Hi all,
>> I'm trying to use the COM API to apply some snapshot.
>> Since I don't know (or more accurately, care, about) the initial state
>> of the machine I thought I'd:
>> 1. Power the machine off
>> 2. Apply the snapshot I want
>> The thing is I can't get the machine to PoweredOff state using the
>> PowerDown method since it's not legal when the machine is in certain states.
The machine states all fall into one of three categories
* VM is online (needs poweroff before you can restore some snapshot)
* VM is offline (you can restore some snapshot immediately)
* VM is in transient state (needs waiting until it is either online or
>> Is there some easy way to perform what I want?
>> (Either easily apply the snapshot, regardless of the machines current
>> state, or get it to powered off state)
You need to write code which decides what to do, based on the machine
state. Essentially you need to get the VM into offline state first, and
then you can restore the snapshot.
The GUI can serve as an example, as it allows restoring the previous
snapshot in the "Close" dialog. Our code uses the API, too, and is thus
a very big sample.
> Which "certain states" are you talking about? So far we got away with
> the API methods...
There are machine states, and those indicate what you need to do...
>> Thanks a lot,
More information about the vbox-dev