On Monday 16 January 2012 11:34:53 Matthias Bolte wrote:
Okay, without looking deeper into this here are some ideas:
The XPCOM API libvirt uses might not be threadsafe, or needs to be
initialized for every thread that wants to use it. Currently its only
initialized for the thread that opens the driver. I know that this is
the case on Windows were VirtualBox uses MSCOM for its API and you
need to call CoInitialize on every thread. This is currently not done
for the MSCOM glue in libvirt, so I know that on Windows the
VirtualBox driver is not threadsafe currently. Also I didn't look into
a solution for this yet. Maybe we need a thread local variable that
holds whether (MS/XP)COM was already initialized for this thread and
add a check to every driver function to initialize it when needed.
Did you try to open a connection for each thread instead of trying to
share one? If that works reliable it might indicate that there is an
VirtualBox API initialization problem.
I tried today with one connection for each thread and it works.
I changed the vbox driver so that the pfnComInitialize function is called only
when the first connection is opened : it breaks the test, even with one
connection per thread.
I guess we'll have to use a thread local variable as you suggested, unless
someone has a better idea to handle this problem.
--
Jean-Baptiste ROUAULT
Ingénieur R&D - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051