FreeBSD xen subsystem code
xenbus.c File Reference

Client-facing interface for the Xenbus driver. More...

#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/types.h>
#include <sys/malloc.h>
#include <sys/libkern.h>
#include <sys/sbuf.h>
#include <xen/xen-os.h>
#include <xen/hypervisor.h>
#include <xen/evtchn.h>
#include <xen/gnttab.h>
#include <xen/xenbus/xenbusvar.h>
#include <machine/stdarg.h>
Include dependency graph for xenbus.c:

Go to the source code of this file.

Macros

#define DPRINTK(fmt, args...)   ((void)0)
 
#define PRINTF_BUFFER_SIZE   4096
 

Functions

 __FBSDID ("$FreeBSD$")
 
 MALLOC_DEFINE (M_XENBUS, "xenbus", "XenBus Support")
 
static char * error_path (device_t dev)
 Construct the error path corresponding to the given XenBus device. More...
 
const char * xenbus_strstate (XenbusState state)
 
void xenbus_dev_verror (device_t dev, int err, const char *fmt, va_list ap)
 
void xenbus_dev_error (device_t dev, int err, const char *fmt,...)
 
void xenbus_dev_vfatal (device_t dev, int err, const char *fmt, va_list ap)
 
void xenbus_dev_fatal (device_t dev, int err, const char *fmt,...)
 
int xenbus_grant_ring (device_t dev, unsigned long ring_mfn, grant_ref_t *refp)
 
XenbusState xenbus_read_driver_state (const char *path)
 
int xenbus_dev_is_online (device_t dev)
 
void xenbus_localend_changed (device_t dev, const char *path)
 

Detailed Description

Client-facing interface for the Xenbus driver.

In other words, the interface between the Xenbus and the device-specific code, be it the frontend or the backend of that driver.

Definition in file xenbus.c.

Macro Definition Documentation

◆ DPRINTK

#define DPRINTK (   fmt,
  args... 
)    ((void)0)

Definition at line 39 of file xenbus.c.

Function Documentation

◆ error_path()

static char * error_path ( device_t  dev)
static

Construct the error path corresponding to the given XenBus device.

Parameters
devThe XenBus device for which we are constructing an error path.
Returns
On success, the contructed error path. Otherwise NULL.

It is the caller's responsibility to free any returned error path node using the M_XENBUS malloc type.

Definition at line 76 of file xenbus.c.

◆ xenbus_dev_error()

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

Definition at line 142 of file xenbus.c.

◆ xenbus_dev_fatal()

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

Definition at line 160 of file xenbus.c.

◆ 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 xenbus_dev_verror ( device_t  dev,
int  err,
const char *  fmt,
va_list  ap 
)

Definition at line 106 of file xenbus.c.

◆ xenbus_dev_vfatal()

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

Definition at line 152 of file xenbus.c.

◆ 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()

const char * xenbus_strstate ( XenbusState  state)

Definition at line 90 of file xenbus.c.