本文整理汇总了C++中xenbus_dev_fatal函数的典型用法代码示例。如果您正苦于以下问题:C++ xenbus_dev_fatal函数的具体用法?C++ xenbus_dev_fatal怎么用?C++ xenbus_dev_fatal使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xenbus_dev_fatal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect
static void connect(struct backend_info *be)
{
int err;
struct xenbus_device *dev = be->dev;
rtnl_lock();
err = xen_net_read_mac(dev, be->netif->fe_dev_addr);
if (err) {
xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
goto out;
}
xen_net_read_rate(dev, &be->netif->credit_bytes,
&be->netif->credit_usec);
be->netif->remaining_credit = be->netif->credit_bytes;
err = connect_rings(be);
if (err)
goto out;
/* May not get a kick from the frontend, so start the tx_queue now. */
if (!netbk_can_queue(be->netif->dev))
netif_wake_queue(be->netif->dev);
out:
rtnl_unlock();
}
示例2: tpmfront_probe
static int tpmfront_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
struct tpm_private *priv;
int rv;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating priv structure");
return -ENOMEM;
}
rv = setup_chip(&dev->dev, priv);
if (rv) {
kfree(priv);
return rv;
}
rv = setup_ring(dev, priv);
if (rv) {
tpm_remove_hardware(&dev->dev);
ring_free(priv);
return rv;
}
tpm_get_timeouts(priv->chip);
dev_set_drvdata(&dev->dev, priv->chip);
return rv;
}
示例3: backend_changed
static void backend_changed(struct xenbus_device *dev,
enum xenbus_state backend_state)
{
int val;
switch (backend_state) {
case XenbusStateInitialised:
case XenbusStateConnected:
if (dev->state == XenbusStateConnected)
break;
if (xenbus_scanf(XBT_NIL, dev->otherend,
"feature-protocol-v2", "%d", &val) < 0)
val = 0;
if (!val) {
xenbus_dev_fatal(dev, -EINVAL,
"vTPM protocol 2 required");
return;
}
xenbus_switch_state(dev, XenbusStateConnected);
break;
case XenbusStateClosing:
case XenbusStateClosed:
device_unregister(&dev->dev);
xenbus_frontend_closed(dev);
break;
default:
break;
}
}
示例4: netback_uevent
/**
* Handle the creation of the hotplug script environment. We add the script
* and vif variables to the environment, for the benefit of the vif-* hotplug
* scripts.
*/
static int netback_uevent(struct xenbus_device *xdev, char **envp,
int num_envp, char *buffer, int buffer_size)
{
struct backend_info *be = xdev->dev.driver_data;
netif_t *netif = be->netif;
int i = 0, length = 0;
char *val;
DPRINTK("netback_uevent");
val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
if (IS_ERR(val)) {
int err = PTR_ERR(val);
xenbus_dev_fatal(xdev, err, "reading script");
return err;
}
else {
add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
&length, "script=%s", val);
kfree(val);
}
add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
"vif=%s", netif->dev->name);
envp[i] = NULL;
return 0;
}
示例5: frontend_changed
/*
* Callback received when the frontend's state changes.
*/
static void frontend_changed(struct xenbus_device *dev,
enum xenbus_state frontend_state)
{
struct backend_info *be = dev_get_drvdata(&dev->dev);
int err;
DPRINTK("%s", xenbus_strstate(frontend_state));
switch (frontend_state) {
case XenbusStateInitialising:
if (dev->state == XenbusStateClosed) {
pr_info(DRV_PFX "%s: prepare for reconnect\n",
dev->nodename);
xenbus_switch_state(dev, XenbusStateInitWait);
}
break;
case XenbusStateInitialised:
case XenbusStateConnected:
/*
* Ensure we connect even when two watches fire in
* close succession and we miss the intermediate value
* of frontend_state.
*/
if (dev->state == XenbusStateConnected)
break;
/*
* Enforce precondition before potential leak point.
* xen_blkif_disconnect() is idempotent.
*/
xen_blkif_disconnect(be->blkif);
err = connect_ring(be);
if (err)
break;
xen_update_blkif_status(be->blkif);
break;
case XenbusStateClosing:
xenbus_switch_state(dev, XenbusStateClosing);
break;
case XenbusStateClosed:
xen_blkif_disconnect(be->blkif);
xenbus_switch_state(dev, XenbusStateClosed);
if (xenbus_dev_is_online(dev))
break;
/* fall through if not online */
case XenbusStateUnknown:
/* implies xen_blkif_disconnect() via xen_blkbk_remove() */
device_unregister(&dev->dev);
break;
default:
xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
frontend_state);
break;
}
}
示例6: xen_pcibk_xenbus_probe
static int xen_pcibk_xenbus_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
int err = 0;
struct xen_pcibk_device *pdev = alloc_pdev(dev);
if (pdev == NULL) {
err = -ENOMEM;
xenbus_dev_fatal(dev, err,
"Error allocating xen_pcibk_device struct");
goto out;
}
/* wait for xend to configure us */
err = xenbus_switch_state(dev, XenbusStateInitWait);
if (err)
goto out;
/* watch the backend node for backend configuration information */
err = xenbus_watch_path(dev, dev->nodename, &pdev->be_watch,
xen_pcibk_be_watch);
if (err)
goto out;
pdev->be_watching = 1;
/* We need to force a call to our callback here in case
* xend already configured us!
*/
xen_pcibk_be_watch(&pdev->be_watch, NULL, 0);
out:
return err;
}
示例7: connect_ring
static int connect_ring(struct backend_info *be)
{
struct xenbus_device *dev = be->dev;
unsigned long ring_ref;
unsigned int evtchn;
char protocol[64] = "";
int err;
DPRINTK("%s", dev->otherend);
err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu",
&ring_ref, "event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_fatal(dev, err,
"reading %s/ring-ref and event-channel",
dev->otherend);
return err;
}
be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
"%63s", protocol, NULL);
if (err)
strcpy(protocol, "unspecified, assuming native");
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_32;
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64))
be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
else {
xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
return -1;
}
pr_info(DRV_PFX "ring-ref %ld, event-channel %d, protocol %d (%s)\n",
ring_ref, evtchn, be->blkif->blk_protocol, protocol);
/* Map the shared frame, irq etc. */
err = xen_blkif_map(be->blkif, ring_ref, evtchn);
if (err) {
xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
ring_ref, evtchn);
return err;
}
return 0;
}
示例8: ixpfront_probe
/**
* Entry point to this code when a new device is created. Allocate the basic
* structures and the ring buffer for communication with the backend, and
* inform the backend of the appropriate details for those. Switch to
* Initialised state.
*/
static int ixpfront_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
int err, vdevice, i;
struct ixpfront_info *info;
/* FIXME: Use dynamic device id if this is not set. */
err = xenbus_scanf(XBT_NIL, dev->nodename,
"virtual-device", "%i", &vdevice);
if (err != 1) {
/* go looking in the extended area instead */
err = xenbus_scanf(XBT_NIL, dev->nodename, "virtual-device-ext",
"%i", &vdevice);
if (err != 1) {
xenbus_dev_fatal(dev, err, "reading virtual-device");
return err;
}
}
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure");
return -ENOMEM;
}
info->xbdev = dev;
info->vdevice = vdevice;
info->connected = IXP_STATE_DISCONNECTED;
for (i = 0; i < IXP_RING_SIZE; i++)
info->shadow[i].req.id = i+1;
info->shadow[IXP_RING_SIZE-1].req.id = 0x0fffffff;
/* Front end dir is a number, which is used as the id. */
info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0);
dev_set_drvdata(&dev->dev, info);
err = talk_to_ixpback(dev, info);
if (err) {
kfree(info);
dev_set_drvdata(&dev->dev, NULL);
return err;
}
return 0;
}
示例9: frontend_changed
/**
* Callback received when the frontend's state changes.
*/
static void frontend_changed(struct xenbus_device *dev,
enum xenbus_state frontend_state)
{
struct backend_info *be = dev_get_drvdata(&dev->dev);
pr_debug("frontend state %s", xenbus_strstate(frontend_state));
be->frontend_state = frontend_state;
switch (frontend_state) {
case XenbusStateInitialising:
if (dev->state == XenbusStateClosed) {
printk(KERN_INFO "%s: %s: prepare for reconnect\n",
__func__, dev->nodename);
xenbus_switch_state(dev, XenbusStateInitWait);
}
break;
case XenbusStateInitialised:
break;
case XenbusStateConnected:
if (dev->state == XenbusStateConnected)
break;
backend_create_xenvif(be);
if (be->vif)
connect(be);
#ifdef DNP_XEN
be->vif->assigned_dnpVF_ID = -1;
be->vif->dnp_net_device = NULL;
register_vif(be->vif);
//Below only need if I want to start with bridge
//switch_vif_netif(be->vif->domid,1);
#endif
break;
case XenbusStateClosing:
if (be->vif)
kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
disconnect_backend(dev);
xenbus_switch_state(dev, XenbusStateClosing);
break;
case XenbusStateClosed:
xenbus_switch_state(dev, XenbusStateClosed);
if (xenbus_dev_is_online(dev))
break;
/* fall through if not online */
case XenbusStateUnknown:
device_unregister(&dev->dev);
break;
default:
xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
frontend_state);
break;
}
}
示例10: xenkbd_connect_backend
static int xenkbd_connect_backend(struct xenbus_device *dev,
struct xenkbd_info *info)
{
int ret;
struct xenbus_transaction xbt;
ret = bind_listening_port_to_irqhandler(
dev->otherend_id, input_handler, 0, "xenkbd", info);
if (ret < 0) {
xenbus_dev_fatal(dev, ret,
"bind_listening_port_to_irqhandler");
return ret;
}
info->irq = ret;
again:
ret = xenbus_transaction_start(&xbt);
if (ret) {
xenbus_dev_fatal(dev, ret, "starting transaction");
return ret;
}
ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
virt_to_mfn(info->page));
if (ret)
goto error_xenbus;
ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
irq_to_evtchn_port(info->irq));
if (ret)
goto error_xenbus;
ret = xenbus_transaction_end(xbt, 0);
if (ret) {
if (ret == -EAGAIN)
goto again;
xenbus_dev_fatal(dev, ret, "completing transaction");
return ret;
}
xenbus_switch_state(dev, XenbusStateInitialised);
return 0;
error_xenbus:
xenbus_transaction_end(xbt, 1);
xenbus_dev_fatal(dev, ret, "writing xenstore");
return ret;
}
示例11: setup_ixpring
static int setup_ixpring(struct xenbus_device *dev,
struct ixpfront_info *info)
{
struct ixp_sring *sring;
int err;
info->ring_ref = GRANT_INVALID_REF;
sring = (struct ixp_sring *)__get_free_page(GFP_NOIO | __GFP_HIGH);
if (!sring) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
return -ENOMEM;
}
SHARED_RING_INIT(sring);
FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
if (err < 0) {
free_page((unsigned long)sring);
info->ring.sring = NULL;
goto fail;
}
info->ring_ref = err;
err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err)
goto fail;
err = bind_evtchn_to_irqhandler(info->evtchn,
ixp_interrupt,
IRQF_SAMPLE_RANDOM, "ixp", info);
if (err <= 0) {
xenbus_dev_fatal(dev, err,
"bind_evtchn_to_irqhandler failed");
goto fail;
}
info->irq = err;
return 0;
fail:
ixp_free(info, 0);
return err;
}
示例12: xen_blkbk_probe
/*
* Entry point to this code when a new device is created. Allocate the basic
* structures, and watch the store waiting for the hotplug scripts to tell us
* the device's physical major and minor numbers. Switch to InitWait.
*/
static int xen_blkbk_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
int err;
struct backend_info *be = kzalloc(sizeof(struct backend_info),
GFP_KERNEL);
if (!be) {
xenbus_dev_fatal(dev, -ENOMEM,
"allocating backend structure");
return -ENOMEM;
}
be->dev = dev;
dev_set_drvdata(&dev->dev, be);
be->blkif = xen_blkif_alloc(dev->otherend_id);
if (IS_ERR(be->blkif)) {
err = PTR_ERR(be->blkif);
be->blkif = NULL;
xenbus_dev_fatal(dev, err, "creating block interface");
goto fail;
}
/* setup back pointer */
be->blkif->be = be;
err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed,
"%s/%s", dev->nodename, "physical-device");
if (err)
goto fail;
err = xenbus_switch_state(dev, XenbusStateInitWait);
if (err)
goto fail;
return 0;
fail:
DPRINTK("failed");
xen_blkbk_remove(dev);
return err;
}
示例13: connect_ctrl_ring
static int connect_ctrl_ring(struct backend_info *be)
{
struct xenbus_device *dev = be->dev;
struct xenvif *vif = be->vif;
unsigned int val;
grant_ref_t ring_ref;
unsigned int evtchn;
int err;
err = xenbus_gather(XBT_NIL, dev->otherend,
"ctrl-ring-ref", "%u", &val, NULL);
if (err)
goto done; /* The frontend does not have a control ring */
ring_ref = val;
err = xenbus_gather(XBT_NIL, dev->otherend,
"event-channel-ctrl", "%u", &val, NULL);
if (err) {
xenbus_dev_fatal(dev, err,
"reading %s/event-channel-ctrl",
dev->otherend);
goto fail;
}
evtchn = val;
err = xenvif_connect_ctrl(vif, ring_ref, evtchn);
if (err) {
xenbus_dev_fatal(dev, err,
"mapping shared-frame %u port %u",
ring_ref, evtchn);
goto fail;
}
done:
return 0;
fail:
return err;
}
示例14: frontend_changed
static void frontend_changed(struct xenbus_device *dev, enum xenbus_state frontend_state)
{
struct backend_info *be = dev_get_drvdata(&dev->dev);
printk("\nxen: dom0:otherend id, frontend state: %s", xenbus_strstate(frontend_state));
be->frontend_state = frontend_state;
switch(frontend_state){
case XenbusStateInitialising:{
if (dev->state == XenbusStateClosed) {
printk("\nxen: dom0: %s prepare for reconnect", dev->nodename);
xenbus_switch_state(dev, XenbusStateInitWait);
}
printk("\nxen: dom0: state changed to XenbusStateInitialising");
break;
}
case XenbusStateInitialised:
printk("\nxen: dom0: front state is XenbusStateInitiallised");
if(be->chrif)
connect(be);
xen_chrif_thread(be->chrif);
break;
case XenbusStateConnected:
// if (dev->state == XenbusStateConnected)
// break;
//map page here
printk("\nxen: dom0: front state XenbusStateConnected");
break;
case XenbusStateClosing:
xenbus_switch_state(dev, XenbusStateClosing);
printk("\nxen: dom0: state changed to XenbusStateClosing");
break;
case XenbusStateClosed:
//xen_chrif_disconnect(be->chrif);
xenbus_switch_state(dev, XenbusStateClosed);
printk("\nxen: dom0: state changed to XenbusStateClosed");
if (xenbus_dev_is_online(dev))
break;
case XenbusStateUnknown:
//device_unregister(&dev->dev);
printk("\nxen: dom0: state Unknown");
break;
default:
xenbus_dev_fatal(dev, -EINVAL, "default saw state %d at frontend", frontend_state);
break;
}
}
示例15: frontend_changed
/**
* Callback received when the frontend's state changes.
*/
static void frontend_changed(struct xenbus_device *dev,
enum xenbus_state frontend_state)
{
struct backend_info *be = dev->dev.driver_data;
DPRINTK("%s", xenbus_strstate(frontend_state));
be->frontend_state = frontend_state;
switch (frontend_state) {
case XenbusStateInitialising:
if (dev->state == XenbusStateClosed) {
printk("%s: %s: prepare for reconnect\n",
__FUNCTION__, dev->nodename);
if (be->netif) {
netif_disconnect(be->netif);
be->netif = NULL;
}
xenbus_switch_state(dev, XenbusStateInitWait);
}
break;
case XenbusStateInitialised:
break;
case XenbusStateConnected:
backend_create_netif(be);
if (be->netif)
connect(be);
break;
case XenbusStateClosing:
xenbus_switch_state(dev, XenbusStateClosing);
break;
case XenbusStateClosed:
xenbus_switch_state(dev, XenbusStateClosed);
if (xenbus_dev_is_online(dev))
break;
/* fall through if not online */
case XenbusStateUnknown:
if (be->netif != NULL)
kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
device_unregister(&dev->dev);
break;
default:
xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
frontend_state);
break;
}
}