'Find any volumes with their connection severed.
Certain VM operations (e.g. `VM.start`, `VM.reboot`, etc.) will not
work when a VBD is present that points to a non-working volume. To work
around this, we scan for non-working volumes and detach them before
retrying a failed operation.'

def find_bad_volumes(self, vm_ref):

    bad_devices = []
    vbd_refs = self._get_all_volume_vbd_refs(vm_ref)
    for vbd_ref in vbd_refs:
        sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)
        try:
            self._session.SR.scan(sr_ref)
        except self._session.XenAPI.Failure as exc:
            if (exc.details[0] == 'SR_BACKEND_FAILURE_40'):
                device = self._session.VBD.get_device(vbd_ref)
                bad_devices.append(('/dev/%s' % device))
            else:
                raise
    return bad_devices
