常见命令:

定义Domain
virsh define ubuntutest.xml
编辑Domain
virsh edit ubuntutest
启动Domain
virsh start ubuntutest
关闭Domain
virsh shutdown ubuntutest
virsh destroy ubuntutest
重启Domain
virsh reboot ubuntutest
暂停Domain
virsh suspend ubuntutest
唤醒Domain
virsh resume ubuntutest
删除Domain
virsh undefined ubuntutest

virsh 工具是构建在 libvirt 管理 API 上,可作为 xm 命令和图形客户端管理程序(virt-manager)的替代工具使用。非特权用户只能以只读模式使用 virsh。您可使用 virsh 为客户端机器执行脚本。

https://docs.fedoraproject.org/zh-CN/Fedora/12/html/Virtualization_Guide/chap-Virtualization_Guide-Managing_guests_with_virsh.html

The virsh tool is built on the libvirt management API and operates as an alternative to the xm tool and the graphical guest Manager(virt-manager).

https://www.centos.org/docs/5/html/5.2/Virtualization/chap-Virtualization-Managing_guests_with_virsh.html

 

Configuring guest domain memory usage with virsh

http://www.linuxsysadmintutorials.com/configuring-guest-domain-memory-usage-with-virsh/

dommemstat shows that the domain web-server has a memory allocation limit of 2097152 kB and is currently using 903040 kB. You can confirm this with ps.

$ ps -C qemu-kvm -o rss,cmd
  RSS CMD
903040 /usr/bin/qemu-kvm -name web-server -S -M pc-1.2 -enable-kvm -m 2048 -smp

The memory allocation limit is set with setmaxmem and can only be performed whilst the domain is inactive.

$ virsh setmaxmem web-server 1048576 --config


By passing setmaxmem the config option the memory allocation limit is written to the virsh configuration file.

The current memory allocation for a guest domain is set with setmem.

$ virsh setmem web-server 786432 --config --live


When passing setmem the live option, a memory balloon is performed on the running guest and the change happens instantly. This can be verified with dominfo.

VIRTUAL MACHINE LIFECYCLE

http://wiki.libvirt.org/page/VM_lifecycle