The Virsh Cheat Sheet
VIRSH is a tool which is run on the command line to manage guest virtual servers and the hypervisor on KVM nodes. It’s built upon the libvert management API. This Virsh cheat sheet details the common commands used to manage KVM containers running on a dedicated server.
Basic VIRSH commands
The instance name can be different depending on the hypervisor used, we’re using “First2Host101” for the instance name in this guide but you should swap this for the instance name you wish to manage, SolusVM instances will usually be defined by kvm101, kvm102, kvm103. Use the virsh list –all command see the guest domain names on your node.
VIRSH Control Commands
virsh start First2Host101
Start the guest
virsh shutdown First2Host101
Shutdown the guest
virsh destroy First2Host101
Delete the server
virsh suspend First2Host101
Suspend the container
virsh resume First2Host101
Unsuspend the container
virsh console First2Host101
Open a serial console for the server.
Virsh Cheat Sheet
virsh dumpxml First2Host101 >dump.xml
Create a dump file which you can use to create more guests or add more options to existing guests.
virsh create dump.xml
Virsh create is used to create guests. dump.xml is the configuration file which can be created using the virsh dump command above.
virsh edit First2Host101
Virsh edit allows you to edit a guests configuration file.
virsh underfine First2Host101 [--managed-save] [storage] [--remove-all-storage] [--wipe-storage] [--snapshots-metadata] [--nvram]
The undefine option allows you to undefine a guest. If the guest is inactive it’s converted to a transient domain.
virsh setmem First2Host101 1000000
Set the guest memory limit in kilobytes. The above commands sets 1 GB of memory.
virsh setvcpus 12
Set the number of vCPUs a guest is assigned.
virsh dominfo First2Host101
virsh vcpuinfo First2Host101
Print CPU information for a guest.
Print node information in the console.
virsh list --all|--inactive
List all guests on the node or list all inactive guests.
Red Hat provides a full guide on how to manage virsh from the command line and for a full list of options to use with Virsh you can check out the documentation at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-managing_guests_with_virsh
How was this article?
You might also like
More from Dedicated Servers
Enable Mod_RemoteIP – See Visitors Real IP address when using Cloudflare & Apache
If you are using Cloudflare on your Apache server you will always see Cloudflare IPs in your logs and not …
Fix 413 Request Entity Too Large Errors When Using NGINX
Just like Apache, NGINX imposes default limits on the size of files that can be uploaded. A 413 Request Entity …
Cloud-init Modules That Automate and Customize Deployments
Cloud-init is a popular way to automate deployments of instances in a cloud or none cloud environment. To save having …