From: Ian Jackson Subject: Re: [PATCH v8 08/11] xl/libxl: implement QDISK libxl_device_disk_local_attach Date: Thu, 7 Jun 2012 19:27:10 +0100 Message-ID: <20432.62078.265596.607954@mariner.uk.xensource.com> References: <1338287956-24691-8-git-send-email-stefano.stabellini@eu.citrix.com> <4FD0EB53.2040603@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4FD0EB53.2040603@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: "xen-devel@lists.xensource.com" , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Roger Pau Monne writes ("Re: [Xen-devel] [PATCH v8 08/11] xl/libxl: implement QDISK libxl_device_disk_local_attach"): > Stefano Stabellini wrote: > > int libxl__device_disk_local_detach(libxl__gc *gc, libxl_device_disk *disk) > > { > > - /* Nothing to do for PHYSTYPE_PHY. */ > > + int rc = 0; > > > > - /* > > - * For other device types assume that the blktap2 process is > > - * needed by the soon to be started domain and do nothing. > > - */ > > + switch (disk->backend) { > > + case LIBXL_DISK_BACKEND_QDISK: > > + if (disk->vdev != NULL) { > > + libxl_device_disk_remove(gc->owner, LIBXL_TOOLSTACK_DOMID, > > + disk, 0); > > I was just looking at this code, and I have the feeling this could be > dangerous, since you call libxl__device_disk_local_detach from an > already running ao (the bootloader ao), and libxl_device_disk_remove > will initiate another ao, and set it to completed inside of an already > running ao. This is indeed forbidden. The inner ao function exit will reenter the libxl event loop, which might do almost anything, including unexpectedly recursively reentering the other asynchronous operation (the lock doesn't prevent this since it's the same thread). Ian.