FreeBSD kernel /amd64 XEN device code
xenstore.c File Reference

XenStore interface. More...

#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/sx.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/unistd.h>
#include <sys/queue.h>
#include <sys/taskqueue.h>
#include <machine/stdarg.h>
#include <xen/xen-os.h>
#include <xen/hypervisor.h>
#include <xen/xen_intr.h>
#include <contrib/xen/hvm/params.h>
#include <xen/hvm.h>
#include <xen/xenstore/xenstorevar.h>
#include <xen/xenstore/xenstore_internal.h>
#include <vm/vm.h>
#include <vm/pmap.h>
Include dependency graph for xenstore.c:

Go to the source code of this file.

Data Structures

struct  xs_stored_msg
 
struct  xs_softc
 

Macros

#define xsd_error_count   (sizeof(xsd_errors) / sizeof(xsd_errors[0]))
 

Functions

 __FBSDID ("$FreeBSD$")
 
static struct xs_watchfind_watch (const char *token)
 
 MALLOC_DEFINE (M_XENSTORE, "xenstore", "XenStore data and results")
 
 TAILQ_HEAD (xs_stored_msg_list, xs_stored_msg)
 
static u_int extract_strings (const char *strings, const char **dest, u_int len)
 
static const char ** split (char *strings, u_int len, u_int *num)
 
struct sbuf * xs_join (const char *dir, const char *name)
 
static void xs_intr (void *arg __unused)
 
static int xs_check_indexes (XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod)
 
static void * xs_get_output_chunk (XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod, char *buf, uint32_t *len)
 
static const void * xs_get_input_chunk (XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod, const char *buf, uint32_t *len)
 
static int xs_write_store (const void *tdata, unsigned len)
 
static int xs_read_store (void *tdata, unsigned len)
 
static int xs_process_msg (enum xsd_sockmsg_type *type)
 
static void xs_rcv_thread (void *arg __unused)
 
static int xs_get_error (const char *errorstring)
 
static int xs_read_reply (enum xsd_sockmsg_type *type, u_int *len, void **result)
 
int xs_dev_request_and_reply (struct xsd_sockmsg *msg, void **result)
 
static int xs_talkv (struct xs_transaction t, enum xsd_sockmsg_type request_type, const struct iovec *iovec, u_int num_vecs, u_int *len, void **result)
 
static int xs_single (struct xs_transaction t, enum xsd_sockmsg_type request_type, const char *body, u_int *len, void **result)
 
static int xs_watch (const char *path, const char *token)
 
static int xs_unwatch (const char *path, const char *token)
 
static void xenwatch_thread (void *unused)
 
static int xs_init_comms (void)
 
static void xs_identify (driver_t *driver, device_t parent)
 
static int xs_probe (device_t dev)
 
static void xs_attach_deferred (void *arg)
 
static void xs_attach_late (void *arg, int pending)
 
static int xs_attach (device_t dev)
 
static int xs_suspend (device_t dev)
 
static int xs_resume (device_t dev __unused)
 
 DEFINE_CLASS_0 (xenstore, xenstore_driver, xenstore_methods, 0)
 
 DRIVER_MODULE (xenstore, xenpv, xenstore_driver, xenstore_devclass, 0, 0)
 
 SYSCTL_NODE (_dev, OID_AUTO, xen, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "Xen")
 
 SYSCTL_INT (_dev_xen, OID_AUTO, xsd_port, CTLFLAG_RD, &xs.evtchn, 0, "")
 
 SYSCTL_ULONG (_dev_xen, OID_AUTO, xsd_kva, CTLFLAG_RD,(u_long *) &xen_store, 0, "")
 
bool xs_initialized (void)
 
evtchn_port_t xs_evtchn (void)
 
vm_paddr_t xs_address (void)
 
int xs_directory (struct xs_transaction t, const char *dir, const char *node, u_int *num, const char ***result)
 
int xs_exists (struct xs_transaction t, const char *dir, const char *node)
 
int xs_read (struct xs_transaction t, const char *dir, const char *node, u_int *len, void **result)
 
int xs_write (struct xs_transaction t, const char *dir, const char *node, const char *string)
 
int xs_mkdir (struct xs_transaction t, const char *dir, const char *node)
 
int xs_rm (struct xs_transaction t, const char *dir, const char *node)
 
int xs_rm_tree (struct xs_transaction xbt, const char *base, const char *node)
 
int xs_transaction_start (struct xs_transaction *t)
 
int xs_transaction_end (struct xs_transaction t, int abort)
 
int xs_scanf (struct xs_transaction t, const char *dir, const char *node, int *scancountp, const char *fmt,...)
 
int xs_vprintf (struct xs_transaction t, const char *dir, const char *node, const char *fmt, va_list ap)
 
int xs_printf (struct xs_transaction t, const char *dir, const char *node, const char *fmt,...)
 
int xs_gather (struct xs_transaction t, const char *dir,...)
 
int xs_register_watch (struct xs_watch *watch)
 
void xs_unregister_watch (struct xs_watch *watch)
 
void xs_lock (void)
 
void xs_unlock (void)
 

Variables

static struct xenstore_domain_interface * xen_store
 
static struct xs_softc xs
 
static device_method_t xenstore_methods []
 
static devclass_t xenstore_devclass
 

Detailed Description

XenStore interface.

The XenStore interface is a simple storage system that is a means of communicating state and configuration data between the Xen Domain 0 and the various guest domains. All configuration data other than a small amount of essential information required during the early boot process of launching a Xen aware guest, is managed using the XenStore.

The XenStore is ASCII string based, and has a structure and semantics similar to a filesystem. There are files and directories, the directories able to contain files or other directories. The depth of the hierarchy is only limited by the XenStore's maximum path length.

The communication channel between the XenStore service and other domains is via two, guest specific, ring buffers in a shared memory area. One ring buffer is used for communicating in each direction. The grant table references for this shared memory are given to the guest either via the xen_start_info structure for a fully para- virtualized guest, or via HVM hypercalls for a hardware virtualized guest.

The XenStore communication relies on an event channel and thus interrupts. For this reason, the attachment of the XenStore relies on an interrupt driven configuration hook to hold off boot processing until communication with the XenStore service can be established.

Several Xen services depend on the XenStore, most notably the XenBus used to discover and manage Xen devices. These services are implemented as NewBus child attachments to a bus exported by this XenStore driver.

Definition in file xenstore.c.

Macro Definition Documentation

◆ xsd_error_count

#define xsd_error_count   (sizeof(xsd_errors) / sizeof(xsd_errors[0]))

Definition at line 705 of file xenstore.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DEFINE_CLASS_0()

DEFINE_CLASS_0 ( xenstore  ,
xenstore_driver  ,
xenstore_methods  ,
 
)

◆ DRIVER_MODULE()

DRIVER_MODULE ( xenstore  ,
xenpv  ,
xenstore_driver  ,
xenstore_devclass  ,
,
 
)

◆ extract_strings()

static u_int extract_strings ( const char *  strings,
const char **  dest,
u_int  len 
)
static

Count and optionally record pointers to a number of NUL terminated strings in a buffer.

Parameters
stringsA pointer to a contiguous buffer of NUL terminated strings.
destAn array to store pointers to each string found in strings.
lenThe length of the buffer pointed to by strings.
Returns
A count of the number of strings found.

Definition at line 273 of file xenstore.c.

Referenced by split().

Here is the caller graph for this function:

◆ find_watch()

static struct xs_watch * find_watch ( const char *  token)
static

Convert from watch token (unique identifier) to the associated internal tracking structure for this watch.

Parameters
tockenThe unique identifier for the watch to find.
Returns
A pointer to the found watch structure or NULL.

Definition at line 953 of file xenstore.c.

References xs_softc::registered_watches, xs, and xs_watch().

Referenced by xs_process_msg(), xs_register_watch(), and xs_unregister_watch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_XENSTORE  ,
"xenstore"  ,
"XenStore data and results"   
)

◆ split()

static const char ** split ( char *  strings,
u_int  len,
u_int *  num 
)
static

Convert a contiguous buffer containing a series of NUL terminated strings into an array of pointers to strings.

The returned pointer references the array of string pointers which is followed by the storage for the string data. It is the client's responsibility to free this storage.

The storage addressed by strings is free'd prior to split returning.

Parameters
stringsA pointer to a contiguous buffer of NUL terminated strings.
lenThe length of the buffer pointed to by strings.
numThe number of strings found and returned in the strings array.
Returns
An array of pointers to the strings found in the input buffer.

Definition at line 305 of file xenstore.c.

References extract_strings().

Referenced by xs_directory(), and xs_process_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSCTL_INT()

SYSCTL_INT ( _dev_xen  ,
OID_AUTO  ,
xsd_port  ,
CTLFLAG_RD  ,
&xs.  evtchn,
,
""   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( _dev  ,
OID_AUTO  ,
xen  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
"Xen"   
)

◆ SYSCTL_ULONG()

SYSCTL_ULONG ( _dev_xen  ,
OID_AUTO  ,
xsd_kva  ,
CTLFLAG_RD  ,
(u_long *) &  xen_store,
,
""   
)

◆ TAILQ_HEAD()

TAILQ_HEAD ( xs_stored_msg_list  ,
xs_stored_msg   
)

◆ xenwatch_thread()

static void xenwatch_thread ( void *  unused)
static

Thread body of the XenStore watch event dispatch thread.

Definition at line 970 of file xenstore.c.

References xs_stored_msg::u, xs_softc::watch_events, xs_softc::watch_events_lock, xs_softc::xenwatch_mutex, and xs.

Referenced by xs_attach().

Here is the caller graph for this function:

◆ xs_address()

vm_paddr_t xs_address ( void  )

Definition at line 1268 of file xenstore.c.

References xs_softc::gpfn, and xs.

Referenced by xsd_dev_mmap().

Here is the caller graph for this function:

◆ xs_attach()

static int xs_attach ( device_t  dev)
static

◆ xs_attach_deferred()

static void xs_attach_deferred ( void *  arg)
static

Definition at line 1071 of file xenstore.c.

References xs, xs_softc::xs_attachcb, and xs_softc::xs_dev.

Referenced by xs_attach().

Here is the caller graph for this function:

◆ xs_attach_late()

static void xs_attach_late ( void *  arg,
int  pending 
)
static

Definition at line 1081 of file xenstore.c.

References xs, and xs_softc::xs_dev.

Referenced by xs_attach().

Here is the caller graph for this function:

◆ xs_check_indexes()

static int xs_check_indexes ( XENSTORE_RING_IDX  cons,
XENSTORE_RING_IDX  prod 
)
static

Verify that the indexes for a ring are valid.

The difference between the producer and consumer cannot exceed the size of the ring.

Parameters
consThe consumer index for the ring to test.
prodThe producer index for the ring to test.
Return values
1If indexes are in range.
0If the indexes are out of range.

Definition at line 390 of file xenstore.c.

Referenced by xs_read_store(), and xs_write_store().

Here is the caller graph for this function:

◆ xs_dev_request_and_reply()

int xs_dev_request_and_reply ( struct xsd_sockmsg *  msg,
void **  result 
)

Pass-thru interface for XenStore access by userland processes via the XenStore device.

Reply type and length data are returned by overwriting these fields in the passed in request message.

Parameters
msgA properly formatted message to transmit to the XenStore service.
resultThe returned body of the reply.
Returns
0 on success. Otherwise an errno indicating the cause of failure.
Note
The returned result is provided in malloced storage and thus must be free'd by the caller with 'free(result, M_XENSTORE);

Definition at line 788 of file xenstore.c.

References xs_softc::request_mutex, xs, xs_read_reply(), and xs_write_store().

Referenced by xs_dev_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_directory()

int xs_directory ( struct xs_transaction  t,
const char *  dir,
const char *  node,
u_int *  num,
const char ***  result 
)

Definition at line 1275 of file xenstore.c.

References split(), xs_join(), and xs_single().

Referenced by xs_exists(), and xs_rm_tree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_evtchn()

evtchn_port_t xs_evtchn ( void  )

Definition at line 1261 of file xenstore.c.

References xs_softc::evtchn, and xs.

Referenced by xsd_dev_read().

Here is the caller graph for this function:

◆ xs_exists()

int xs_exists ( struct xs_transaction  t,
const char *  dir,
const char *  node 
)

Definition at line 1296 of file xenstore.c.

References xs_directory().

Here is the call graph for this function:

◆ xs_gather()

int xs_gather ( struct xs_transaction  t,
const char *  dir,
  ... 
)

Definition at line 1548 of file xenstore.c.

References xs_read().

Referenced by xbb_attach_cb(), xbb_collect_frontend_info(), xbd_connect(), and xnb_collect_xenstore_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_get_error()

static int xs_get_error ( const char *  errorstring)
static

Convert a XenStore error string into an errno number.

Parameters
errorstringThe error string to convert.
Returns
The errno best matching the input string.
Note
Unknown error strings are converted to EINVAL.

Definition at line 717 of file xenstore.c.

References xsd_error_count.

Referenced by xs_talkv().

Here is the caller graph for this function:

◆ xs_get_input_chunk()

static const void * xs_get_input_chunk ( XENSTORE_RING_IDX  cons,
XENSTORE_RING_IDX  prod,
const char *  buf,
uint32_t *  len 
)
static

Return a pointer to, and the length of, the contiguous data available to read from a ring buffer.

Parameters
consThe consumer index for the ring.
prodThe producer index for the ring.
bufThe base address of the ring's storage.
lenThe amount of contiguous data available to read.
Returns
A pointer to the start location of the available data.

Definition at line 430 of file xenstore.c.

References buf.

Referenced by xs_read_store().

Here is the caller graph for this function:

◆ xs_get_output_chunk()

static void * xs_get_output_chunk ( XENSTORE_RING_IDX  cons,
XENSTORE_RING_IDX  prod,
char *  buf,
uint32_t *  len 
)
static

Return a pointer to, and the length of, the contiguous free region available for output in a ring buffer.

Parameters
consThe consumer index for the ring.
prodThe producer index for the ring.
bufThe base address of the ring's storage.
lenThe amount of contiguous storage available.
Returns
A pointer to the start location of the free region.

Definition at line 408 of file xenstore.c.

References buf.

Referenced by xs_write_store().

Here is the caller graph for this function:

◆ xs_identify()

static void xs_identify ( driver_t *  driver,
device_t  parent 
)
static

Definition at line 1046 of file xenstore.c.

◆ xs_init_comms()

static int xs_init_comms ( void  )
static

Setup communication channels with the XenStore service.

Returns
On success, 0. Otherwise an errno value indicating the type of failure.

Definition at line 1020 of file xenstore.c.

References xs_softc::evtchn, xs_softc::xen_intr_handle, xen_store, xs, xs_softc::xs_dev, and xs_intr().

Referenced by xs_attach(), and xs_resume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_initialized()

bool xs_initialized ( void  )

Definition at line 1254 of file xenstore.c.

References xs_softc::initialized, and xs.

Referenced by xsd_dev_identify().

Here is the caller graph for this function:

◆ xs_intr()

static void xs_intr ( void *arg  __unused)
static

Interrupt handler for the XenStore event channel.

XenStore reads and writes block on "xen_store" for buffer space. Wakeup any blocking operations when the XenStore service has modified the queues.

Definition at line 355 of file xenstore.c.

References xs_softc::initialized, xs_softc::ring_lock, xen_store, xs, and xs_softc::xs_late_init.

Referenced by xs_init_comms().

Here is the caller graph for this function:

◆ xs_join()

struct sbuf * xs_join ( const char *  dir,
const char *  name 
)

Definition at line 331 of file xenstore.c.

Referenced by xbb_attach(), xs_directory(), xs_mkdir(), xs_read(), xs_rm(), xs_rm_tree(), and xs_write().

Here is the caller graph for this function:

◆ xs_lock()

void xs_lock ( void  )

Definition at line 1648 of file xenstore.c.

References xs_softc::request_mutex, and xs.

◆ xs_mkdir()

int xs_mkdir ( struct xs_transaction  t,
const char *  dir,
const char *  node 
)

Definition at line 1347 of file xenstore.c.

References xs_join(), and xs_single().

Here is the call graph for this function:

◆ xs_printf()

int xs_printf ( struct xs_transaction  t,
const char *  dir,
const char *  node,
const char *  fmt,
  ... 
)

Definition at line 1534 of file xenstore.c.

References xs_vprintf().

Referenced by talk_to_backend(), write_queue_xenstore_keys(), xbb_attach(), xbb_attach_disk(), xbb_attach_failed(), xbb_publish_backend_info(), xbd_alloc_ring(), xbd_initialize(), xnb_attach(), xnb_attach_failed(), and xnb_publish_backend_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_probe()

static int xs_probe ( device_t  dev)
static

Probe for the existence of the XenStore.

Parameters
dev

Definition at line 1058 of file xenstore.c.

◆ xs_process_msg()

static int xs_process_msg ( enum xsd_sockmsg_type *  type)
static

Block reading the next message from the XenStore service and process the result.

Parameters
typeThe returned type of the XenStore message received.
Returns
0 on success. Otherwise an errno value indicating the type of failure encountered.

Definition at line 628 of file xenstore.c.

References find_watch(), xs_softc::registered_watches_lock, xs_softc::reply_list, xs_softc::reply_lock, split(), xs_stored_msg::u, xs_softc::watch_events, xs_softc::watch_events_lock, xs, and xs_read_store().

Referenced by xs_rcv_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_rcv_thread()

static void xs_rcv_thread ( void *arg  __unused)
static

Thread body of the XenStore receive thread.

This thread blocks waiting for data from the XenStore service and processes and received messages.

Definition at line 691 of file xenstore.c.

References xs_process_msg().

Referenced by xs_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_read()

int xs_read ( struct xs_transaction  t,
const char *  dir,
const char *  node,
u_int *  len,
void **  result 
)

Definition at line 1309 of file xenstore.c.

References xs_join(), and xs_single().

Referenced by xbd_probe(), xctrl_on_watch_event(), xen_net_read_mac(), xnb_collect_xenstore_info(), xs_gather(), and xs_scanf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_read_reply()

static int xs_read_reply ( enum xsd_sockmsg_type *  type,
u_int *  len,
void **  result 
)
static

Block waiting for a reply to a message request.

Parameters
typeThe returned type of the reply.
lenThe returned body length of the reply.
resultThe returned body of the reply.
Returns
0 on success. Otherwise an errno indicating the cause of failure.

Definition at line 741 of file xenstore.c.

References xs_softc::reply_list, xs_softc::reply_lock, xs_stored_msg::u, and xs.

Referenced by xs_dev_request_and_reply(), and xs_talkv().

Here is the caller graph for this function:

◆ xs_read_store()

static int xs_read_store ( void *  tdata,
unsigned  len 
)
static

Receive data from the XenStore service.

Parameters
tdataA pointer to the contiguous buffer to receive the data.
lenThe amount of data to receive.
Returns
On success 0, otherwise an errno value indicating the cause of failure.
Invariant
Called from thread context.
The buffer pointed to by tdata is at least len bytes in length.
Note
xs_read does not perform any internal locking to guarantee serial access to the incoming ring buffer. However, there is only one context processing reads: xs_rcv_thread().

Definition at line 544 of file xenstore.c.

References xs_softc::ring_lock, xs_softc::xen_intr_handle, xen_store, xs, xs_check_indexes(), and xs_get_input_chunk().

Referenced by xs_process_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_register_watch()

int xs_register_watch ( struct xs_watch watch)

Definition at line 1578 of file xenstore.c.

References find_watch(), xs_softc::registered_watches, xs_softc::registered_watches_lock, xs, and xs_watch().

Referenced by xbb_attach(), xctrl_attach(), xenballoon_attach(), and xs_dev_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_resume()

static int xs_resume ( device_t dev  __unused)
static

Resume XenStore operations after this VM is resumed.

Definition at line 1192 of file xenstore.c.

References xs_softc::registered_watches, xs_softc::request_mutex, xs, xs_init_comms(), and xs_watch().

Here is the call graph for this function:

◆ xs_rm()

int xs_rm ( struct xs_transaction  t,
const char *  dir,
const char *  node 
)

Definition at line 1360 of file xenstore.c.

References xs_join(), and xs_single().

Referenced by xn_ioctl(), and xs_rm_tree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_rm_tree()

int xs_rm_tree ( struct xs_transaction  xbt,
const char *  base,
const char *  node 
)

Definition at line 1373 of file xenstore.c.

References xs_directory(), xs_join(), xs_rm(), xs_transaction_end(), and xs_transaction_start().

Here is the call graph for this function:

◆ xs_scanf()

int xs_scanf ( struct xs_transaction  t,
const char *  dir,
const char *  node,
int *  scancountp,
const char *  fmt,
  ... 
)

Definition at line 1494 of file xenstore.c.

References xs_read().

Referenced by create_netdev(), talk_to_backend(), watch_target(), xbb_collect_frontend_info(), xbd_attach(), xbd_initialize(), xn_connect(), xn_query_features(), and xnb_collect_xenstore_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_single()

static int xs_single ( struct xs_transaction  t,
enum xsd_sockmsg_type  request_type,
const char *  body,
u_int *  len,
void **  result 
)
static

Wrapper for xs_talkv allowing easy transmission of a message with a single, contiguous, message body.

Parameters
tThe transaction to use for this request.
request_typeThe type of message to send.
bodyThe body of the request.
lenThe returned length of the reply.
resultThe returned body of the reply.
Returns
0 on success. Otherwise an errno indicating the cause of failure.
Note
The returned result is provided in malloced storage and thus must be free'd by the caller with 'free(*result, M_XENSTORE);

Definition at line 888 of file xenstore.c.

References xs_talkv().

Referenced by xs_directory(), xs_mkdir(), xs_read(), xs_rm(), xs_transaction_end(), and xs_transaction_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_suspend()

static int xs_suspend ( device_t  dev)
static

Prepare for suspension of this VM by halting XenStore access after all transactions and individual requests have completed.

Definition at line 1174 of file xenstore.c.

References xs_softc::request_mutex, and xs.

◆ xs_talkv()

static int xs_talkv ( struct xs_transaction  t,
enum xsd_sockmsg_type  request_type,
const struct iovec *  iovec,
u_int  num_vecs,
u_int *  len,
void **  result 
)
static

Send a message with an optionally muti-part body to the XenStore service.

Parameters
tThe transaction to use for this request.
request_typeThe type of message to send.
iovecPointers to the body sections of the request.
num_vecsThe number of body sections in the request.
lenThe returned length of the reply.
resultThe returned body of the reply.
Returns
0 on success. Otherwise an errno indicating the cause of failure.
Note
The returned result is provided in malloced storage and thus must be free'd by the caller with 'free(*result, M_XENSTORE);

Definition at line 817 of file xenstore.c.

References xs_softc::request_mutex, xs, xs_get_error(), xs_read_reply(), and xs_write_store().

Referenced by xs_single(), xs_unwatch(), xs_watch(), and xs_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_transaction_end()

int xs_transaction_end ( struct xs_transaction  t,
int  abort 
)

Definition at line 1481 of file xenstore.c.

References xs_single().

Referenced by talk_to_backend(), xbb_publish_backend_info(), xnb_publish_backend_info(), xs_dev_dtor(), and xs_rm_tree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_transaction_start()

int xs_transaction_start ( struct xs_transaction *  t)

Definition at line 1466 of file xenstore.c.

References xs_single().

Referenced by talk_to_backend(), xbb_publish_backend_info(), xnb_publish_backend_info(), and xs_rm_tree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_unlock()

void xs_unlock ( void  )

Definition at line 1656 of file xenstore.c.

References xs_softc::request_mutex, and xs.

◆ xs_unregister_watch()

void xs_unregister_watch ( struct xs_watch watch)

Definition at line 1608 of file xenstore.c.

References find_watch(), xs_softc::registered_watches_lock, xs_stored_msg::u, xs_softc::watch_events, xs_softc::watch_events_lock, xs_softc::xenwatch_mutex, xs_softc::xenwatch_pid, xs, and xs_unwatch().

Referenced by xbb_attach_cb(), xbb_shutdown(), xctrl_detach(), xs_dev_dtor(), and xs_dev_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_unwatch()

static int xs_unwatch ( const char *  path,
const char *  token 
)
static

Transmit an uwatch request to the XenStore service.

Parameters
pathThe path in the XenStore to watch.
tockenA unique identifier for this watch.
Returns
0 on success. Otherwise an errno indicating the cause of failure.

Definition at line 932 of file xenstore.c.

References xs_talkv().

Referenced by xs_unregister_watch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_vprintf()

int xs_vprintf ( struct xs_transaction  t,
const char *  dir,
const char *  node,
const char *  fmt,
va_list  ap 
)

Definition at line 1518 of file xenstore.c.

References xs_write().

Referenced by xbb_attach_failed(), xnb_attach_failed(), and xs_printf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_watch()

static int xs_watch ( const char *  path,
const char *  token 
)
static

Transmit a watch request to the XenStore service.

Parameters
pathThe path in the XenStore to watch.
tockenA unique identifier for this watch.
Returns
0 on success. Otherwise an errno indicating the cause of failure.

Definition at line 910 of file xenstore.c.

References xs_talkv().

Referenced by find_watch(), xs_register_watch(), and xs_resume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_write()

int xs_write ( struct xs_transaction  t,
const char *  dir,
const char *  node,
const char *  string 
)

Definition at line 1326 of file xenstore.c.

References xs_join(), and xs_talkv().

Referenced by xctrl_on_watch_event(), and xs_vprintf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_write_store()

static int xs_write_store ( const void *  tdata,
unsigned  len 
)
static

Transmit data to the XenStore service.

Parameters
tdataA pointer to the contiguous data to send.
lenThe amount of data to send.
Returns
On success 0, otherwise an errno value indicating the cause of failure.
Invariant
Called from thread context.
The buffer pointed to by tdata is at least len bytes in length.
xs.request_mutex exclusively locked.

Definition at line 455 of file xenstore.c.

References xs_softc::request_mutex, xs_softc::ring_lock, xs_softc::xen_intr_handle, xen_store, xs, xs_check_indexes(), and xs_get_output_chunk().

Referenced by xs_dev_request_and_reply(), and xs_talkv().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ xen_store

struct xenstore_domain_interface* xen_store
static

Pointer to shared memory communication structures allowing us to communicate with the XenStore service.

When operating in full PV mode, this pointer is set early in kernel startup from within xen_machdep.c. In HVM mode, we use hypercalls to get the guest frame number for the shared page and then map it into kva. See xs_init() for details.

Definition at line 117 of file xenstore.c.

Referenced by xs_attach(), xs_init_comms(), xs_intr(), xs_read_store(), and xs_write_store().

◆ xenstore_devclass

devclass_t xenstore_devclass
static

Definition at line 1240 of file xenstore.c.

◆ xenstore_methods

device_method_t xenstore_methods[]
static
Initial value:
= {
DEVMETHOD(device_identify, xs_identify),
DEVMETHOD(device_probe, xs_probe),
DEVMETHOD(device_attach, xs_attach),
DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, xs_suspend),
DEVMETHOD(device_resume, xs_resume),
DEVMETHOD(bus_add_child, bus_generic_add_child),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD_END
}
static int xs_attach(device_t dev)
Definition: xenstore.c:1096
static int xs_suspend(device_t dev)
Definition: xenstore.c:1174
static int xs_probe(device_t dev)
Definition: xenstore.c:1058
static void xs_identify(driver_t *driver, device_t parent)
Definition: xenstore.c:1046
static int xs_resume(device_t dev __unused)
Definition: xenstore.c:1192

Definition at line 1219 of file xenstore.c.

◆ xs