FreeBSD xen subsystem code
xenbusvar.h File Reference

Datastructures and function declarations for usedby device drivers operating on the XenBus. More...

#include <sys/queue.h>
#include <sys/bus.h>
#include <sys/eventhandler.h>
#include <sys/malloc.h>
#include <sys/sbuf.h>
#include <machine/stdarg.h>
#include <xen/xen-os.h>
#include <contrib/xen/grant_table.h>
#include <contrib/xen/io/xenbus.h>
#include <contrib/xen/io/xs_wire.h>
#include <xen/xenstore/xenstorevar.h>
#include "xenbus_if.h"
Include dependency graph for xenbusvar.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XENBUS_ACCESSOR(var, ivar, type)    __BUS_ACCESSOR(xenbus, var, XENBUS, ivar, type)
 

Enumerations

enum  {
  XENBUS_IVAR_NODE , XENBUS_IVAR_TYPE , XENBUS_IVAR_STATE , XENBUS_IVAR_OTHEREND_ID ,
  XENBUS_IVAR_OTHEREND_PATH
}
 

Functions

 MALLOC_DECLARE (M_XENBUS)
 
XenbusState xenbus_read_driver_state (const char *path)
 
static XenbusState xenbus_get_otherend_state (device_t dev)
 
int xenbus_grant_ring (device_t dev, unsigned long ring_mfn, grant_ref_t *refp)
 
void xenbus_dev_error (device_t dev, int err, const char *fmt,...) __attribute__((format(printf
 
void void xenbus_dev_verror (device_t dev, int err, const char *fmt, va_list ap) __attribute__((format(printf
 
void void void xenbus_dev_fatal (device_t dev, int err, const char *fmt,...) __attribute__((format(printf
 
void void void void xenbus_dev_vfatal (device_t dev, int err, const char *fmt, va_list) __attribute__((format(printf
 
void void void void const char * xenbus_strstate (enum xenbus_state state)
 
int xenbus_dev_is_online (device_t dev)
 
void xenbus_localend_changed (device_t dev, const char *path)
 

Detailed Description

Datastructures and function declarations for usedby device drivers operating on the XenBus.

Definition in file xenbusvar.h.

Macro Definition Documentation

◆ XENBUS_ACCESSOR

#define XENBUS_ACCESSOR (   var,
  ivar,
  type 
)     __BUS_ACCESSOR(xenbus, var, XENBUS, ivar, type)

Simplified accessors for xenbus devices:

xenbus_get_node xenbus_get_type xenbus_get_state xenbus_get_otherend_id xenbus_get_otherend_path

Definition at line 93 of file xenbusvar.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
XENBUS_IVAR_NODE 

Path of this device node.

XENBUS_IVAR_TYPE 

The device type (e.g. vif, vbd).

XENBUS_IVAR_STATE 

The state of this device (not the otherend's state).

XENBUS_IVAR_OTHEREND_ID 

Domain ID of the other end device.

XENBUS_IVAR_OTHEREND_PATH 

Path of the other end device.

Definition at line 57 of file xenbusvar.h.

Function Documentation

◆ xenbus_dev_error()

void xenbus_dev_error ( device_t  dev,
int  err,
const char *  fmt,
  ... 
)

Record the given errno, along with the given, printf-style, formatted message in dev's device specific error node in the XenStore.

Parameters
devThe device which encountered the error.
errThe errno value corresponding to the error.
fmtPrintf format string followed by a variable number of printf arguments.

◆ xenbus_dev_fatal()

void void void xenbus_dev_fatal ( device_t  dev,
int  err,
const char *  fmt,
  ... 
)

Equivalent to xenbus_dev_error(), followed by xenbus_set_state(dev, XenbusStateClosing).

Parameters
devThe device which encountered the error.
errThe errno value corresponding to the error.
fmtPrintf format string followed by a variable number of printf arguments.

Referenced by xenbus_grant_ring(), and xenbusb_write_ivar().

Here is the caller graph for this function:

◆ xenbus_dev_is_online()

int xenbus_dev_is_online ( device_t  dev)

Return the value of a XenBus device's "online" node within the XenStore.

Parameters
devThe XenBus device to query.
Returns
The value of the "online" node for the device. If the node does not exist, 0 (offline) is returned.

Definition at line 198 of file xenbus.c.

Referenced by xenbusb_back_localend_changed(), and xenbusb_back_otherend_changed().

Here is the caller graph for this function:

◆ xenbus_dev_verror()

void void xenbus_dev_verror ( device_t  dev,
int  err,
const char *  fmt,
va_list  ap 
)

va_list version of xenbus_dev_error().

Parameters
devThe device which encountered the error.
errThe errno value corresponding to the error.
fmtPrintf format string.
apVa_list of printf arguments.

◆ xenbus_dev_vfatal()

void void void void xenbus_dev_vfatal ( device_t  dev,
int  err,
const char *  fmt,
va_list   
)

va_list version of xenbus_dev_fatal().

Parameters
devThe device which encountered the error.
errThe errno value corresponding to the error.
fmtPrintf format string.
apVa_list of printf arguments.

◆ xenbus_get_otherend_state()

static XenbusState xenbus_get_otherend_state ( device_t  dev)
inlinestatic

Return the state of the "other end" (peer) of a XenBus device.

Parameters
devThe XenBus device whose peer to query.
Returns
The current state of the peer device or XenbusStateClosed if no state can be read.

Definition at line 121 of file xenbusvar.h.

References xenbus_read_driver_state().

Here is the call graph for this function:

◆ xenbus_grant_ring()

int xenbus_grant_ring ( device_t  dev,
unsigned long  ring_mfn,
grant_ref_t *  refp 
)

Grant access to the given ring_mfn to the peer of the given device.

Parameters
devThe device granting access to the ring page.
ring_mfnThe guest machine page number of the page to grant peer access rights.
refp[out]The grant reference for the page.
Returns
On success, 0. Otherwise an errno value indicating the type of failure.

A successful call to xenbus_grant_ring should be paired with a call to gnttab_end_foreign_access() when foregn access to this page is no longer requried.

Note
On error, dev will be switched to the XenbusStateClosing state and the returned error is saved in the per-device error node for dev in the XenStore.

Definition at line 170 of file xenbus.c.

References xenbus_dev_fatal().

Here is the call graph for this function:

◆ xenbus_localend_changed()

void xenbus_localend_changed ( device_t  dev,
const char *  path 
)

Default callback invoked when a change to the local XenStore sub-tree for a device is modified.

Parameters
devThe XenBus device whose tree was modified.
pathThe tree relative sub-path to the modified node. The empty string indicates the root of the tree was destroyed.

Definition at line 215 of file xenbus.c.

◆ xenbus_read_driver_state()

XenbusState xenbus_read_driver_state ( const char *  path)

Return the state of a XenBus device.

Parameters
pathThe root XenStore path for the device.
Returns
The current state of the device or XenbusStateClosed if no state can be read.

Definition at line 185 of file xenbus.c.

Referenced by xenbus_get_otherend_state(), xenbusb_add_device(), xenbusb_localend_changed(), and xenbusb_otherend_watch_cb().

Here is the caller graph for this function:

◆ xenbus_strstate()

void void void void const char * xenbus_strstate ( enum xenbus_state  state)

Convert a member of the xenbus_state enum into an ASCII string.

/param state The XenBus state to lookup.

/return A string representing state or, for unrecognized states, the string "Unknown".

Referenced by xenbusb_device_sysctl_handler().

Here is the caller graph for this function: