Discussion:
[vbox-dev] IMachine methods in source code?
Johannes DeWitt
2014-06-06 12:46:46 UTC
Permalink
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?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140606/0cf02c63/attachment.html
Frank Mehnert
2014-06-06 12:51:20 UTC
Permalink
Johannes,
Post by Johannes DeWitt
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
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany

Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz

Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
Frank Mehnert
2014-06-06 13:27:15 UTC
Permalink
Sorry, that information is not available in VMM and I don't see the
reason why you would need it. And beyond the doxygen'd source code
there is no further documentation.

Kind regards,

Frank
Thanks.
Once i have that pRoot, how can i obtain for example the path of the
machine (like the GetSettingsFilePath() ) ?
If you don't have time for answer these specific questions, can you tell me
where can i find the documentation about the tree attributes?
Post by Frank Mehnert
Johannes,
Post by Johannes DeWitt
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
Post by Johannes DeWitt
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
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany
Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz
Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany

Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz

Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
Frank Mehnert
2014-06-06 15:10:54 UTC
Permalink
Hi Johannes,

1. Please could you reply to the list? Other users might be able to help
you or might be interested in your problems.

2. To read values from the VBox settings file you don't need the file
path but should use the CFGM API. You will find this API in
include/VBox/vmm/cfgm.h.

Kind regards,

Frank
Becouse i want to read some value from VMname.vbox (the xml file). So want
to obtain the path of VM, becouse the .vbox file is in the same folder.
And i'm looking for a way for read value from xml file
Post by Frank Mehnert
Sorry, that information is not available in VMM and I don't see the
reason why you would need it. And beyond the doxygen'd source code
there is no further documentation.
Kind regards,
Frank
Thanks.
Once i have that pRoot, how can i obtain for example the path of the
machine (like the GetSettingsFilePath() ) ?
If you don't have time for answer these specific questions, can you tell
me
where can i find the documentation about the tree attributes?
Post by Frank Mehnert
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source code. For example,
if a
Post by Frank Mehnert
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for example
in a
Post by Frank Mehnert
cpp
Post by Johannes DeWitt
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
Post by Frank Mehnert
VM.
Kind regards,
Frank
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt,
Germany
Post by Frank Mehnert
Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz
Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany
Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz
Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany

Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz

Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
Johannes DeWitt
2014-06-09 10:51:14 UTC
Permalink
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.
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
Post by Frank Mehnert
Johannes,
Post by Johannes DeWitt
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
Post by Johannes DeWitt
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
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany
Hauptverwaltung: Riesstr. 25, D-80992 M?nchen
Registergericht: Amtsgericht M?nchen, HRA 95603
Gesch?ftsf?hrer: J?rgen Kunz
Komplement?rin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Gesch?ftsf?hrer: Alexander van der Ven, Astrid Kepper, Val Maher
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140609/1462bad9/attachment.html
Klaus Espenlaub
2014-06-11 11:51:57 UTC
Permalink
Post by Johannes DeWitt
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.
Post by Johannes DeWitt
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
Post by Johannes DeWitt
2014-06-06 14:51 GMT+02:00 Frank Mehnert <frank.mehnert at oracle.com
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source code. For
example, if a
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for
example in a cpp
Post by Johannes DeWitt
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
Johannes DeWitt
2014-06-11 12:38:39 UTC
Permalink
Thanks you for your perfect explanation.
I wanted to use stdio.h because i was looking for a way to read some values
from outside, while a virtual machine is in runtime; so my idea was to use
the fopen function to read values from a normal file (txt or something).
But now i understand why i can't use stdio.h (kernel mode etc).

So, in VMMAll/ is it IMPOSSIBILE to read a value from another file? I read
your answer, i understand that a possibile way is from tm struct, but if i
need to use a value that can change in rumtime? My achievement is to read
(in VMMAll/ ) value from an external file, and read this value more times,
and this value can change during the execution.

For example, i need to execute a part code ONLY when i want, so my idea was
to write ( in a VMMALL/ .cpp file) code like this:

x= get value from external file MYVALUE (xml or somehting) (in this file,
the value is 0)
if (x) { do something;}

every time virtualbox execute this code, nothing happend.

after a while, from extern i change the value in the file MYVALUE (from 0
to 1)
Now, when virtualbox execute the code above, it enters in the {do
something;}

I hope you can understand my example.
Post by Klaus Espenlaub
Post by Johannes DeWitt
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.
Post by Johannes DeWitt
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
Post by Johannes DeWitt
2014-06-06 14:51 GMT+02:00 Frank Mehnert <frank.mehnert at oracle.com
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source code. For
example, if a
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for
example in a cpp
Post by Johannes DeWitt
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
Post by Johannes DeWitt
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
Post by Johannes DeWitt
VM.
Kind regards,
Frank
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140611/ea1a75aa/attachment.html
Klaus Espenlaub
2014-06-13 17:44:08 UTC
Permalink
Johannes,
Post by Johannes DeWitt
Thanks you for your perfect explanation.
I wanted to use stdio.h because i was looking for a way to read some
values from outside, while a virtual machine is in runtime; so my idea
was to use the fopen function to read values from a normal file (txt or
something).
But now i understand why i can't use stdio.h (kernel mode etc).
So, in VMMAll/ is it IMPOSSIBILE to read a value from another file? I
read your answer, i understand that a possibile way is from tm struct,
but if i need to use a value that can change in rumtime? My achievement
is to read (in VMMAll/ ) value from an external file, and read this
value more times, and this value can change during the execution.
I'm not following... you talked about modifying VMMAll/TMAll.cpp, which
is about timekeeping for the VM - and if you think you can read a file
(kernel or not) in such a context without seriously messing up the time
behavior then the understatement I can find is "optimist" :)

In any case, accessing a file from kernel mode is not portable in any
way, and thus I don't even want to think about it.
Post by Johannes DeWitt
For example, i need to execute a part code ONLY when i want, so my idea
x= get value from external file MYVALUE (xml or somehting) (in this
file, the value is 0)
if (x) { do something;}
every time virtualbox execute this code, nothing happend.
after a while, from extern i change the value in the file MYVALUE (from
0 to 1)
Now, when virtualbox execute the code above, it enters in the {do
something;}
I hope you can understand my example.
I think I do... it's super abstract and I can't be sure.

The proposal in my previous mail still applies: put variable x in the
VM/... structure, and add a way to tweak it from userland, e.g. with
"VBoxManage debugvm" (something inspired by "VBoxManage debugvm
injectnmi" maybe, or by hacking the handling of "VBoxManage debugvm
info", as that'd have already parameters, and you can register such
internal info handlers with DBGFR3InfoRegisterInternal - see
VMMR3/TM.cpp - which of course isn't meant to change anything
significant related to the VM etc. structures, but I can't see any
police :) ). The machine debugger is where I would add such hacks, as
the rest of the code has more clearly defined interfaces which
intentionally aren't as easily abusable.

I know this is more than 2 minutes of work, and I humbly ask for
apologies that we don't have the "do what I want" feature implemented (yet).

Klaus
Post by Johannes DeWitt
2014-06-11 13:51 GMT+02:00 Klaus Espenlaub <klaus.espenlaub at oracle.com
Post by Johannes DeWitt
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
Post by Johannes DeWitt
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.
Post by Johannes DeWitt
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
Post by Johannes DeWitt
2014-06-06 14:51 GMT+02:00 Frank Mehnert
<frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com>
Post by Johannes DeWitt
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source code. For
example, if a
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for
example in a cpp
Post by Johannes DeWitt
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
Post by Johannes DeWitt
are strictly separated, and in particular the IMachine code
you are
Post by Johannes DeWitt
talking about lives in VBoxSVC while the VMM code lives in
the VBoxSVC
Post by Johannes DeWitt
client (either the VirtualBox process or the VBoxHeadless
process).
Post by Johannes DeWitt
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
Post by Johannes DeWitt
VM.
Kind regards,
Frank
Johannes DeWitt
2014-06-17 09:07:05 UTC
Permalink
Thanks. So, i'm looking for a way to change value in VM struct from
VBoxManage. I'm not expert, but thank you for the hint.
I hope i can find a way
Post by Frank Mehnert
Johannes,
Post by Johannes DeWitt
Thanks you for your perfect explanation.
I wanted to use stdio.h because i was looking for a way to read some
values from outside, while a virtual machine is in runtime; so my idea
was to use the fopen function to read values from a normal file (txt or
something).
But now i understand why i can't use stdio.h (kernel mode etc).
So, in VMMAll/ is it IMPOSSIBILE to read a value from another file? I
read your answer, i understand that a possibile way is from tm struct,
but if i need to use a value that can change in rumtime? My achievement
is to read (in VMMAll/ ) value from an external file, and read this
value more times, and this value can change during the execution.
I'm not following... you talked about modifying VMMAll/TMAll.cpp, which
is about timekeeping for the VM - and if you think you can read a file
(kernel or not) in such a context without seriously messing up the time
behavior then the understatement I can find is "optimist" :)
In any case, accessing a file from kernel mode is not portable in any
way, and thus I don't even want to think about it.
Post by Johannes DeWitt
For example, i need to execute a part code ONLY when i want, so my idea
x= get value from external file MYVALUE (xml or somehting) (in this
file, the value is 0)
if (x) { do something;}
every time virtualbox execute this code, nothing happend.
after a while, from extern i change the value in the file MYVALUE (from
0 to 1)
Now, when virtualbox execute the code above, it enters in the {do
something;}
I hope you can understand my example.
I think I do... it's super abstract and I can't be sure.
The proposal in my previous mail still applies: put variable x in the
VM/... structure, and add a way to tweak it from userland, e.g. with
"VBoxManage debugvm" (something inspired by "VBoxManage debugvm
injectnmi" maybe, or by hacking the handling of "VBoxManage debugvm
info", as that'd have already parameters, and you can register such
internal info handlers with DBGFR3InfoRegisterInternal - see
VMMR3/TM.cpp - which of course isn't meant to change anything
significant related to the VM etc. structures, but I can't see any
police :) ). The machine debugger is where I would add such hacks, as
the rest of the code has more clearly defined interfaces which
intentionally aren't as easily abusable.
I know this is more than 2 minutes of work, and I humbly ask for
apologies that we don't have the "do what I want" feature implemented (yet).
Klaus
Post by Johannes DeWitt
2014-06-11 13:51 GMT+02:00 Klaus Espenlaub <klaus.espenlaub at oracle.com
Post by Johannes DeWitt
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
Post by Johannes DeWitt
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
Post by Johannes DeWitt
it's impossible to deal with CFGM settings. Everything must be
already
Post by Johannes DeWitt
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
Post by Johannes DeWitt
already uses CFGM), your needs probably can be covered by adding a
few
Post by Johannes DeWitt
such settings.
Note that all extradata keys (see documentation of VBoxManage
extradata)
Post by Johannes DeWitt
starting with VBoxInternal/ are stored in CFGM automatically, i.e.
you
Post by Johannes DeWitt
need to set VBoxInternal/TM/foo to some value in order to have it
available in VMMR3/TM.cpp.
Post by Johannes DeWitt
Any ideas? I tried also to include <stdio.h> for others
achievements,
Post by Johannes DeWitt
Post by Johannes DeWitt
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
Post by Johannes DeWitt
subset of the Runtime functionality is available, and I don't think
you
Post by Johannes DeWitt
need anything which isn't already used by VMMAll/*.cpp.
Klaus
Post by Johannes DeWitt
2014-06-06 14:51 GMT+02:00 Frank Mehnert
<frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com>
Post by Johannes DeWitt
<mailto:frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source code. For
example, if a
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for
example in a cpp
Post by Johannes DeWitt
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
Post by Johannes DeWitt
are strictly separated, and in particular the IMachine code
you are
Post by Johannes DeWitt
talking about lives in VBoxSVC while the VMM code lives in
the VBoxSVC
Post by Johannes DeWitt
client (either the VirtualBox process or the VBoxHeadless
process).
Post by Johannes DeWitt
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
Post by Johannes DeWitt
VM.
Kind regards,
Frank
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140617/87d77236/attachment.html
Johannes DeWitt
2014-06-19 11:27:11 UTC
Permalink
Ok, thanks about the hint: modify VBoxManage to write a way for change VM
struct fields...but i can't find a way. I understand that every change is
made by COMSETTER, but what about this function? There's no documentation
about this, i tried to search a similar situation in VBoxManage, but i
can't.
Post by Frank Mehnert
Johannes,
Post by Johannes DeWitt
Thanks you for your perfect explanation.
I wanted to use stdio.h because i was looking for a way to read some
values from outside, while a virtual machine is in runtime; so my idea
was to use the fopen function to read values from a normal file (txt or
something).
But now i understand why i can't use stdio.h (kernel mode etc).
So, in VMMAll/ is it IMPOSSIBILE to read a value from another file? I
read your answer, i understand that a possibile way is from tm struct,
but if i need to use a value that can change in rumtime? My achievement
is to read (in VMMAll/ ) value from an external file, and read this
value more times, and this value can change during the execution.
I'm not following... you talked about modifying VMMAll/TMAll.cpp, which
is about timekeeping for the VM - and if you think you can read a file
(kernel or not) in such a context without seriously messing up the time
behavior then the understatement I can find is "optimist" :)
In any case, accessing a file from kernel mode is not portable in any
way, and thus I don't even want to think about it.
Post by Johannes DeWitt
For example, i need to execute a part code ONLY when i want, so my idea
x= get value from external file MYVALUE (xml or somehting) (in this
file, the value is 0)
if (x) { do something;}
every time virtualbox execute this code, nothing happend.
after a while, from extern i change the value in the file MYVALUE (from
0 to 1)
Now, when virtualbox execute the code above, it enters in the {do
something;}
I hope you can understand my example.
I think I do... it's super abstract and I can't be sure.
The proposal in my previous mail still applies: put variable x in the
VM/... structure, and add a way to tweak it from userland, e.g. with
"VBoxManage debugvm" (something inspired by "VBoxManage debugvm
injectnmi" maybe, or by hacking the handling of "VBoxManage debugvm
info", as that'd have already parameters, and you can register such
internal info handlers with DBGFR3InfoRegisterInternal - see
VMMR3/TM.cpp - which of course isn't meant to change anything
significant related to the VM etc. structures, but I can't see any
police :) ). The machine debugger is where I would add such hacks, as
the rest of the code has more clearly defined interfaces which
intentionally aren't as easily abusable.
I know this is more than 2 minutes of work, and I humbly ask for
apologies that we don't have the "do what I want" feature implemented (yet).
Klaus
Post by Johannes DeWitt
2014-06-11 13:51 GMT+02:00 Klaus Espenlaub <klaus.espenlaub at oracle.com
Post by Johannes DeWitt
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
Post by Johannes DeWitt
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
Post by Johannes DeWitt
it's impossible to deal with CFGM settings. Everything must be
already
Post by Johannes DeWitt
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
Post by Johannes DeWitt
already uses CFGM), your needs probably can be covered by adding a
few
Post by Johannes DeWitt
such settings.
Note that all extradata keys (see documentation of VBoxManage
extradata)
Post by Johannes DeWitt
starting with VBoxInternal/ are stored in CFGM automatically, i.e.
you
Post by Johannes DeWitt
need to set VBoxInternal/TM/foo to some value in order to have it
available in VMMR3/TM.cpp.
Post by Johannes DeWitt
Any ideas? I tried also to include <stdio.h> for others
achievements,
Post by Johannes DeWitt
Post by Johannes DeWitt
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
Post by Johannes DeWitt
subset of the Runtime functionality is available, and I don't think
you
Post by Johannes DeWitt
need anything which isn't already used by VMMAll/*.cpp.
Klaus
Post by Johannes DeWitt
2014-06-06 14:51 GMT+02:00 Frank Mehnert
<frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com>
Post by Johannes DeWitt
<mailto:frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source code. For
example, if a
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source code, for
example in a cpp
Post by Johannes DeWitt
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
Post by Johannes DeWitt
are strictly separated, and in particular the IMachine code
you are
Post by Johannes DeWitt
talking about lives in VBoxSVC while the VMM code lives in
the VBoxSVC
Post by Johannes DeWitt
client (either the VirtualBox process or the VBoxHeadless
process).
Post by Johannes DeWitt
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
Post by Johannes DeWitt
VM.
Kind regards,
Frank
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140619/4c65111d/attachment.html
Klaus Espenlaub
2014-06-20 11:52:53 UTC
Permalink
Johannes,
Post by Johannes DeWitt
Ok, thanks about the hint: modify VBoxManage to write a way for change
VM struct fields...but i can't find a way. I understand that every
change is made by COMSETTER, but what about this function? There's no
documentation about this, i tried to search a similar situation in
VBoxManage, but i can't.
I pointed at "VBoxManage debugvm info ...", which allows executing any
info handler registered in VMM and elsewhere. Just register another one.
This info handler can parse the additional parameters and tweak whatever
your new VM struct field is.

The beauty of going this way is that it doesn't require any VBoxManage
or API changes, it's all there already.

Klaus
Post by Johannes DeWitt
2014-06-13 19:44 GMT+02:00 Klaus Espenlaub <klaus.espenlaub at oracle.com
Johannes,
Post by Johannes DeWitt
Thanks you for your perfect explanation.
I wanted to use stdio.h because i was looking for a way to read some
values from outside, while a virtual machine is in runtime; so my
idea
Post by Johannes DeWitt
was to use the fopen function to read values from a normal file
(txt or
Post by Johannes DeWitt
something).
But now i understand why i can't use stdio.h (kernel mode etc).
So, in VMMAll/ is it IMPOSSIBILE to read a value from another file? I
read your answer, i understand that a possibile way is from tm
struct,
Post by Johannes DeWitt
but if i need to use a value that can change in rumtime? My
achievement
Post by Johannes DeWitt
is to read (in VMMAll/ ) value from an external file, and read this
value more times, and this value can change during the execution.
I'm not following... you talked about modifying VMMAll/TMAll.cpp, which
is about timekeeping for the VM - and if you think you can read a file
(kernel or not) in such a context without seriously messing up the time
behavior then the understatement I can find is "optimist" :)
In any case, accessing a file from kernel mode is not portable in any
way, and thus I don't even want to think about it.
Post by Johannes DeWitt
For example, i need to execute a part code ONLY when i want, so
my idea
Post by Johannes DeWitt
x= get value from external file MYVALUE (xml or somehting) (in this
file, the value is 0)
if (x) { do something;}
every time virtualbox execute this code, nothing happend.
after a while, from extern i change the value in the file MYVALUE
(from
Post by Johannes DeWitt
0 to 1)
Now, when virtualbox execute the code above, it enters in the {do
something;}
I hope you can understand my example.
I think I do... it's super abstract and I can't be sure.
The proposal in my previous mail still applies: put variable x in the
VM/... structure, and add a way to tweak it from userland, e.g. with
"VBoxManage debugvm" (something inspired by "VBoxManage debugvm
injectnmi" maybe, or by hacking the handling of "VBoxManage debugvm
info", as that'd have already parameters, and you can register such
internal info handlers with DBGFR3InfoRegisterInternal - see
VMMR3/TM.cpp - which of course isn't meant to change anything
significant related to the VM etc. structures, but I can't see any
police :) ). The machine debugger is where I would add such hacks, as
the rest of the code has more clearly defined interfaces which
intentionally aren't as easily abusable.
I know this is more than 2 minutes of work, and I humbly ask for
apologies that we don't have the "do what I want" feature
implemented (yet).
Klaus
Post by Johannes DeWitt
2014-06-11 13:51 GMT+02:00 Klaus Espenlaub
<klaus.espenlaub at oracle.com <mailto:klaus.espenlaub at oracle.com>
Post by Johannes DeWitt
<mailto:klaus.espenlaub at oracle.com
Post by Johannes DeWitt
I tried to use this function in VMM/VMMAll/TMAll.cpp, but
when i
Post by Johannes DeWitt
Post by Johannes DeWitt
compile, i receive this: ?CFGMR3GetRoot? was not declared
in this
Post by Johannes DeWitt
scope
Post by Johannes DeWitt
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
Post by Johannes DeWitt
it's impossible to deal with CFGM settings. Everything must
be already
Post by Johannes DeWitt
stored in the VM or VMCPU structure or somewhere reachable
from there
Post by Johannes DeWitt
while in userland. See VMMR3/TM.cpp how the TM settings are
handled (it
Post by Johannes DeWitt
already uses CFGM), your needs probably can be covered by
adding a few
Post by Johannes DeWitt
such settings.
Note that all extradata keys (see documentation of VBoxManage
extradata)
Post by Johannes DeWitt
starting with VBoxInternal/ are stored in CFGM automatically,
i.e. you
Post by Johannes DeWitt
need to set VBoxInternal/TM/foo to some value in order to have it
available in VMMR3/TM.cpp.
Post by Johannes DeWitt
Any ideas? I tried also to include <stdio.h> for others
achievements,
Post by Johannes DeWitt
Post by Johannes DeWitt
but i recieve an error too (however in others .cpp files i
can use
Post by Johannes DeWitt
Post by Johannes DeWitt
stdio.h without any problems): i don't understand why
See above. One can't use the normal stdio.h functionality
from kernel. A
Post by Johannes DeWitt
subset of the Runtime functionality is available, and I don't
think you
Post by Johannes DeWitt
need anything which isn't already used by VMMAll/*.cpp.
Klaus
Post by Johannes DeWitt
2014-06-06 14:51 GMT+02:00 Frank Mehnert
<frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com>
<mailto:frank.mehnert at oracle.com <mailto:frank.mehnert at oracle.com>>
Post by Johannes DeWitt
Post by Johannes DeWitt
<mailto:frank.mehnert at oracle.com
<mailto:frank.mehnert at oracle.com> <mailto:frank.mehnert at oracle.com
Post by Johannes DeWitt
Post by Johannes DeWitt
Johannes,
Post by Johannes DeWitt
I, i need to use come IMachine methods in source
code. For
Post by Johannes DeWitt
Post by Johannes DeWitt
example, if a
Post by Johannes DeWitt
want to use the GetSettingsFilePath() function (used in
tstVBoxAPIXPCOM.cpp) in a cpp file of the source
code, for
Post by Johannes DeWitt
Post by Johannes DeWitt
example in a cpp
Post by Johannes DeWitt
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
Post by Johannes DeWitt
and Main
Post by Johannes DeWitt
are strictly separated, and in particular the IMachine
code
Post by Johannes DeWitt
you are
Post by Johannes DeWitt
talking about lives in VBoxSVC while the VMM code lives in
the VBoxSVC
Post by Johannes DeWitt
client (either the VirtualBox process or the VBoxHeadless
process).
Post by Johannes DeWitt
Inside VMM you should always have a pRoot handle,
pRoot = CFGMR3GetRoot(pVM);
Using this pRoot handle you can access the CFGM tree
for that
Post by Johannes DeWitt
particular
Post by Johannes DeWitt
VM.
Kind regards,
Frank
Loading...