xen-org/xen-api — pull request #717 by djs55 (2012-07-01 13:16:44+00:00)
Title: CA-83837: VBD_unplug is now more robust; should not hang erroneously

Reliably cleaning up a VBD is quite tricky since:
1. the domain may have been destroyed underneath us
2. the xenstore device may have shutdown already

The code now cleans all the resources up independently, and avoids exiting early with (occasionally expected) exception.

Note this depends on a xen-api-libs pull request.
Note this does fix the blocking behaviour *but* it won't be as good as the previous release until either
1. we revert the shutdown-done / PVops compatibility fix
2. blkback guarantees to fire the udev remove event even when a hotunplug is initially rejected by the frontend.

This has been tested by:
1. quicktest: this does a number of VBD operations which are relevant
2. suspend: verified no storage resource leak
3. localhost migrate: verified storage resources are properly accounted for
4. VBD.unplug doesn't block even if the device is in use by the guest. *Note* this is where the blkback bug was exposed: if the guest initially refuses the unplug but then subsequently let go, the VBD is left attached because the remove udev event doesn't fire. The disk ends up in limbo: the guest can't touch it and neither can anyone else, until the VM is rebooted.