我在 Ubuntu 12.10 中安装了 xcp-xapi 包。我已经在 XenCenter 中创建了一个 PV VM,但我无法访问它的控制台——当我在 XenCenter 中选择“控制台”选项卡时,我只看到一个空白页。
我通过控制台尝试了这个并得到了这个:
bear@ubuntu-tmp1:~$ sudo xe vm-list params=dom-id
dom-id ( RO) : 0
dom-id ( RO) : 2
bear@ubuntu-tmp1:~$ sudo xenstore-ls /local/domain/2/serial
0 = ""
limit = "65536"
bear@ubuntu-tmp1:~$
据这位官员称关联,我至少应该在输出中看到“tty”和“vnc”,但我什么都没看到……现在我完全无法在该虚拟机上安装操作系统,因为没有可用的控制台……:-(
答案1
有一个隐藏的 CLI 命令(我已提交请求使其不隐藏):
xe console uuid=<vm_uuid>
请注意,这仅适用于 PV 客户机。或者,对于 PV 和 HVM 客户机,您可以使用 vncviewer 获取 VNC 控制台。使用 xenstore 获取 VNC 端口:
PORT=xenstore-read /local/domain/${domid}/console/vnc-port
然后调用:
vncviewer -via root@${YOUR_SERVER} localhost::${PORT}
这是一个可以为您完成此操作的脚本:
#!/bin/bash
function usage () {
echo "Usage:"
echo " `basename $0` -h <xenserver host> -g <guest vm name-label>"
echo " `basename $0` -h <xenserver host> -u <guest vm uuid>"
echo " `basename $0` -h <xenserver host> -d <domID>"
exit 1
}
while getopts "h:g:u:d:" option
do
case $option in
h ) xs=${OPTARG} ;;
g ) vm=${OPTARG} ;;
u ) uu=${OPTARG} ;;
d ) id=${OPTARG} ;;
* ) usage
esac
done
if [ -z ${xs} ]; then
usage
fi
if [ -z ${uu} ] && [ -z ${vm} ] && [ -z ${id} ]; then
usage
fi
if [ ! -z ${uu} ]; then
domid=`ssh root@${xs} xe vm-list uuid=${uu} params=dom-id --minimal`
elif [ ! -z ${vm} ]; then
domid=`ssh root@${xs} xe vm-list name-label=${vm} params=dom-id --minimal`
elif [ ! -z ${id} ]; then
domid=${id}
fi
if [ -z ${domid} ]; then
echo "Could not find guest ${vm}${uu} on host ${xs}."
exit 1
elif [ ${domid} -lt 0 ]; then
echo "Guest ${vm}${uu} has no dom-id. Is your vm running?"
exit 1
fi
port=`ssh root@${xs} xenstore-read /local/domain/${domid}/console/vnc-port`
if [ -z ${port} ]; then
echo "Couldn't read VNC port from xenstore. Is your vm running?"
exit 1
fi
echo "Connecting to vnc port ${port} on host ${xs}..."
set -x
vncviewer -via root@${xs} localhost::${port}