在计算节点上运行下面脚本
ps -u qemu uf | grep kvm | while read line; do printf '%s\t%s\t%s \n' "$(echo ${line} | awk '{print $13}')" "$(sed -n 's/.*>\(.*\)<\/nova:name>/\1/p' $(echo /etc/libvirt/qemu/`echo ${line} | awk '{print $13}'`\.xml))" "$(echo ${line} | tr '.,' '\n'| grep 'spice port=' |awk -F 'spice port=' '{print $2}')" ;done;
例:
openstack实例名 openstack别名 spice端口
instance-00000087 ubuntu1 5903
instance-00000086 ubuntu1 5902
instance-00000089 ubuntu3 5901
instance-0000003f ubuntu4 5900