Exemplo n.º 1
0
int xenbus_read_otherend_details(struct xenbus_device *xendev,
				 char *id_node, char *path_node)
{
	int err = xenbus_gather(XBT_NIL, xendev->nodename,
				id_node, "%i", &xendev->otherend_id,
				path_node, NULL, &xendev->otherend,
				NULL);
	if (err) {
		xenbus_dev_fatal(xendev, err,
				 "reading other end details from %s",
				 xendev->nodename);
		return err;
	}
	if (strlen(xendev->otherend) == 0 ||
	    !xenbus_exists(XBT_NIL, xendev->otherend, "")) {
		xenbus_dev_fatal(xendev, -ENOENT,
				 "unable to read other end from %s.  "
				 "missing or inaccessible.",
				 xendev->nodename);
		free_otherend_details(xendev);
		return -ENOENT;
	}

	return 0;
}
Exemplo n.º 2
0
/* accelstate on the frontend's xenbus node has changed */
static void bend_domu_accel_change(struct xenbus_watch *watch,
				   const char **vec, unsigned int len)
{
	int state;
	struct netback_accel *bend;

	bend = container_of(watch, struct netback_accel, domu_accel_watch);
	if (bend->domu_accel_watch.node != NULL) {
		struct xenbus_device *dev = 
			(struct xenbus_device *)bend->hdev_data;
		VPRINTK("Watch matched, got dev %p otherend %p\n",
			dev, dev->otherend);
		/*
		 * dev->otherend != NULL check to protect against
		 * watch firing when domain goes away and we haven't
		 * yet cleaned up
		 */
		if (!dev->otherend ||
		    !xenbus_exists(XBT_NIL, watch->node, "") ||
		    strncmp(dev->otherend, vec[XS_WATCH_PATH],
			    strlen(dev->otherend))) {
			DPRINTK("Ignoring watch as otherend seems invalid\n");
			return;
		}

		mutex_lock(&bend->bend_mutex);

		xenbus_scanf(XBT_NIL, dev->otherend, "accelstate", "%d", 
			     &state);
		netback_accel_frontend_changed(dev, state);

		mutex_unlock(&bend->bend_mutex);
	}
}
Exemplo n.º 3
0
/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
static int backend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
{
	int domid, err;
	const char *devid, *type, *frontend;
	unsigned int typelen;

	type = strchr(nodename, '/');
	if (!type)
		return -EINVAL;
	type++;
	typelen = strcspn(type, "/");
	if (!typelen || type[typelen] != '/')
		return -EINVAL;

	devid = strrchr(nodename, '/') + 1;

	err = xenbus_gather(XBT_NIL, nodename, "frontend-id", "%i", &domid,
			    "frontend", NULL, &frontend,
			    NULL);
	if (err)
		return err;
	if (strlen(frontend) == 0)
		err = -ERANGE;
	if (!err && !xenbus_exists(XBT_NIL, frontend, ""))
		err = -ENOENT;
	kfree(frontend);

	if (err)
		return err;

	if (snprintf(bus_id, XEN_BUS_ID_SIZE, "%.*s-%i-%s",
		     typelen, type, domid, devid) >= XEN_BUS_ID_SIZE)
		return -ENOSPC;
	return 0;
}
Exemplo n.º 4
0
int read_otherend_details(struct xenbus_device *xendev,
				 char *id_node, char *path_node)
{
    /* add for vmdq migrate.When the device is vmdq_vnic ,return */
	if(0 == strcmp(xendev->devicetype, VMDQ_VNIC)){
        return 0;
	}
	int err = xenbus_gather(XBT_NIL, xendev->nodename,
				id_node, "%i", &xendev->otherend_id,
				path_node, NULL, &xendev->otherend,
				NULL);
	if (err) {
		xenbus_dev_fatal(xendev, err,
				 "reading other end details from %s",
				 xendev->nodename);
		return err;
	}
	if (strlen(xendev->otherend) == 0 ||
	    !xenbus_exists(XBT_NIL, xendev->otherend, "")) {
		xenbus_dev_fatal(xendev, -ENOENT,
				 "unable to read other end from %s.  "
				 "missing or inaccessible.",
				 xendev->nodename);
		free_otherend_details(xendev);
		return -ENOENT;
	}

	return 0;
}
Exemplo n.º 5
0
static int svm_get_domid(void)
{
	int ret;
	
	//check if svm have the right to access xenstore
	ret  = xenbus_exists(XBT_NIL, "/vrv/svm/grant_table", "com");
	if(0 == ret){
		printk(KERN_ALERT "[svm]: do not have the right of xenstore!\n");
		return -1;
	}

	xenbus_scanf(XBT_NIL, "domid", "", "%d", &ret);
	xenbus_printf(XBT_NIL, "/vrv", "svm", "%d", ret);
	printk(KERN_ALERT "[svm]: domid is %d", ret);
	return ret;
}
Exemplo n.º 6
0
void xenbus_dev_changed(const char *node, struct xen_bus_type *bus)
{
	int exists, rootlen;
	struct xenbus_device *dev;
	char type[XEN_BUS_ID_SIZE];
	const char *p, *root;

	if (char_count(node, '/') < 2)
		return;

	exists = xenbus_exists(XBT_NIL, node, "");
	if (!exists) {
		xenbus_cleanup_devices(node, &bus->bus);
		return;
	}

	/* backend/<type>/... or device/<type>/... */
	p = strchr(node, '/') + 1;
	snprintf(type, XEN_BUS_ID_SIZE, "%.*s", (int)strcspn(p, "/"), p);
	type[XEN_BUS_ID_SIZE-1] = '\0';

	rootlen = strsep_len(node, '/', bus->levels);
	if (rootlen < 0)
		return;
	root = kasprintf(GFP_KERNEL, "%.*s", rootlen, node);
	if (!root)
		return;

	dev = xenbus_device_find(root, &bus->bus);
	if (!dev)
		xenbus_probe_node(bus, type, root);
	else
		put_device(&dev->dev);

	kfree(root);
}
Exemplo n.º 7
0
void net_accel_update_state(struct xenbus_device *dev, int state)
{
    struct xenbus_transaction tr;
    int err;

    DPRINTK("%s: setting accelstate to %s\n", __FUNCTION__,
            xenbus_strstate(state));

    if (xenbus_exists(XBT_NIL, dev->nodename, "")) {
        VPRINTK("%s: nodename %s\n", __FUNCTION__, dev->nodename);
again:
        err = xenbus_transaction_start(&tr);
        if (err == 0)
            err = xenbus_printf(tr, dev->nodename, "accelstate",
                                "%d", state);
        if (err != 0) {
            xenbus_transaction_end(tr, 1);
        } else {
            err = xenbus_transaction_end(tr, 0);
            if (err == -EAGAIN)
                goto again;
        }
    }
}
Exemplo n.º 8
0
static void bend_config_accel_change(struct xenbus_watch *watch,
				     const char **vec, unsigned int len)
{
	struct netback_accel *bend;

	bend = container_of(watch, struct netback_accel, config_accel_watch);

	mutex_lock(&bend->bend_mutex);
	if (bend->config_accel_watch.node != NULL) {
		struct xenbus_device *dev = 
			(struct xenbus_device *)bend->hdev_data;
		DPRINTK("Watch matched, got dev %p otherend %p\n",
			dev, dev->otherend);
		if(!xenbus_exists(XBT_NIL, watch->node, "")) {
			DPRINTK("Ignoring watch as otherend seems invalid\n");
			goto out;
		}
		
		cfg_hw_quotas(dev, bend);
	}
 out:
	mutex_unlock(&bend->bend_mutex);
	return;
}
Exemplo n.º 9
0
static int __init xencons_init(void)
{
	int rc;

	if (!is_running_on_xen())
		return -ENODEV;

	if (xc_mode == XC_OFF)
		return 0;

	if (!is_initial_xendomain()) {
		rc = xencons_ring_init();
		if (rc)
			return rc;
	}

	xencons_driver = alloc_tty_driver((xc_mode == XC_TTY) ?
					  MAX_NR_CONSOLES : 1);
	if (xencons_driver == NULL)
		return -ENOMEM;

	DRV(xencons_driver)->name            = "xencons";
	DRV(xencons_driver)->major           = TTY_MAJOR;
	DRV(xencons_driver)->type            = TTY_DRIVER_TYPE_SERIAL;
	DRV(xencons_driver)->subtype         = SERIAL_TYPE_NORMAL;
	DRV(xencons_driver)->init_termios    = tty_std_termios;
	DRV(xencons_driver)->flags           =
		TTY_DRIVER_REAL_RAW |
		TTY_DRIVER_RESET_TERMIOS |
		TTY_DRIVER_NO_DEVFS;
	DRV(xencons_driver)->termios         = xencons_termios;
	DRV(xencons_driver)->termios_locked  = xencons_termios_locked;

	switch (xc_mode) {
	case XC_XVC:
		DRV(xencons_driver)->name        = "xvc";
		DRV(xencons_driver)->major       = XEN_XVC_MAJOR;
		DRV(xencons_driver)->minor_start = XEN_XVC_MINOR;
		DRV(xencons_driver)->name_base   = xc_num;
		break;
	case XC_SERIAL:
		DRV(xencons_driver)->name        = "ttyS";
		DRV(xencons_driver)->minor_start = 64 + xc_num;
		DRV(xencons_driver)->name_base   = xc_num;
		break;
	default:
		DRV(xencons_driver)->name        = "tty";
		DRV(xencons_driver)->minor_start = 1;
		DRV(xencons_driver)->name_base   = 1;
		break;
	}

	tty_set_operations(xencons_driver, &xencons_ops);

	if ((rc = tty_register_driver(DRV(xencons_driver))) != 0) {
		printk("WARNING: Failed to register Xen virtual "
		       "console driver as '%s%d'\n",
		       DRV(xencons_driver)->name,
		       DRV(xencons_driver)->name_base);
		put_tty_driver(xencons_driver);
		xencons_driver = NULL;
		return rc;
	}

	tty_register_device(xencons_driver, 0, NULL);

	if (is_initial_xendomain()) {
		xencons_priv_irq = bind_virq_to_irqhandler(
			VIRQ_CONSOLE,
			0,
			xencons_priv_interrupt,
			0,
			"console",
			NULL);
		BUG_ON(xencons_priv_irq < 0);
	}

	printk("Xen virtual console successfully installed as %s%d\n",
	       DRV(xencons_driver)->name, xc_num);

        /* Check about framebuffer messing up the console */
        if (!is_initial_xendomain() &&
	    !xenbus_exists(XBT_NIL, "device", "vfb")) {
		/* FIXME: this is ugly */
		unregister_console(&kcons_info);
		kcons_info.flags |= CON_CONSDEV;
		register_console(&kcons_info);
	}

	return 0;
}