xenstore

Xenstore 是主要的用来控制建立来自客户机的共享内存区域的事件通道、管理客户机的通知,收集客户机状态数据的工具。Xenstore 的目录是层次似的 key-data 值对。每个域都有一个目录继承结构,包含存储它自身的信息,主要是配置信息。

这些信息一般存储于一个数据库中,位于 /var/lib/xenstored/tdb。都是关于和域方面有关的关键功能。比如,一个Xen 总线在安装新的硬件时能方便发现新的硬件。这对于客户机的热拔插功能是很关键的。维护一个域的配置信息只是更新在存储继承结构中的引用。由于域只能修改自 身目录的内容,它们被允许注册而收到有关和它们存储的树结构的修改的通知。比如你要将一个客户机从使用主机的 CD-ROM 驱动器到使用一个 ISO 文件,你将需要使用管理工具来更新域的存储信息,使得其中 /dev/cdrom 的配置重新映射到一个 ISO 文件。这并不需要域的重新创建。

如果你查看这种继承结构,将会看到 3 个主要的路径:
/vm:包含和域相关的配置;
/local/domain:本节点上存储的信息;
/tool:包含不同用户模态下的工具。

你可以使用这些信息来开发一个定制的管理接口或者进行 Xen 环境下简单的查询。下面几个命令是和此有关的:
xenstore-chmod:准许管理员和开发人员手工改变 Xenstore 中任意位置的权限;
xenstore-list:列出存放于目录中存放的 key,或者类别。
xenstore-read:输出和一个特定 key 有关的值。
xenstore-write:改变 key 中存放的值。
xenstore-exists:用于检查一个特定的 key-value 是否存在。
xenstore-ls:输出整个数据库树,包含所有的节点和key-value 值对。
xenstore-rm:删除一个 key。

#!/bin/sh
 
function dumpkey()
{
local param=${1}
local key
local result
result=$(xenstore-list ${param})
if [ "${result}" != "" ] ; then
for key in ${result} ; do dumpkey ${param}/${key} ; done
else
echo -n ${param}'='
xenstore-read ${param}
fi
}
 
for key in /vm /local/domain /tool; do dumpkey ${key} ; done


或者你直接运行 xenstore-ls 打出整个数据库的树状结构:

tool = ""
xenstored = ""
vm = ""
00000000-0000-0000-0000-000000000000 = ""
shadow_memory = "0"
uuid = "00000000-0000-0000-0000-000000000000"
on_reboot = "restart"
on_poweroff = "destroy"
name = "Domain-0"
xend = ""
restart_count = "0"
vcpus = "2"
vcpu_avail = "3"
memory = "2516"
on_crash = "restart"
maxmem = "2651"
8059729a-360a-0793-39d5-05bd058cf587 = ""
image = "(linux (ramdisk /var/lib/xen/boot_ramdisk.z1pw6p) (kernel /var/li..."
ostype = "linux"
kernel = "/var/lib/xen/boot_kernel.vkUxRH"
cmdline = " ro root=LABEL=/"
ramdisk = "/var/lib/xen/boot_ramdisk.z1pw6p"
device = ""
vkbd = ""
0 = ""
frontend = "/local/domain/1/device/vkbd/0"
frontend-id = "1"
backend-id = "0"
backend = "/local/domain/0/backend/vkbd/1/0"
tap = ""
51712 = ""
frontend = "/local/domain/1/device/vbd/51712"
frontend-id = "1"
backend-id = "0"
backend = "/local/domain/0/backend/tap/1/51712"
vif = ""
0 = ""
frontend = "/local/domain/1/device/vif/0"
frontend-id = "1"
backend-id = "0"
backend = "/local/domain/0/backend/vif/1/0"
1 = ""
frontend = "/local/domain/1/device/vif/1"
frontend-id = "1"
backend-id = "0"
backend = "/local/domain/0/backend/vif/1/1"
vfb = ""
0 = ""
frontend = "/local/domain/1/device/vfb/0"
frontend-id = "1"
backend-id = "0"
backend = "/local/domain/0/backend/vfb/1/0"
shadow_memory = "0"
uuid = "8059729a-360a-0793-39d5-05bd058cf587"
on_reboot = "restart"
start_time = "1235966971.63"
on_poweroff = "destroy"
name = "test2"
xend = ""
restart_count = "0"
vcpus = "1"
vcpu_avail = "1"
memory = "512"
on_crash = "restart"
maxmem = "512"
local = ""
domain = ""
0 = ""
vm = "/vm/00000000-0000-0000-0000-000000000000"
device = ""
control = ""
error = ""
backend = ""
tap = ""
1 = ""
51712 = ""
error = "2 getting info"
cpu = ""
0 = ""
availability = "online"
1 = ""
availability = "online"
memory = ""
target = "2576384"
name = "Domain-0"
console = ""
limit = "1048576"
domid = "0"
backend = ""
vkbd = ""
1 = ""
0 = ""
frontend-id = "1"
domain = "test2"
frontend = "/local/domain/1/device/vkbd/0"
state = "4"
online = "1"
feature-abs-pointer = "1"
hotplug-status = "connected"
tap = ""
1 = ""
51712 = ""
domain = "test2"
frontend = "/local/domain/1/device/vbd/51712"
format = "raw"
dev = "xvda"
state = "4"
params = "aio:/root/test2"
mode = "w"
online = "1"
frontend-id = "1"
type = "tap"
sectors = "12582912"
sector-size = "512"
info = "0"
hotplug-status = "connected"
vif = ""
1 = ""
0 = ""
bridge = "xenbr0"
domain = "test2"
handle = "0"
script = "/etc/xen/scripts/vif-bridge"
state = "4"
frontend = "/local/domain/1/device/vif/0"
mac = "00:16:3e:20:ca:9b"
online = "1"
frontend-id = "1"
feature-sg = "1"
feature-gso-tcpv4 = "1"
feature-rx-copy = "1"
hotplug-status = "connected"
1 = ""
bridge = "xenbr0"
domain = "test2"
handle = "1"
script = "/etc/xen/scripts/vif-bridge"
state = "4"
frontend = "/local/domain/1/device/vif/1"
mac = "00:16:3e:65:15:b6"
online = "1"
frontend-id = "1"
feature-sg = "1"
feature-gso-tcpv4 = "1"
feature-rx-copy = "1"
hotplug-status = "connected"
vfb = ""
1 = ""
0 = ""
vncunused = "0"
domain = "test2"
frontend = "/local/domain/1/device/vfb/0"
xauthority = "/root/.Xauthority"
vncdisplay = "0"
state = "4"
online = "1"
frontend-id = "1"
type = "vnc"
hotplug-status = "connected"
request-update = "1"
1 = ""
vm = "/vm/8059729a-360a-0793-39d5-05bd058cf587"
device = ""
vkbd = ""
0 = ""
protocol = "x86_32-abi"
state = "4"
backend-id = "0"
backend = "/local/domain/0/backend/vkbd/1/0"
page-ref = "776015"
event-channel = "7"
request-abs-pointer = "1"
vbd = ""
51712 = ""
virtual-device = "51712"
device-type = "disk"
protocol = "x86_32-abi"
backend-id = "0"
state = "4"
backend = "/local/domain/0/backend/tap/1/51712"
ring-ref = "8"
event-channel = "8"
vif = ""
0 = ""
mac = "00:16:3e:20:ca:9b"
handle = "0"
protocol = "x86_32-abi"
backend-id = "0"
state = "4"
backend = "/local/domain/0/backend/vif/1/0"
tx-ring-ref = "1280"
rx-ring-ref = "1281"
event-channel = "9"
request-rx-copy = "0"
feature-rx-notify = "1"
feature-sg = "1"
feature-gso-tcpv4 = "1"
1 = ""
mac = "00:16:3e:65:15:b6"
handle = "1"
protocol = "x86_32-abi"
backend-id = "0"
state = "4"
backend = "/local/domain/0/backend/vif/1/1"
tx-ring-ref = "1282"
rx-ring-ref = "1283"
event-channel = "10"
request-rx-copy = "0"
feature-rx-notify = "1"
feature-sg = "1"
feature-gso-tcpv4 = "1"
vfb = ""
0 = ""
protocol = "x86_32-abi"
state = "4"
backend-id = "0"
backend = "/local/domain/0/backend/vfb/1/0"
page-ref = "776025"
event-channel = "6"
feature-update = "1"
control = ""
error = ""
device-misc = ""
vif = ""
nextDeviceID = "2"
console = ""
use_graphics = "1"
ring-ref = "774877"
port = "2"
limit = "1048576"
tty = "/dev/pts/0"
vnc-port = "5900"
name = "test2"
domid = "1"
cpu = ""
0 = ""
availability = "online"
memory = ""
target = "524288"
store = ""
ring-ref = "774878"
port = "1"
serial = ""
0 = ""
tty = "/dev/pts/0"

其中 xm list 的输出:

[root@chenyajun ~]# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 2516 2 r----- 140.5
test2 1 511 1 -b---- 29.7

 

你可能感兴趣的:(数据库,存储,domain,Crash,xen,X86)