Document directory
- 0. Motivation
- 1. Quick Start
Abstract: xenstore is a cross-domain shared storage system provided by xen. It stores the configuration information of the Management Program and the front and back-end drivers in the form of strings. Dom0 manages all the data, while domu sends a request to dom0 for its own key value through the shared memory to implement Inter-Domain Communication. Xen provides multiple interfaces for operating xenstore: Command Line xenstore-* commands, user space Xs _ series functions, and kernel xenbus interfaces.
0. Motivation
In the xen semi-virtualization (PV) system, each Virtual Machine (domain) can use the authorization table and event channel provided by the xen core) mechanism for Inter-Domain Communication. However, there is a problem in actual use:
- Alice shares a page using the authorization table, but sanae must know its authorized reference (GREF) in advance to use it );
- Alice opens an event channel (unbound evtchn), but sanae must know the port number (remote port) used by Alice before binding this channel ).
Obviously, to solve these two problems, Alice and sanae need to be able to communicate with each other before creating a custom authorization table and event channel.
Xenstore can easily implement this communication.
1. Quick Start
Xenstore is a cross-domain shared storage system provided by xen. It stores the configuration information of hypervisor and front-end and back-end drivers in string form.Dom0 manages all the data, while domu sends a request to dom0 for its own key value through the shared memory to implement Inter-Domain Communication.
The storage structure of xenstore is similar to the DOM tree: each node has a string value and can have multiple subnodes. After dom0 is started, the xenstore structure is as follows:
/
VM
{UUID}
...
Local
Domain
0
VM
Device
Control
Memory
Console
Limit
Type
Name
......
1
...
Tool
Xenstored
There are three subdirectories under the root (/), Vm, local (actually/local/domain) and tool. VM stores VM management information. The tool has no data. The/local/domain stores the active virtual machine configuration and driver information. In/local/domain, each directory item represents an active virtual machine. For example,/local/domain/0 represents dom0.Dom0 can read and write all data of xenstore, while Dom-X can only access/local/domain/X content. The content that needs to be shared between dom0 and domx is generally written in this directory, so/local/domain is the most common directory.
Xen provides multiple interfaces for operating xenstore: Command Line xenstore-* commands, user space Xs _ series functions, and kernel xenbus interfaces.
Operation |
Command Line |
User space #include <xs.h>-lxenstore |
Kernel space #include “xen/xenbus.h” |
Column directory |
Xenstore-ls (recursion) Xenstore-List (non-recursive) |
Xs_directory |
Xenbus_directory |
Read/write |
Xenstore-read Xenstore-write |
Xs_read Xs_write |
Xenbus_read Xenbus_write Xenbus_scanf Xenbus_printf |
Create/delete a directory |
Xenstore-mkdir Xenstore-rm |
Xs_mkdir Xs_rm |
Xenbus_mkdir Xenbus_rm |
Monitoring |
Xenstore-watch |
Xs_watch Xs_unwatch Xs_read_watch |
Xenbus_watch Xenbus_unwatch |
Example
Command Line
xenstore-write example/Alice hello!
User space
struct xs_handle *xh = xs_open(0);int xt=xs_transaction_begin(xh);xs_write(xh,xt,"/local/domain/0/example/Alice", "hello!", sizeof("hello!"));xs_transaction_end(xh, xt, 0);xs_close(xh);
Kernel space
struct xenbus_transaction trans;xenbus_transaction_start(&trans);xenbus_printf(trans, "example", "Alice", "Hello! trans_id = %d", trans.id);xenbus_transaction_end(trans, 0);
Note: Example/Alice is equivalent to/local/domain/{current domain}/example/Alice
For specific usage, you can view the corresponding header file
Quick Reference:
Http://wiki.xen.org/xenwiki/XenStoreReference