BACKUP AND RESTORE
Posted: 5. Jan 2012, 16:56
Hi ,
I am using 4.1.8 VB and the SDK i want to clone a machine for backup.
IMachine *targetMachine;
IMachine *machine;
ISession *session = NULL;
IConsole *console = NULL;
IProgress *progress = NULL;
HRESULT hr;
SAFEARRAY *machinesArray = NULL;
hr = IvirtualBox->get_Machines(&machinesArray);
// Create target machine before start cloning
hr = SafeArrayAccessData (machinesArray, (void **) &machine);
BSTR guid = NULL;
BSTR strMachineName = ::SysAllocString(L"SampleMachine");
IGuestOSType* os = NULL;
BSTR type = ::SysAllocString(L"unknown");
hr = IvirtualBox->GetGuestOSType(type, &os);
os->get_Id(&guid);
os->Release();
BSTR null = ::SysAllocString(L"00000000-0000-0000-0000-000000000000");
hr = IvirtualBox->CreateMachine(NULL, strMachineName, guid, null, TRUE, &targetMachine);
::SysFreeString(null);
hr = machine->CloneTo(targetMachine, CloneMode_AllStates, machinesArray, &progress);
/* Wait untill clone is running. */
printf ("Cloning VM, please wait ...\n");
hr = progress->WaitForCompletion (-1);
It crashes in cloneto line. Am i missing something.? Any help on this.
Thanks a lot.
I am using 4.1.8 VB and the SDK i want to clone a machine for backup.
IMachine *targetMachine;
IMachine *machine;
ISession *session = NULL;
IConsole *console = NULL;
IProgress *progress = NULL;
HRESULT hr;
SAFEARRAY *machinesArray = NULL;
hr = IvirtualBox->get_Machines(&machinesArray);
// Create target machine before start cloning
hr = SafeArrayAccessData (machinesArray, (void **) &machine);
BSTR guid = NULL;
BSTR strMachineName = ::SysAllocString(L"SampleMachine");
IGuestOSType* os = NULL;
BSTR type = ::SysAllocString(L"unknown");
hr = IvirtualBox->GetGuestOSType(type, &os);
os->get_Id(&guid);
os->Release();
BSTR null = ::SysAllocString(L"00000000-0000-0000-0000-000000000000");
hr = IvirtualBox->CreateMachine(NULL, strMachineName, guid, null, TRUE, &targetMachine);
::SysFreeString(null);
hr = machine->CloneTo(targetMachine, CloneMode_AllStates, machinesArray, &progress);
/* Wait untill clone is running. */
printf ("Cloning VM, please wait ...\n");
hr = progress->WaitForCompletion (-1);
It crashes in cloneto line. Am i missing something.? Any help on this.
Thanks a lot.