[[PageOutline|]]
====== KVM Overview ======
===== Description =====
The virsh program is the main interface for managing virsh guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains. Libvirt is a C toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes). It is free software available under the GNU Lesser General Public License. Virtualization of the Linux Operating System means the ability to run multiple instances of Operating Systems concurrently on a single hardware system where the basic resources are driven by a Linux instance. The library aims at providing a long term stable C API . It currently supports Xen, QEmu, KVM , LXC , OpenVZ, VirtualBox and VMware ESX .
The basic structure of most virsh usage is:
virsh [OPTION]... [ARG]...
Where command is one of the commands listed below; domain is the numeric domain id, or the domain name, or the domain UUID ; and ARGS are command specific options. There are a few exceptions to this rule in the cases where the command in question acts on all domains, the entire machine, or directly on the xen hypervisor. Those exceptions will be clear for each of those commands. Note: it is permissible to give numeric names to domains, however, doing so will result in a domain that can only be identified by domain id. In other words, if a numeric value is supplied it will be interpreted as a domain id, not as a name.
The virsh program can be used either to run one COMMAND by giving the command and its arguments on the shell command line, or a COMMAND_STRING which is a single shell argument consisting of multiple COMMAND actions and their arguments joined with whitespace, and separated by semicolons between commands. Within COMMAND_STRING , virsh understands the same single, double, and backslash escapes as the shell, although you must add another layer of shell escaping in creating the single shell argument. If no command is given in the command line, virsh will then start a minimal interpreter waiting for your commands, and the quit command will then exit the program.
----
The **virsh **program understands the following OPTIONS .
Generic Commands
\\
**help ** [command-or-group]\\
This lists each of the virsh commands. When used without options, all commands are listed, one per line, grouped into related categories, displaying the keyword for each group.
virsh # help host
Host and Hypervisor (help keyword **'host**'):
- **capabilities** capabilities ]
- **connect** (re)connect to hypervisor
- **freecell** NUMA free memory
- **hostname** print the hypervisor hostname
- **qemu-attach** Attach to existing QEMU process
- **qemu-monitor-command** QEMU Monitor Command
- **qemu-agent-command **QEMU Guest Agent Command
- **sysinfo **print the hypervisor sysinfo
- **uri **print the hypervisor canonical URI
===== Migrating Guests to new storage =====
virsh list --all
virsh shutdown
virsh pool-list
virsh pool-dumpxml
virsh vol-list
virsh pool-destroy
** find and update path of new location for the guest e.g.
virsh edit
** move hosts to new storage
mv
** To permanently remove a pool if its not used anymore
virsh pool-undefine
Not sure about
* How do we get virsh to rescan volume storage?
* [[https://trac.x0blr.com/#data-tracwysiwyg-link=https://libvirt.org/storage.html|This link is good for Libvirt Storage advice]]
===== External References =====
* [[https://trac.x0blr.com/#data-tracwysiwyg-link=https://www.unixarena.com/2015/12/linux-kvm-change-libvirt-vm-image-store-path.html/|UNIX Arena - Linux KVM – Change libvirt VM image store path]]
* [[https://trac.x0blr.com/#data-tracwysiwyg-link=https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-managing_guest_virtual_machines_with_virsh-editing_a_guest_virtual_machines_configuration_file|Redhat - Editing a Guest Virtual Machine's XML Configuration Settings]]
* [[https://trac.x0blr.com/#data-tracwysiwyg-link=https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm|Reddit - Correct way to move kvm vm]]