Google 了一下 好像是用 virsh 命令,搜了一些网页好像没有启动虚拟机的选项
找到了一个脚本不知道行不行,可有大佬了解的
#!/bin/bash
VM1="$1" VM2="$2"
echo $VM1 echo $VM2
if virsh list | grep -q " ${VM1} .*running" ; then virsh shutdown "${VM1}" fi
echo "1" WAIT=0
while virsh list | grep -q " ${VM1} .*running" ; do if [ $WAIT -lt 51 ]; then WAIT=$(($WAIT + 5)) sleep 5 echo $WAIT else echo "too long" break fi done
if virsh list | grep -q " ${VM1} .*running" ; then virsh destroy "${VM1}" fi
WAIT=0
while virsh list | grep -q " ${VM1} .*running" ; do if [ $WAIT -lt 30 ]; then WAIT=$(($WAIT + 5)) sleep 5 echo $WAIT else echo "too long" break fi done
virsh start "$VM2"