On Wed, Jul 16, 2014 at 12:08:50AM +0400, Vasiliy Tolstov
wrote:> 2014-07-15 20:59 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
> > Not sure I understand the question, but the guestfish mount-local-run
> > command will block guestfish until another process runs
> > 'fusermount -u /mntpoint' (or better, 'guestunmount
/mntpoint').
>
>
> I understand that guestfish process will be locked. But in case of go
> that uses lightweight goroutines, is that possible to replace fork
> with goroutine ?
It's a pretty tricky question.
It will depend on how goroutines map to pthreads.
In my experience it has been very difficult to avoid races in FUSE
when using EITHER pthreads OR multiple processes. One particular
problem is if the kernel socket that FUSE uses leaks into a forked
subprocess, which can happen because the FUSE library is not careful
about setting FD_CLOEXEC atomically.
You'll probably want to take a look at the implementation of
guestfs_mount_local_run here:
https://github.com/libguestfs/libguestfs/blob/master/src/fuse.c#L1029
Also at the parallel test of mount_local which is part of the test
suite:
https://github.com/libguestfs/libguestfs/blob/master/tests/mount-local/test-parallel-mount-local.c
BTW is there any reason to use FUSE instead of using the libguestfs
API directly? Using the API is going to be much more robust.
Also
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org