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

Re: [Xen-devel] [PATCH v3 03/15] libxl: properly lock userdata store

On Thu, 2014-09-04 at 23:43 +0100, Wei Liu wrote:
> Originally libxl user data store didn't have lock at all. There could be
> such race condition as mentioned by Ian Jackson:
>   Task 1                                 Task 2
>   Creating the domain                    Trying to shut down
>     actually create domain
>                                            observe domid
>                                            start domain destruction
>                                            delete all userdata
>                                            destroy domain
>     store the userdata
>       *** forbidden state created: userdata exists but domain doesn't
>       *** userdata has been leaked
>     [ would now bomb out ]
> This patch adds in proper locking to libxl user data store. The lock is
> associated with a specific domain (i.e. a per-domain lock).
> As for locking hierachy, we first take CTX lock (which is implemented
> with pthread recursive mutex so even if the application has taken it
> we're fine), then take the file lock. These locks are released in
> reversed order.
> A new libxl error code ERROR_LOCK_FAIL is introduced to describe failure
> to acquire locks.
> Also factor out libxl__userdata_{retrieve,store}, so that other
> functions that already hold the lock can call them to manipulate
> user data.
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>

Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.