[vbox-dev] createHardDisk and createBaseStorage

Frédéric SOSSON fsosson at gmail.com
Tue Aug 11 07:45:48 GMT 2009


I'm coding in Python and it's not so easy to translate from cpp, so
how to defined ISession ?

2009/8/10 Huihong Luo <huisinro at yahoo.com>:
> you need a mutable IMachine instance, refer to following code:
>
> // delete a vbox vm given the vm name
> HRESULT DeleteVBoxVM(IN PWSTR vmname)
> {
> HRESULT rc;
> rc = CreateVBoxCOM();
> if (rc)
> return rc;
> IMachine *machine = NULL;
> ISession *session = g_pSession;
> IMachine *pMutableMachine = NULL;
> rc = g_pVBox->FindMachine(BStr(vmname), &machine);
> if (SUCCEEDED(rc)) do {
> BSTR uuid;
> machine->get_Id(&uuid);
> rc = g_pVBox->OpenSession(session, uuid);
> CHECK_ERROR_BREAK(rc);
> rc = session->get_Machine(&pMutableMachine);
> CHECK_ERROR_BREAK(rc);
> rc = pMutableMachine->DetachHardDisk(BStr(L
> "IDE"), 0, 0);
> if (SUCCEEDED(rc)) {
> /* commit changes */
> rc = pMutableMachine->SaveSettings();
> }
> pMutableMachine->Release();
> session->Close();
> CHECK_ERROR_BREAK(rc);
> IMachine *machine1 = NULL;
> rc = g_pVBox->UnregisterMachine(uuid, &machine1);
> if (SUCCEEDED(rc)) {
> machine1->DeleteSettings();
> printf(
> "Virtual machine '%ls' has been successfully deleted.\n", vmname);
> machine1->Release();
> }
> }
> while (0);
> if (machine)
> machine->Release();
> CHECK_ERROR(rc);
> ReleaseVBoxCOM();
> return rc;
> }
>
> --- On Mon, 8/10/09, Frédéric SOSSON <fsosson at gmail.com> wrote:
>
> From: Frédéric SOSSON <fsosson at gmail.com>
> Subject: Re: [vbox-dev] createHardDisk and createBaseStorage
> To: vbox-dev at virtualbox.org
> Date: Monday, August 10, 2009, 8:11 AM
>
> after using addStorageController, I got this message: The machine is
> not mutable (state is 1)
>
> what does it mean?
>
> 2009/8/10 Frédéric SOSSON <fsosson at gmail.com>:
>> OK, thanx for the piece of code provided by Nikolay
>>
>> 2009/8/10 Klaus Espenlaub <Klaus.Espenlaub at sun.com>:
>>> Frédéric SOSSON wrote:
>>>>
>>>> do you mean vboxshell ?
>>>
>>> no, I usually don't mean vboxshell if I type VBoxManage ;)
>>>
>>> I know that many python programmers are highly allergic to C++ code, but
>>> with VirtualBox it's just a fact that the vast majority of code which
>>> uses
>>> the API is C++. And it should give you at least a hint what the usual
>>> sequence of API calls is.
>>>
>>> Nikolay provided python code which does the job, but the same information
>>> could be easily distilled out of VBoxManageDisk.cpp in the VirtualBox
>>> sources. Or by looking at the API documentation.
>>>
>>> Klaus
>>>
>>>>
>>>> 2009/8/10 Klaus Espenlaub <Klaus.Espenlaub at sun.com>:
>>>>>
>>>>> Frédéric SOSSON wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I try to create hard disk and to use createBaseStorage...
>>>>>>
>>>>>> Do you have a small sample ?
>>>>>
>>>>> The usual "sample" is VBoxManage. The total tool is relatively big, but
>>>>> each
>>>>> subcommand is usually pretty straightforward.
>>>>>
>>>>> Klaus
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Dr. Klaus Espenlaub
>>> Sun Microsystems GmbH
>>> Werkstrasse 24
>>> 71384 Weinstadt
>>> Germany
>>>
>>> =====================================================================
>>> Sitz der Gesellschaft:
>>> Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
>>> Amtsgericht Muenchen: HRB 161028
>>> Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
>>> Vorsitzender des Aufsichtsrates: Martin Haering
>>> =====================================================================
>>>
>>
>>
>>
>> --
>> Frédéric SOSSON
>> Tél.: 0032 496 29 29 88
>>
>
>
>
> --
> Frédéric SOSSON
> Tél.: 0032 496 29 29 88
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev
>



-- 
Frédéric SOSSON
Tél.: 0032 496 29 29 88




More information about the vbox-dev mailing list