本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}