FreeBSD/sys/dev/xen/blkback/blkback.c
/**
 * Handle state changes expressed via the XenStore by our front-end peer.
 *
 * \param dev             NewBus device object representing this Xen
 *                        Block Back instance.
 * \param frontend_state  The new state of the front-end.
 *
 * \return  0 for success, errno codes for failure.
 */
Handle state changes expressed via the XenStore by our front-end peer.
\param dev             NewBus device object representing this Xen
Block Back instance.
\param frontend_state  The new state of the front-end.

\return  0 for success, errno codes for failure.
Handle state changes expressed via the XenStore by our front - end peer . \ param dev NewBus device object representing this Xen Block Back instance . \ param frontend_state The new state of the front - end . \ return 0 for success errno codes for failure .
static void
xbb_frontend_changed(device_t dev, XenbusState frontend_state)
{
	struct xbb_softc *xbb = device_get_softc(dev);
	DPRINTF("frontend_state=%s, xbb_state=%s\n",
	        xenbus_strstate(frontend_state),
		xenbus_strstate(xenbus_get_state(xbb->dev)));
	switch (frontend_state) {
	case XenbusStateInitialising:
		break;
	case XenbusStateInitialised:
	case XenbusStateConnected:
		xbb_connect(xbb);
		break;
	case XenbusStateClosing:
	case XenbusStateClosed:
		mtx_lock(&xbb->lock);
		xbb_shutdown(xbb);
		mtx_unlock(&xbb->lock);
		if (frontend_state == XenbusStateClosed)
			xenbus_set_state(xbb->dev, XenbusStateClosed);
		break;
	default:
		xenbus_dev_fatal(xbb->dev, EINVAL, "saw state %d at frontend",
				 frontend_state);
		break;
	}
}
static void xbb_frontend_changed ( device_t dev , XenbusState frontend_state ) { struct xbb_softc * xbb = device_get_softc ( dev ) ; DPRINTF ( " \n " , xenbus_strstate ( frontend_state ) , xenbus_strstate ( xenbus_get_state ( xbb -> dev ) ) ) ; switch ( frontend_state ) { case XenbusStateInitialising : break ; case XenbusStateInitialised : case XenbusStateConnected : xbb_connect ( xbb ) ; break ; case XenbusStateClosing : case XenbusStateClosed : mtx_lock ( & xbb -> lock ) ; xbb_shutdown ( xbb ) ; mtx_unlock ( & xbb -> lock ) ; if ( frontend_state == XenbusStateClosed ) xenbus_set_state ( xbb -> dev , XenbusStateClosed ) ; break ; default : xenbus_dev_fatal ( xbb -> dev , EINVAL , " " , frontend_state ) ; break ; } }
Handle state changes expressed via the XenStore by our front-end peer.
Handle state changes expressed via the XenStore by our front - end peer .