View all virtual machine status:
[root@kvm7 vps] virsh list --all
To view the specified virtual machine status:
[root@kvm7 vps] virsh domstate vm01
running
Start the virtual machine manually:
[root@kvm7 vps] virsh start vmname
To manually shut down a virtual machine:
[root@kvm7 vps] virsh shutdown vmname
Suspend virtual machine (pause):
[root@kvm7 vps] virsh suspend vmname
Reply to suspended virtual machine:
[root@kvm7 vps] virsh resume name
Power down virtual machine:
[root@kvm7 vps] virsh destroy vmname
Set boot with host (boot up):
[root@kvm7 vps] virsh autostart vmname
Cancel startup:
[root@kvm7 vps] virsh autostart --disable vmname
Delete virtual machine.xml configuration file
[root@kvm7 vps] virsh undefine vmname
Export (backup) virtual machine profile
[root@kvm7 vps] virsh dumpxml centos6 > /home/vpsbak/centos6bak.xml
Edit the virtual machine configuration file (the location of the configuration file is / etc/libvirt/qemu, which can be edited with vim, but it is recommended to use the command provided by KVM)
[root@kvm7 vps] virsh edit vmname
To view virtual machine disk information:
[root@kvm7 vps] qemu-img info vm01.img
image: vm01.img
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 3.3G
cluster_size: 65536
Format specific information:
compat: 0.10
To view the disks used by the specified virtual machine:
[root@kvm7 vps] virsh domblklist vm01
target source
------------------------------------------------
vda /home/vps/vm01.img
vdb /home/vps/data.img
hda
Virtual machine migration host physical server:
1. Backup virtual machine profile
[root@kvm6 vps] virsh dumpxml centos6 > /home/vpsbak/centos6.xml
2. Shut down and migrate configuration files and disk files. The configuration file path is / etc/libvirt/qemu
[root@kvm6 vps] scp /home/vpsbak/centos6.xml root@192.168.0.3:/etc/libvirt/qemu/
[root@kvm6 vps] scp /home/vpsdata/vps/centos6.qcow2 root@192.168.0.3:/data/vpsdata/vps
3. Activate virtual machine profile
[root@kvm7 vps] virsh define /etc/libvirt/qemu/centos6.xml