[vbox-dev] IMachine methods in source code?

Klaus Espenlaub klaus.espenlaub at oracle.com
Wed Jun 11 11:51:57 GMT 2014


On 09.06.2014 12:51, Johannes DeWitt wrote:
> I tried to use this function in VMM/VMMAll/TMAll.cpp, but when i
> compile, i receive this: ‘CFGMR3GetRoot’ was not declared in this scope
> I added #include <VBox/vmm/cfgm.h, but atill have this error.

TMAll.cpp is code which is compiled several times, once for the 
userland, once for kernel mode etc etc., which shares data. In this code 
it's impossible to deal with CFGM settings. Everything must be already 
stored in the VM or VMCPU structure or somewhere reachable from there 
while in userland. See VMMR3/TM.cpp how the TM settings are handled (it 
already uses CFGM), your needs probably can be covered by adding a few 
such settings.

Note that all extradata keys (see documentation of VBoxManage extradata) 
starting with VBoxInternal/ are stored in CFGM automatically, i.e. you 
need to set VBoxInternal/TM/foo to some value in order to have it 
available in VMMR3/TM.cpp.

> Any ideas? I tried also to include <stdio.h> for others achievements,
> but i recieve an error too (however in others .cpp files i can use
> stdio.h without any problems): i don't understand why

See above. One can't use the normal stdio.h functionality from kernel. A 
subset of the Runtime functionality is available, and I don't think you 
need anything which isn't already used by VMMAll/*.cpp.

Klaus

> 2014-06-06 14:51 GMT+02:00 Frank Mehnert <frank.mehnert at oracle.com
> <mailto:frank.mehnert at oracle.com>>:
>
>     Johannes,
>
>     On Friday 06 June 2014 14:46:46 Johannes DeWitt wrote:
>      > I, i need to use come IMachine methods in source code. For
>     example, if a
>      > want to use the GetSettingsFilePath() function (used in
>      > tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for
>     example in a cpp
>      > file in /src/VBox/VMM/VMMAll/, how can i do it?
>      > And which headers files i need to include?
>
>     that's actually not the intended way to use !VirtualBox. VMM and Main
>     are strictly separated, and in particular the IMachine code you are
>     talking about lives in VBoxSVC while the VMM code lives in the VBoxSVC
>     client (either the VirtualBox process or the VBoxHeadless process).
>
>     Inside VMM you should always have a pRoot handle,
>
>        pRoot = CFGMR3GetRoot(pVM);
>
>     Using this pRoot handle you can access the CFGM tree for that particular
>     VM.
>
>     Kind regards,
>
>     Frank




More information about the vbox-dev mailing list