The XenBus, in the context of device drivers, is an informal protocol built on top of the XenStore, which provides a way of enumerating the (virtual) devices available to a given domain, and connecting to them. Implementing the XenBus interface is not required when porting a kernel to Xen. It is predominantly used in Linux to isolate the Xen-specific code behind a relatively abstract interface.(from chapter 6.4[1])
enumxenbus_state { XenbusStateUnknown = 0, XenbusStateInitialising = 1, XenbusStateInitWait = 2, /* Finished early initialisation, but waiting for information from the peer or hotplug scripts. */ XenbusStateInitialised = 3, /* Initialised and waiting for a connection from the peer. */ XenbusStateConnected = 4, XenbusStateClosing = 5, /* The device is being closed due to an error or an unplug event. */ XenbusStateClosed = 6,
/* * Reconfiguring: The device is being reconfigured. */ XenbusStateReconfiguring = 7, XenbusStateReconfigured = 8 };
/* We set up the callback functions */ staticstructxenbus_driveralice_back_driver = { .ids = alice_back_ids, .probe = alice_back_probe, .otherend_changed = alice_back_otherend_changed, };
/* The function is called on a state change of the frontend driver */ staticvoidalice_back_otherend_changed(struct xenbus_device *dev, enum xenbus_state frontend_state) { switch (frontend_state) { case XenbusStateInitialising: set_backend_state(dev, XenbusStateInitWait); break;
case XenbusStateConnected: set_backend_state(dev, XenbusStateConnected); break; ...
default: xenbus_dev_fatal(dev, -EINVAL, "saw state %s (%d) at frontend", xenbus_strstate(frontend_state), frontend_state); break; } }