#!/bin/bash
case "$1" in
        start)
        virsh start hello                       / 开启虚拟机holle
        ;;
        poweroff)
        virsh destroy hello                    / 关闭虚拟机holle
        ;;
        reboot)
        virsh destroy hello                    / 关闭虚拟机
        virsh start hello                       / 开启虚拟机
        virt-viewer hello                       / 显示虚拟机
        ;;
        reset)
        echo poweroff hello
        virsh destroy hello &> /dev/null        / 关闭快照
        echo del hello.xml ...
virsh undefine hello &> /dev/null       / 删除快照
        echo create disk ...
        qemu-img create -f qcow2 -b /var/lib/libvirt/p_w_picpaths/vm1.qcow2 /var/lib/libvirt/p_w_picpaths/hello.qcow2                       / 建立快照
        echo create hello vm ...
        virt-install \                          / 安装虚拟机
        --name hello \                          / 确定名字
        --ram 2000 \                            / 确定内存大小
        --disk /var/lib/libvirt/p_w_picpaths/hello.qcow2 \   / 指定硬盘位置
        --import &> /dev/null &                   /  启动图形界面
        echo created hello successful !!!
        ;;
        view)
        virt-viewer hello                       / 显示虚拟机
esac