Xen

xm

# xm create lucid.cfg
Using config file "/etc/xen/lucid.cfg".
# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  1630     4     r-----    677.2
lucid                                        2   128     2     -b----      2.4
# xm console 2
............
Ubuntu 10.04 LTS lucid hvc0
lucid login:

Misc

退出console:

ctrl-]

获得domU的IP地址(10.0.0.0/24是局域网):

nmap -sP -PR 10.0.0.0/24

或者用如下Bash脚本:

ID=$1
network=$2
# Use xenstore to find the mac associated with VM
mac=`xenstore-read /local/domain/$ID/device/vif/0/mac`
umac=`echo $mac | tr "[:lower:]" "[:upper:]"`
# Search the local networking for all up machines and find the IP address.
ip=`nmap -sP $network |  grep -B 2 $umac | grep Host | awk '{print $2}'`
echo "IP address for Guest ID $ID is \"$ip\""

这样可以得到局域网各终端的IP和MAC地址,找到domU的MAC的对应IP地址即可。

X

要用domU的X程序,用SSH的X11 Forwarding或者VNC。

EOF