Friday, April 27, 2012

KVM: Starting / Stopping Guest Operating Systems With virsh Command

The virsh command can be used to mange local or remote guest operating systems. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains.

List Running VMS

Type the following command:
# virsh list
Sample outputs:
 Id Name                 State
----------------------------------
1 centos.nixcraft.in running
2 freebsd running

Shut Down A Guest

# virsh list
# virsh shutdown dominName
# virsh shutdown freebsd
# virsh shutdown 3

Rebooting A Guest

# virsh list
# virsh reboot domaiName
# virsh reboot 3
# virsh reboot win2008biz

Forcefully Stop A Guest

Force a guest to stop with the virsh command if it is not responding or crashed
# virsh list
# virsh destroy domainName
# virsh destroy openbsd.nixcraft.in

Get Information About Guest

# virsh list
# virsh dominfo dominName
# virsh dominfo 2
# virsh dominfo freebsd

Sample outputs:
Id:             2
Name: freebsd
UUID: 6b7f44df-b67a-b1e1-0f9a-40c9ad760b0a
OS Type: hvm
State: running
CPU(s): 1
CPU time: 26.3s
Max memory: 524288 kB
Used memory: 524288 kB
Autostart: disable

Get Information About Node

# virsh nodeinfo
Sample Outputs:
CPU model:           x86_64
CPU(s): 4
CPU frequency: 2394 MHz
CPU socket(s): 1
Core(s) per socket: 4
Thread(s) per core: 1
NUMA cell(s): 1
Memory size: 8181332 kB

Conclusion

The first part in this series covered KVM installation, KVM bridged based networking, KVM guest setup using virt-install, virt-manager, kickstart based guest installation and troubleshooting KVM with log files. Stay tunned for next part of series which will cover other advanced topics such as:
  • VM storage configuration using NFS and iSCSI
  • VM live migration
  • VM security and firewall
  • VM load balancing
  • VM instillation using Cobbler

No comments:

Post a Comment