FreeBSD/sys/dev/xen/blkback/blkback.c
/**
 * Connect to our blkfront peer now that it has completed publishing
 * its configuration into the XenStore.
 *
 * \param xbb  Per-instance xbb configuration structure.
 */
Connect to our blkfront peer now that it has completed publishing
its configuration into the XenStore.

\param xbb  Per-instance xbb configuration structure.
Connect to our blkfront peer now that it has completed publishing its configuration into the XenStore . \ param xbb Per - instance xbb configuration structure .
static void
xbb_connect(struct xbb_softc *xbb)
{
	int error;
	if (xenbus_get_state(xbb->dev) != XenbusStateInitialised)
		return;
	if (xbb_collect_frontend_info(xbb) != 0)
		return;
	xbb->flags &= ~XBBF_SHUTDOWN;
	xbb->max_reqlist_segments = MIN(xbb->max_request_segments *
		xbb->max_requests, XBB_MAX_SEGMENTS_PER_REQLIST);
	xbb->max_reqlist_size = xbb->max_reqlist_segments * PAGE_SIZE;
	error = xbb_alloc_communication_mem(xbb);
	if (error != 0) {
		xenbus_dev_fatal(xbb->dev, error,
				 "Unable to allocate communication memory");
		return;
	}
	error = xbb_alloc_requests(xbb);
	if (error != 0) {
		return;
	}
	error = xbb_alloc_request_lists(xbb);
	if (error != 0) {
		return;
	}
	error = xbb_connect_ring(xbb);
	if (error != 0) {
		return;
	}
	if (xbb_publish_backend_info(xbb) != 0) {
		(void)xbb_disconnect(xbb);
		return;
	}
	xenbus_set_state(xbb->dev, XenbusStateConnected);
}
static void xbb_connect ( struct xbb_softc * xbb ) { int error ; if ( xenbus_get_state ( xbb -> dev ) != XenbusStateInitialised ) return ; if ( xbb_collect_frontend_info ( xbb ) != 0 ) return ; xbb -> flags &= ~ XBBF_SHUTDOWN ; xbb -> max_reqlist_segments = MIN ( xbb -> max_request_segments * xbb -> max_requests , XBB_MAX_SEGMENTS_PER_REQLIST ) ; xbb -> max_reqlist_size = xbb -> max_reqlist_segments * PAGE_SIZE ; error = xbb_alloc_communication_mem ( xbb ) ; if ( error != 0 ) { xenbus_dev_fatal ( xbb -> dev , error , " " ) ; return ; } error = xbb_alloc_requests ( xbb ) ; if ( error != 0 ) { return ; } error = xbb_alloc_request_lists ( xbb ) ; if ( error != 0 ) { return ; } error = xbb_connect_ring ( xbb ) ; if ( error != 0 ) { return ; } if ( xbb_publish_backend_info ( xbb ) != 0 ) { ( void ) xbb_disconnect ( xbb ) ; return ; } xenbus_set_state ( xbb -> dev , XenbusStateConnected ) ; }
Connect to our blkfront peer now that it has completed publishing
 its configuration into the XenStore.
Connect to our blkfront peer now that it has completed publishing its configuration into the XenStore .
/*
	 * We limit the maximum number of reqlist segments to the maximum
	 * number of segments in the ring, or our absolute maximum,
	 * whichever is smaller.
	 */ /*
	 * The maximum size is simply a function of the number of segments
	 * we can handle.
	 */ /* Allocate resources whose size depends on front-end configuration. */ /* Specific errors are reported by xbb_alloc_requests(). */ /* Specific errors are reported by xbb_alloc_request_lists(). */ /*
	 * Connect communication channel.
	 */ /* Specific errors are reported by xbb_connect_ring(). */ /*
		 * If we can't publish our data, we cannot participate
		 * in this connection, and waiting for a front-end state
		 * change will not help the situation.
		 */ /* Ready for I/O. */