Exemple #1
0
/**
 * Handler for all generic XenBus device systcl nodes.
 */
static int
xenbusb_device_sysctl_handler(SYSCTL_HANDLER_ARGS)  
{
	device_t dev;
        const char *value;

	dev = (device_t)arg1;
        switch (arg2) {
	case XENBUS_IVAR_NODE:
		value = xenbus_get_node(dev);
		break;
	case XENBUS_IVAR_TYPE:
		value = xenbus_get_type(dev);
		break;
	case XENBUS_IVAR_STATE:
		value = xenbus_strstate(xenbus_get_state(dev));
		break;
	case XENBUS_IVAR_OTHEREND_ID:
		return (sysctl_handle_int(oidp, NULL,
					  xenbus_get_otherend_id(dev),
					  req));
		/* NOTREACHED */
	case XENBUS_IVAR_OTHEREND_PATH:
		value = xenbus_get_otherend_path(dev);
                break;
	default:
		return (EINVAL);
	}
	return (SYSCTL_OUT_STR(req, value));
}
Exemple #2
0
int
xenbus_grant_ring(device_t dev, unsigned long ring_mfn, grant_ref_t *refp)
{
	int error;

	error = gnttab_grant_foreign_access(
		xenbus_get_otherend_id(dev), ring_mfn, 0, refp);
	if (error) {
		xenbus_dev_fatal(dev, error, "granting access to ring page");
		return (error);
	}

	return (0);
}
Exemple #3
0
int
xenbus_alloc_evtchn(device_t dev, evtchn_port_t *port)
{
	struct evtchn_alloc_unbound alloc_unbound;
	int err;

	alloc_unbound.dom        = DOMID_SELF;
	alloc_unbound.remote_dom = xenbus_get_otherend_id(dev);

	err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
					  &alloc_unbound);

	if (err) {
		xenbus_dev_fatal(dev, -err, "allocating event channel");
		return (-err);
	}
	*port = alloc_unbound.port;
	return (0);
}