[xen] Cope with unexpected initial backend states

Under some circumstances (e.g. if iPXE itself is booted via iSCSI, or
after an unclean reboot), the backend may not be in the expected
InitWait state when iPXE starts up.

There is no generic reset mechanism for Xenbus devices.  Recent
versions of xen-netback will gracefully perform all of the required
steps if the frontend sets its state to Initialising.  Older versions
(such as that found in XenServer 6.2.0) require the frontend to
transition through Closed before reaching Initialising.

Add a reset mechanism for netfront devices which does the following:

 - read current backend state

 - if backend state is anything other than InitWait, then set the
   frontend state to Closed and wait for the backend to also reach
   Closed

 - set the frontend state to Initialising and wait for the backend to
   reach InitWait.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2014-08-14 00:03:43 +01:00
parent be79ca535a
commit 8b2942a7db
3 changed files with 66 additions and 11 deletions

View File

@@ -118,7 +118,7 @@ int xenbus_set_state ( struct xen_device *xendev, int state ) {
* @v xendev Xen device
* @ret state Backend state, or negative error
*/
static int xenbus_backend_state ( struct xen_device *xendev ) {
int xenbus_backend_state ( struct xen_device *xendev ) {
unsigned long state;
int rc;