[CRIU] Thread safety of C API
Andrew Vagin
avagin at virtuozzo.com
Wed Jun 8 15:44:10 PDT 2016
On Wed, Jun 08, 2016 at 03:14:25PM +0200, Michal Privoznik wrote:
> Dear list,
>
> forgive me if this question has been asked already, but I didn't find
> anything about that. Katerina (CCed) and me are working on implementing
> migration support for our LXC driver [1] in libvirt [2]. And we wanted
> to use the C API, however reading the documentation to that [3] and
> checking out the sources we've found that C API is not threat safe. This
> is a bummer, since libvirt is multi-threaded app where each thread is
> allowed to execute an API over distant VMs (in this case containers) at
> the same time. So we are unable to use the C API unless we serialize the
> callers wanting to migrate on a mutex. This would, however, have
> unfortunate effect on our performance.
>
> My question here is, are there any plans on making the APIs thread safe?
> I don't know what's the policy on changing APIs (for instance in Libvirt
> we don't allow that and have to invent a new one for the flawed ones). I
> can provide the patches if there's not enough bandwidth, but I'd rather
> check with you before devoting my time to it.
What do we need to do to make it thread-safe?
Actually I can't say anything about changing API of the library,
it's up to Pavel.
But if you think that the library doesn't cover your needs,
you can use our RPC protocol directly:
https://criu.org/RPC
Here is an example how we do this in runc:
https://github.com/opencontainers/runc/blob/master/libcontainer/container_linux.go#L799
Thanks,
Andrew
>
> Thanks!
>
> Michal
>
> 1: https://www.redhat.com/archives/libvir-list/2016-May/msg00565.html
> 2: http://libvirt.org/internals/eventloop.html#worker_pool
> 3: https://criu.org/C_API
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list