[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Win32 compatibility for 0.9.11

Am 7. April 2012 20:23 schrieb Marcel Müller <marcel-mueller gmx de>:
> Hello everyone,
> I tried to build libvirt-0.9.11 for Windows using the MSYS Build Script
> provided by Matthias Bolte and noticed that there were two problems which
> made libvirt unusable.
> 1)      Whenever a TCP Connection is opened, libvirt will fail with “failed
> to set close-on-exec” (I’m using “xen+tcp” here).
> 2)      The lib will crash most of the time, because it tries to access a
> null pointer.
> I fixed both issues with a little patch:
> 1)      On Win32 platforms virSetInherit always returns -1, therefore
> failing any call which tries to set “close-on-exec”. I don’t know if there’s
> a Win32 equivalent of “close-on-exec”, so I just set this to return 0
> instead.
> 2)      Libvirt crashes, because TlsGetValue seems to return a NULL value
> sometimes. Not sure right now, if this is ok in a way or if it indicates
> another problem somewhere... (This might be the case, as I’m experience
> crashes as soon as libvirt is used in a multithreading application, though I
> had this with an old version as well. Will discuss that in another mail).

Okay, I looked into the TlsGetValue problem and I can reproduce it. In
my case it happened because virThreadIsSelf was called on the thread
that was not create via virThreadCreate and has no data set in the TLS
slot for the virThreadPtr. Because of this TlsGetValue returns NULL.
In contrast the pthread version is safe because pthread_self works
also on threads not created by virThreadCreate.

But your fix for this is incomplete, you need to set virThreadPtr
properly in all cases, including TlsGetValue returning NULL. I've
posted an improved version:


I didn't have time to look into the virSetInherit problem.

Matthias Bolte

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]