From: Jiri Denemark Subject: Fix removing /vm/UUID/device paths when device cannot be disconnected Date: Wed, 25 Feb 2009 16:39:56 +0100 Message-ID: <20090225153956.GA25947@orkuz.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="EVF5PPMfhYS0aIcm" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Currently if a device cannot be disconnected (for example, when trying to xm block-detach a disk which is mounted in domU), its /vm/UUID/device/CLASS/ID path is still removed. The result is that after a failed detach, the device cannot be detached even when using force... An example of bad behavior: xm create guest xm block-attach guest tap:aio:/var/lib/xen/images/disk.img xvdb w # mount /dev/xvdb1 in the guest Than "xm block-detach guest xvdb" fails with something like Error: Device ID (tap) could not be disconnected. Examining xenstore, one can find both xvdb's backend and frontend are there, but /vm/UUID/device/tap/ID is not. Although "xm block-list guest" would still show the xvdb device, "xm block-detach guest xvdb" would fail with Device ID not connected And it would show it even when --force is used. I'd suggest to change deviceDestroy behavior to remove /vm/UUID/device/... path only when force was used (as it already does so for both frontend and backend) and do the removing from xen-hotplug-cleanup script when we are sure the device is really not attached to the guest any more. Attached is a patch which moves unforced removing to cleanup script. Cheers. Signed-off-by: Jiri Denemark --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="device_destroy.patch" diff -r f8187a343ad2 tools/hotplug/Linux/xen-hotplug-cleanup --- a/tools/hotplug/Linux/xen-hotplug-cleanup Fri Feb 20 17:02:36 2009 +0000 +++ b/tools/hotplug/Linux/xen-hotplug-cleanup Wed Feb 25 16:16:07 2009 +0100 @@ -11,6 +11,13 @@ # This is pretty horrible, but there's not really a nicer way of solving this. claim_lock "block" +# split backend/DEVCLASS/VMID/DEVID on slashes +path_array=( ${XENBUS_PATH//\// } ) +# get /vm/UUID path +vm=$(xenstore-read "/local/domain/${path_array[2]}/vm") +# construct /vm/UUID/device/DEVCLASS/DEVID +vm_dev="$vm/device/${path_array[1]}/${path_array[3]}" + # remove device frontend store entries xenstore-rm -t \ $(xenstore-read "$XENBUS_PATH/frontend" 2>/dev/null) 2>/dev/null || true @@ -19,4 +26,7 @@ xenstore-rm -t "$XENBUS_PATH" 2>/dev/null || true xenstore-rm -t "error/$XENBUS_PATH" 2>/dev/null || true +# remove device path from /vm/UUID +xenstore-rm -t "$vm_dev" 2>/dev/null || true + release_lock "block" diff -r f8187a343ad2 tools/python/xen/xend/server/DevController.py --- a/tools/python/xen/xend/server/DevController.py Fri Feb 20 17:02:36 2009 +0000 +++ b/tools/python/xen/xend/server/DevController.py Wed Feb 25 16:16:07 2009 +0100 @@ -235,8 +235,8 @@ xstransact.Remove(backpath) xstransact.Remove(frontpath) - # xstransact.Remove(self.devicePath()) ?? Below is the same ? - self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev)) + # xstransact.Remove(self.devicePath()) ?? Below is the same ? + self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev)) def configurations(self, transaction = None): return map(lambda x: self.configuration(x, transaction), self.deviceIDs(transaction)) --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --EVF5PPMfhYS0aIcm--