[libvirt] [PATCH v7 2/6] add fuse support for libvirt lxc

Gao feng gaofeng at cn.fujitsu.com
Tue Nov 6 08:54:59 UTC 2012


于 2012年11月06日 16:34, Richard W.M. Jones 写道:
> On Tue, Nov 06, 2012 at 02:07:18PM +0800, Gao feng wrote:
>> +static int
>> +virLXCControllerSetupFuse(virLXCControllerPtr ctrl)
>> +{
>> +    int try = 0;
>> +    virThread thread;
>> +    if (virThreadCreate(&thread, true, lxcRegisterFuse,
>> +                        (void *)ctrl->def) < 0)
>> +        return -1;
>> +    /*
>> +     * because libvirt_lxc may use fuse filesystem before fuse being
>> +     * mounted by the thread. so wait 3 seconds in libvirt_lxc. if fuse
>> +     * is not mounted in 3 seconds, libvirt_lxc will exit.
>> +     */
>> +    while (try++ < 2) {
>> +        if (lxcRegisterFuseSuccess())
>> +            return 0;
>> +
>> +        sleep(1);
>> +    }
>> +
>> +    return -1;
>> +}
> 
> This code seems like it is bound to cause trouble.  Can you explain
> why the arbitrary wait is required here?
> 

Because libvirt_lxc create a thread to mount fuse filesystem.
and then libvirt_lxc will try to access the fuse filesystem.

Without waiting,libvirt_lxc may access fuse before it is mounted.

And I can't find a better way to make accessing fuse after the fuse
being mounted,because fuse_main will return until fuse being unmounted,so
I don't know how to pass message to tell libvirt_lxc whether the fuse is
mounted success.

>> diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
>> new file mode 100644
>> index 0000000..42107d7
>> --- /dev/null
>> +++ b/src/lxc/lxc_fuse.c
>> @@ -0,0 +1,157 @@
>> +/*
>> + * Copyright (C) 2012 Fujitsu Limited.
>> + *
>> + * lxc_fuse.c: fuse filesystem support for libvirt lxc
> [...]
> 
> The basic empty directory fuse filesystem seems fine.  I see
> that patch 5/6 adds one(?) file to this directory, also fine.
> 

Thanks for your review.

Gao





More information about the libvir-list mailing list