[vbox-dev] VirtualBox COM works on Linux, but CRASHES on Windows !
nikolay.igotti at oracle.com
Sun Apr 24 11:42:57 PDT 2011
24.04.2011 20:05, Alexey Eromenko пишет:
> On Sun, Apr 24, 2011 at 9:07 AM, Nikolay Igotti
> <nikolay.igotti at oracle.com> wrote:
>> Consider VirtualBoxManager() a singleton, you need to create only once. So
>> smth like
>> def getMgr():
>> global g_mgr
>> if g_mgr is None:
>> g_mgr = VirtualBoxManager(None, None)
>> return g_mgr
> This exactly code fails in GNS3. (in 'vboxwrapper.py')
> This is because they start some 'vboxstarter' class via TCP server (in
> the same python module) which spawns new thread (instead of process),
> so if you initialize it twice in new thread it fails.
Exactly for that, VirtualBoxManager has initPerThread and
deinitPerThread methods. If you have spent some time checking how
other multithreaded programs (such as vboxweb), using VBox API or
anything else COM-based implemented,
this whole discussion would be pointless.
> If you use it 'as is', it won't crash but it will refuse to start VMs,
> complaining they that 'VirtualBoxManager() was marshalled from some
> other thread' or findMachine() fails with: 'Object is not connected to
> server'. (depends where I put the code)
You also need to transfer ownership of COM object, which has nothing to
do with VirtualBox, but related to COM threading model.
as an example (search for
> Plus, doing 'del g_mgr' doesn't uninitialize it fully. It still crashes.
This probably need to be eventually looked at, but as I said, you don't
really need it.
More information about the vbox-dev