当前位置: 首页>>代码示例>>C++>>正文


C++ xenbus_printf函数代码示例

本文整理汇总了C++中xenbus_printf函数的典型用法代码示例。如果您正苦于以下问题:C++ xenbus_printf函数的具体用法?C++ xenbus_printf怎么用?C++ xenbus_printf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xenbus_printf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shutdown_netfront

void shutdown_netfront(struct netfront_dev *dev)
{
    char* err;
    char *nodename = dev->nodename;

    char path[strlen(dev->backend) + 1 + 5 + 1];

    printk("close network: backend at %s\n",dev->backend);

    snprintf(path, sizeof(path), "%s/state", dev->backend);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
    xenbus_wait_for_value(path, "5", &dev->events);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
    xenbus_wait_for_value(path, "6", &dev->events);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
    xenbus_wait_for_value(path, "2", &dev->events);

    xenbus_unwatch_path(XBT_NIL, path);

    snprintf(path, sizeof(path), "%s/tx-ring-ref", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/rx-ring-ref", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/event-channel", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/request-rx-copy", nodename);
    xenbus_rm(XBT_NIL, path);

    free_netfront(dev);
}
开发者ID:jinxuan,项目名称:vncos,代码行数:33,代码来源:netfront.c

示例2: shutdown_kbdfront

void shutdown_kbdfront(struct kbdfront_dev *dev)
{
    char* err;
    char *nodename = dev->nodename;

    char path[strlen(dev->backend) + 1 + 5 + 1];

    printk("close kbd: backend at %s\n",dev->backend);

    snprintf(path, sizeof(path), "%s/state", dev->backend);
    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
    xenbus_wait_for_value(path, "5", &dev->events);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
    xenbus_wait_for_value(path, "6", &dev->events);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
    // does not work yet.
    //xenbus_wait_for_value(path, "2", &dev->events);

    xenbus_unwatch_path(XBT_NIL, path);

    snprintf(path, sizeof(path), "%s/page-ref", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/event-channel", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/request-abs-pointer", nodename);
    xenbus_rm(XBT_NIL, path);

    free_kbdfront(dev);
}
开发者ID:amodj,项目名称:Utopia,代码行数:31,代码来源:fbfront.c

示例3: svm_grant_ring

static int svm_grant_ring(int arg)
{
	int ret, gnt_ref;
	struct xenbus_device dev;

	printk(KERN_ALERT "[svm]: arg is:%d\n", arg);
	dev.otherend_id = arg;

	if(NULL == vaddr){
		printk(KERN_ALERT "[svm]: wrong vaddr.\n");
		return -1;
	}

	gnt_ref = xenbus_grant_ring(&dev, virt_to_mfn(vaddr));
	if(gnt_ref < 0){
		printk(KERN_ALERT "[svm]: grant ring failed!\n");
		return -1;
	}
	
	xenbus_printf(XBT_NIL, "/vrv/svm/grant_table", "com", "pos:0 len:0");
	xenbus_printf(XBT_NIL, "/vrv/svm", "grant_table", "%d", gnt_ref);

	printk(KERN_ALERT "[svm]: grant table to %d, gnt_ref is:%d.\n", dev.otherend_id, gnt_ref);

	return 0;
}
开发者ID:xiaoyuyang,项目名称:xenbus,代码行数:26,代码来源:svm.c

示例4: shutdown_fbfront

void shutdown_fbfront(struct fbfront_dev *dev)
{
    char* err;
    char *nodename = dev->nodename;

    char path[strlen(dev->backend) + 1 + 5 + 1];

    printk("close fb: backend at %s\n",dev->backend);

    snprintf(path, sizeof(path), "%s/state", dev->backend);
    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
    xenbus_wait_for_value(path, "5", &dev->events);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
    xenbus_wait_for_value(path, "6", &dev->events);

    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
    // does not work yet
    //xenbus_wait_for_value(path, "2", &dev->events);

    xenbus_unwatch_path(XBT_NIL, path);

    snprintf(path, sizeof(path), "%s/page-ref", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/event-channel", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/protocol", nodename);
    xenbus_rm(XBT_NIL, path);
    snprintf(path, sizeof(path), "%s/feature-update", nodename);
    xenbus_rm(XBT_NIL, path);

    unbind_evtchn(dev->evtchn);

    free_fbfront(dev);
}
开发者ID:amodj,项目名称:Utopia,代码行数:35,代码来源:fbfront.c

示例5: pcifront_publish_info

static int pcifront_publish_info(struct pcifront_device *pdev)
{
	int err = 0;
	struct xenbus_transaction trans;

	err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
	if (err < 0)
		goto out;

	pdev->gnt_ref = err;

	err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
	if (err)
		goto out;

	bind_caller_port_to_irqhandler(pdev->evtchn, pcifront_handler_aer, 
		IRQF_SAMPLE_RANDOM, "pcifront", pdev);

      do_publish:
	err = xenbus_transaction_start(&trans);
	if (err) {
		xenbus_dev_fatal(pdev->xdev, err,
				 "Error writing configuration for backend "
				 "(start transaction)");
		goto out;
	}

	err = xenbus_printf(trans, pdev->xdev->nodename,
			    "pci-op-ref", "%u", pdev->gnt_ref);
	if (!err)
		err = xenbus_printf(trans, pdev->xdev->nodename,
				    "event-channel", "%u", pdev->evtchn);
	if (!err)
		err = xenbus_printf(trans, pdev->xdev->nodename,
				    "magic", XEN_PCI_MAGIC);

	if (err) {
		xenbus_transaction_end(trans, 1);
		xenbus_dev_fatal(pdev->xdev, err,
				 "Error writing configuration for backend");
		goto out;
	} else {
		err = xenbus_transaction_end(trans, 0);
		if (err == -EAGAIN)
			goto do_publish;
		else if (err) {
			xenbus_dev_fatal(pdev->xdev, err,
					 "Error completing transaction "
					 "for backend");
			goto out;
		}
	}

	xenbus_switch_state(pdev->xdev, XenbusStateInitialised);

	dev_dbg(&pdev->xdev->dev, "publishing successful!\n");

      out:
	return err;
}
开发者ID:AsadRaza,项目名称:OCTEON-Linux,代码行数:60,代码来源:xenbus.c

示例6: talk_to_backend

static int talk_to_backend(struct xenbus_device *dev,
			   struct usbfront_info *info)
{
	const char *message;
	struct xenbus_transaction xbt;
	int err;

	err = setup_rings(dev, info);
	if (err)
		goto out;

again:
	err = xenbus_transaction_start(&xbt);
	if (err) {
		xenbus_dev_fatal(dev, err, "starting transaction");
		goto destroy_ring;
	}

	err = xenbus_printf(xbt, dev->nodename, "urb-ring-ref", "%u",
			    info->urb_ring_ref);
	if (err) {
		message = "writing urb-ring-ref";
		goto abort_transaction;
	}

	err = xenbus_printf(xbt, dev->nodename, "conn-ring-ref", "%u",
			    info->conn_ring_ref);
	if (err) {
		message = "writing conn-ring-ref";
		goto abort_transaction;
	}

	err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
			    irq_to_evtchn_port(info->irq));
	if (err) {
		message = "writing event-channel";
		goto abort_transaction;
	}

	err = xenbus_transaction_end(xbt, 0);
	if (err) {
		if (err == -EAGAIN)
			goto again;
		xenbus_dev_fatal(dev, err, "completing transaction");
		goto destroy_ring;
	}

	return 0;

abort_transaction:
	xenbus_transaction_end(xbt, 1);
	xenbus_dev_fatal(dev, err, "%s", message);

destroy_ring:
	destroy_rings(info);

out:
	return err;
}
开发者ID:zhoupeng,项目名称:spice4xen,代码行数:59,代码来源:xenbus.c

示例7: talk_to_ixpback

/* Common code used when first setting up, and when resuming. */
static int talk_to_ixpback(struct xenbus_device *dev,
			   struct ixpfront_info *info)
{
	const char *message = NULL;
	struct xenbus_transaction xbt;
	int err;

	/* Create shared ring, alloc event channel. */
	err = setup_ixpring(dev, info);
	if (err)
		goto out;

again:
	err = xenbus_transaction_start(&xbt);
	if (err) {
		xenbus_dev_fatal(dev, err, "starting transaction");
		goto destroy_ixpring;
	}

	err = xenbus_printf(xbt, dev->nodename,
			    "ring-ref", "%u", info->ring_ref);
	if (err) {
		message = "writing ring-ref";
		goto abort_transaction;
	}
	err = xenbus_printf(xbt, dev->nodename,
			    "event-channel", "%u", info->evtchn);
	if (err) {
		message = "writing event-channel";
		goto abort_transaction;
	}
	err = xenbus_printf(xbt, dev->nodename, "protocol", "%s",
			    XEN_IO_PROTO_ABI_NATIVE);
	if (err) {
		message = "writing protocol";
		goto abort_transaction;
	}

	err = xenbus_transaction_end(xbt, 0);
	if (err) {
		if (err == -EAGAIN)
			goto again;
		xenbus_dev_fatal(dev, err, "completing transaction");
		goto destroy_ixpring;
	}

	xenbus_switch_state(dev, XenbusStateInitialised);

	return 0;

 abort_transaction:
	xenbus_transaction_end(xbt, 1);
	if (message)
		xenbus_dev_fatal(dev, err, "%s", message);
 destroy_ixpring:
	ixp_free(info, 0);
 out:
	return err;
}
开发者ID:kong123456,项目名称:tolapai,代码行数:60,代码来源:ixpfront.c

示例8: xen_pcibk_publish_pci_root

static int xen_pcibk_publish_pci_root(struct xen_pcibk_device *pdev,
				    unsigned int domain, unsigned int bus)
{
	unsigned int d, b;
	int i, root_num, len, err;
	char str[64];

	dev_dbg(&pdev->xdev->dev, "Publishing pci roots\n");

	err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
			   "root_num", "%d", &root_num);
	if (err == 0 || err == -ENOENT)
		root_num = 0;
	else if (err < 0)
		goto out;

	/* Verify that we haven't already published this pci root */
	for (i = 0; i < root_num; i++) {
		len = snprintf(str, sizeof(str), "root-%d", i);
		if (unlikely(len >= (sizeof(str) - 1))) {
			err = -ENOMEM;
			goto out;
		}

		err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
				   str, "%x:%x", &d, &b);
		if (err < 0)
			goto out;
		if (err != 2) {
			err = -EINVAL;
			goto out;
		}

		if (d == domain && b == bus) {
			err = 0;
			goto out;
		}
	}

	len = snprintf(str, sizeof(str), "root-%d", root_num);
	if (unlikely(len >= (sizeof(str) - 1))) {
		err = -ENOMEM;
		goto out;
	}

	dev_dbg(&pdev->xdev->dev, "writing root %d at %04x:%02x\n",
		root_num, domain, bus);

	err = xenbus_printf(XBT_NIL, pdev->xdev->nodename, str,
			    "%04x:%02x", domain, bus);
	if (err)
		goto out;

	err = xenbus_printf(XBT_NIL, pdev->xdev->nodename,
			    "root_num", "%d", (root_num + 1));

out:
	return err;
}
开发者ID:454053205,项目名称:linux,代码行数:59,代码来源:xenbus.c

示例9: connect

/**
 * Write the physical details regarding the block device to the store, and
 * switch to Connected state.
 */
static void connect(struct backend_info *be)
{
	xenbus_transaction_t xbt;
	int err;
	struct xenbus_device *dev = be->dev;

	DPRINTK("%s", dev->otherend);

	/* Supply the information about the device the frontend needs */
again:
	err = xenbus_transaction_start(&xbt);

	if (err) {
		xenbus_dev_fatal(dev, err, "starting transaction");
		return;
	}

	err = xenbus_printf(xbt, dev->nodename, "sectors", "%lu",
			    vbd_size(&be->blkif->vbd));
	if (err) {
		xenbus_dev_fatal(dev, err, "writing %s/sectors",
				 dev->nodename);
		goto abort;
	}

	/* FIXME: use a typename instead */
	err = xenbus_printf(xbt, dev->nodename, "info", "%u",
			    vbd_info(&be->blkif->vbd));
	if (err) {
		xenbus_dev_fatal(dev, err, "writing %s/info",
				 dev->nodename);
		goto abort;
	}
	err = xenbus_printf(xbt, dev->nodename, "sector-size", "%lu",
			    vbd_secsize(&be->blkif->vbd));
	if (err) {
		xenbus_dev_fatal(dev, err, "writing %s/sector-size",
				 dev->nodename);
		goto abort;
	}

	err = xenbus_transaction_end(xbt, 0);
	if (err == -EAGAIN)
		goto again;
	if (err)
		xenbus_dev_fatal(dev, err, "ending transaction");

	err = xenbus_switch_state(dev, XenbusStateConnected);
	if (err)
		xenbus_dev_fatal(dev, err, "switching to Connected state",
				 dev->nodename);

	return;
 abort:
	xenbus_transaction_end(xbt, 1);
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:60,代码来源:xenbus.c

示例10: publish_frontend_name

static int publish_frontend_name(struct xenbus_device *dev)
{
	struct xenbus_transaction tr;
	int err;
	
	/* Publish the name of the frontend driver */
	do {
		err = xenbus_transaction_start(&tr);
		if (err != 0) { 
			EPRINTK("%s: transaction start failed\n", __FUNCTION__);
			return err;
		}
		err = xenbus_printf(tr, dev->nodename, "accel-frontend", 
				    "%s", frontend_name);
		if (err != 0) {
			EPRINTK("%s: xenbus_printf failed\n", __FUNCTION__);
			xenbus_transaction_end(tr, 1);
			return err;
		}
		err = xenbus_transaction_end(tr, 0);
	} while (err == -EAGAIN);
	
	if (err != 0) {
		EPRINTK("failed to end frontend name transaction\n");
		return err;
	}
	return 0;
}
开发者ID:zhoupeng,项目名称:spice4xen,代码行数:28,代码来源:accel_xenbus.c

示例11: xpv_attach

static int
xpv_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
	if (cmd != DDI_ATTACH)
		return (DDI_FAILURE);

	if (ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR,
	    ddi_get_instance(dip), DDI_PSEUDO, 0) != DDI_SUCCESS)
		return (DDI_FAILURE);

	xpv_dip = dip;

	if (xpv_drv_init() != 0)
		return (DDI_FAILURE);

	ddi_report_dev(dip);

	/*
	 * If the memscrubber attempts to scrub the pages we hand to Xen,
	 * the domain will panic.
	 */
	memscrub_disable();

	/*
	 * Report our version to dom0.
	 */
	if (xenbus_printf(XBT_NULL, "guest/xpv", "version", "%d",
	    HVMPV_XPV_VERS))
		cmn_err(CE_WARN, "xpv: couldn't write version\n");

	return (DDI_SUCCESS);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:32,代码来源:xpv_support.c

示例12: sysrq_handler

static void sysrq_handler(struct xenbus_watch *watch, const char *path,
			  const char *token)
{
	char sysrq_key = '\0';
	struct xenbus_transaction xbt;
	int err;

 again:
	err = xenbus_transaction_start(&xbt);
	if (err)
		return;
	err = xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key);
	if (err < 0) {
		/*
		 * The Xenstore watch fires directly after registering it and
		 * after a suspend/resume cycle. So ENOENT is no error but
		 * might happen in those cases.
		 */
		if (err != -ENOENT)
			pr_err("Error %d reading sysrq code in control/sysrq\n",
			       err);
		xenbus_transaction_end(xbt, 1);
		return;
	}

	if (sysrq_key != '\0')
		xenbus_printf(xbt, "control", "sysrq", "%c", '\0');

	err = xenbus_transaction_end(xbt, 0);
	if (err == -EAGAIN)
		goto again;

	if (sysrq_key != '\0')
		handle_sysrq(sysrq_key);
}
开发者ID:mdamt,项目名称:linux,代码行数:35,代码来源:manage.c

示例13: setup_shutdown_watcher

static int setup_shutdown_watcher(void)
{
	int err;
	int idx;
#define FEATURE_PATH_SIZE (SHUTDOWN_CMD_SIZE + sizeof("feature-"))
	char node[FEATURE_PATH_SIZE];

	err = register_xenbus_watch(&shutdown_watch);
	if (err) {
		pr_err("Failed to set shutdown watcher\n");
		return err;
	}


#ifdef CONFIG_MAGIC_SYSRQ
	err = register_xenbus_watch(&sysrq_watch);
	if (err) {
		pr_err("Failed to set sysrq watcher\n");
		return err;
	}
#endif

	for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
		if (!shutdown_handlers[idx].flag)
			continue;
		snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
			 shutdown_handlers[idx].command);
		xenbus_printf(XBT_NIL, "control", node, "%u", 1);
	}

	return 0;
}
开发者ID:mdamt,项目名称:linux,代码行数:32,代码来源:manage.c

示例14: XenLowerInterfaceVersion

ULONG
XenLowerInterfaceVersion(
    PXEN_LOWER XenLower)
{
    NTSTATUS status;
    PCHAR vstr;
    int version;

	vstr = XenLowerReadXenstoreValue(XenLower->BackendPath, "version");
    if (vstr == NULL)
    {
        TraceError((__FUNCTION__\
            ": XenLowerReadXenstoreValue() failed to return the vusb version.\n"));
        return 0;
    }

    sscanf_s(vstr, "%d", &version);
    XmFreeMemory(vstr);

    // Need to now write the version we support to the frontend
    status = xenbus_printf(XBT_NIL, XenLower->FrontendPath,
        "version", "%d", XEN_LOWER_INTERFACE_VERSION);
    if (!NT_SUCCESS(status))
    {
        TraceError((__FUNCTION__\
            ": xenbus_printf(frontend/version) failed.\n"));
        return 0;
    }

    TraceInfo((__FUNCTION__
        ": Read backend version: %d  -  Wrote frontend version: %d\n",
        version, XEN_LOWER_INTERFACE_VERSION));

    return (ULONG)version;
}
开发者ID:OpenXT,项目名称:xc-vusb,代码行数:35,代码来源:xenlower.cpp

示例15: xenkbd_backend_changed

static void xenkbd_backend_changed(struct xenbus_device *dev,
				   enum xenbus_state backend_state)
{
	struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
	int ret, val;

	switch (backend_state) {
	case XenbusStateInitialising:
	case XenbusStateInitialised:
	case XenbusStateReconfiguring:
	case XenbusStateReconfigured:
	case XenbusStateUnknown:
		break;

	case XenbusStateInitWait:
InitWait:
		ret = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
				   "feature-abs-pointer", "%d", &val);
		if (ret < 0)
			val = 0;
		if (val) {
			ret = xenbus_printf(XBT_NIL, info->xbdev->nodename,
					    "request-abs-pointer", "1");
			if (ret)
				pr_warning("xenkbd: can't request abs-pointer");
		}

		xenbus_switch_state(dev, XenbusStateConnected);
		break;

	case XenbusStateConnected:
		/*
		 * Work around xenbus race condition: If backend goes
		 * through InitWait to Connected fast enough, we can
		 * get Connected twice here.
		 */
		if (dev->state != XenbusStateConnected)
			goto InitWait; /* no InitWait seen yet, fudge it */

		/* Set input abs params to match backend screen res */
		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
				 "width", "%d", &val) > 0)
			input_set_abs_params(info->ptr, ABS_X, 0, val, 0, 0);

		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
				 "height", "%d", &val) > 0)
			input_set_abs_params(info->ptr, ABS_Y, 0, val, 0, 0);

		break;

	case XenbusStateClosed:
		if (dev->state == XenbusStateClosed)
			break;
		/* Missed the backend's CLOSING state -- fallthrough */
	case XenbusStateClosing:
		xenbus_frontend_closed(dev);
		break;
	}
}
开发者ID:168519,项目名称:linux,代码行数:59,代码来源:xen-kbdfront.c


注:本文中的xenbus_printf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。