Difference between revisions of "Virsh"

From wikieduonline
Jump to navigation Jump to search
m
Line 1: Line 1:
<code>virsh</code><ref>http://manpages.ubuntu.com/manpages/xenial/man1/virsh.1.html</ref><ref> https://github.com/libvirt/libvirt/blob/master/tools/virsh.c</ref> is a command line utility for managing virsh guest domains/virtual machines and the hypervisor<ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-managing_guests_with_virsh</ref>. Can be used to operate vm like create, list, start, [[virsh/virsh shutdown|shutdown]] or suspend and to manage storage, [[virsh/KVM virsh Snapshots|snapshots]] and [[cell biology/Checkpoints|checkpoints]]<ref>https://github.com/libvirt/libvirt/commit/689beaa47c51fb49fafa992dd468116b8f6b0782#diff-f41fa7374ab97c527387ea4ce48fd04e</ref> among other actions. <code>[[virt-manager]]</code> is a graphical alternative to virsh. It supports Xen, QEMU, [[KVM]], LXC, OpenVZ, VirtualBox and VMware ESX.
+
<code>virsh</code><ref>http://manpages.ubuntu.com/manpages/xenial/man1/virsh.1.html</ref><ref> https://github.com/libvirt/libvirt/blob/master/tools/virsh.c</ref> is a command line utility for managing virsh guest domains/virtual machines and the hypervisor<ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-managing_guests_with_virsh</ref>. Can be used to operate vm like create, list, start, [[shutdown]] or suspend and to manage storage, [[snapshots]] and [[checkpoints]]<ref>https://github.com/libvirt/libvirt/commit/689beaa47c51fb49fafa992dd468116b8f6b0782#diff-f41fa7374ab97c527387ea4ce48fd04e</ref> among other actions. <code>[[virt-manager]]</code> is a graphical alternative to virsh. It supports Xen, QEMU, [[KVM]], LXC, OpenVZ, VirtualBox and VMware ESX.
  
<code>virsh</code>  is include in <code>[[libvirt|libvirt-client]]</code>  package in [[Red Hat Enterprise Linux|RHEL]] and [[Ubuntu]] and uses [[libvirt]] management API. Binaries included:
+
<code>virsh</code>  is include in <code>[[libvirt|libvirt-client]]</code>  package in [[RHEL]] and [[Ubuntu]] and uses [[libvirt]] management API. Binaries included:
 
* virsh
 
* virsh
 
* [[virt-admin]]
 
* [[virt-admin]]
Line 28: Line 28:
 
**<code>[[virsh domblklist]] --details VM_MACHINE_NAME</code>
 
**<code>[[virsh domblklist]] --details VM_MACHINE_NAME</code>
 
* <code>[[virsh domblkstat]] VMNAME</code>
 
* <code>[[virsh domblkstat]] VMNAME</code>
* <code>[[virsh domblkinfo]] VMNAME BLOCK_DEVICE</code> (BLOCK_DEVICE from [[/virsh domblklist/]] command)
+
* <code>[[virsh domblkinfo]] VMNAME BLOCK_DEVICE</code> (BLOCK_DEVICE from [[virsh domblklist]] command)
 
* <code>[[virsh domdisplay]]</code>
 
* <code>[[virsh domdisplay]]</code>
 
* <code>[[virsh domfsfreeze]]</code> Quiesces the guest filesystem in isolation<ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands</ref>
 
* <code>[[virsh domfsfreeze]]</code> Quiesces the guest filesystem in isolation<ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands</ref>
 
* <code>[[virsh domfsthaw]]</code> Quiesces the guest filesystem in isolation<ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands</ref>
 
* <code>[[virsh domfsthaw]]</code> Quiesces the guest filesystem in isolation<ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands</ref>
 
* <code>[[virsh domid]]</code>
 
* <code>[[virsh domid]]</code>
* <code>[[virsh dominfo]] VMNAME_OR_ID</code> Guess virtual machine information such us state and [[virsh/virsh autostart|autostart]] configuration.
+
* <code>[[virsh dominfo]] VMNAME_OR_ID</code> Guess virtual machine information such us state and [[autostart]] configuration.
 
* <code>[[virsh dommemstat]]</code>
 
* <code>[[virsh dommemstat]]</code>
 
* <code>[[virsh domname]]</code>
 
* <code>[[virsh domname]]</code>
Line 72: Line 72:
 
** List all Virtual Machines: <code>virsh list --all</code>
 
** List all Virtual Machines: <code>virsh list --all</code>
  
* <code>[[virsh dominfo]] MY_VM_NAME</code> Guess virtual machine information such us state and [[virsh/virsh autostart|autostart]] configuration.
+
* <code>[[virsh dominfo]] MY_VM_NAME</code> Guess virtual machine information such us state and [[autostart]] configuration.
  
 
* <code>[[virsh domstats]]</code> (show all VMs)
 
* <code>[[virsh domstats]]</code> (show all VMs)
Line 184: Line 184:
 
# Enable access to your VM Machines via [[virsh console]] command
 
# Enable access to your VM Machines via [[virsh console]] command
 
# Learn difference between <code>[[virsh define]]</code> and <code>[[virsh create]]</code>
 
# Learn difference between <code>[[virsh define]]</code> and <code>[[virsh create]]</code>
# [[/Create Live backups/]] with active [[virsh blockcommit]]<ref>https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit</ref>
+
# [[Create Live backups]] with active [[virsh blockcommit]]<ref>https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit</ref>
# [[KVM/Offline Migrate or move a virtual machine between two KVM servers without shared storage]]<ref>https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm</ref>: <code>[[virsh dumpxml]]</code> and <code>[[virsh/MY XML VM DEFINITION.XML|virsh define]]</code>
+
# [[Offline Migrate or move a virtual machine between two KVM servers without shared storage]]<ref>https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm</ref>: <code>[[virsh dumpxml]]</code> and <code>[[virsh define]]</code>
  
 
== See also ==
 
== See also ==
 
* <code>[[virtinst]]</code> package<ref>https://github.com/virt-manager/virt-manager/tree/master/virtinst</ref>, includes following python binaries: <code>virt-clone</code>, <code>virt-convert</code>, <code>[[virt-install]]</code><ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/getting-started-with-virtualization-in-rhel-8_configuring-and-managing-virtualization</ref>
 
* <code>[[virtinst]]</code> package<ref>https://github.com/virt-manager/virt-manager/tree/master/virtinst</ref>, includes following python binaries: <code>virt-clone</code>, <code>virt-convert</code>, <code>[[virt-install]]</code><ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/getting-started-with-virtualization-in-rhel-8_configuring-and-managing-virtualization</ref>
 
* [[virt-top]] 'top'-like utility for virtualization stats
 
* [[virt-top]] 'top'-like utility for virtualization stats
* [[DevOps/Ansible/ovirt-RHV module]]
+
* [[ovirt-RHV module]]
 
* [[KVM]] and [[libvirt]]
 
* [[KVM]] and [[libvirt]]
 
* [[virt-admin]]
 
* [[virt-admin]]

Revision as of 06:30, 7 January 2020

virsh[1][2] is a command line utility for managing virsh guest domains/virtual machines and the hypervisor[3]. Can be used to operate vm like create, list, start, shutdown or suspend and to manage storage, snapshots and checkpoints[4] among other actions. virt-manager is a graphical alternative to virsh. It supports Xen, QEMU, KVM, LXC, OpenVZ, VirtualBox and VMware ESX.

virsh is include in libvirt-client package in RHEL and Ubuntu and uses libvirt management API. Binaries included:

Basic Commands

  • virsh
  • virsh -r

All Commands

Getting Information

  • List Running Virtual Machines: virsh list[12][13]
    • virsh list --name
    • List all Virtual Machines: virsh list --all
  • View configuration: virsh dumpxml {guest-id, VM_NAME or uuid} > yourfilename.xml[14]
    • Virtual interfaces: virsh domiflist VM_NAME

Network info:

Storage info:


Guest info:

Operations

Changing VM running status operations:

Snapshots:

Migrations:

  • virsh migrate --live GuestName DestinationURL
  • virsh migrate --offline[17] (copying non-shared storage or other file based storages (e.g. UEFI variable storage) is not supported during offline migration)

Configuration:

Virsh Storage commands

Virsh Storage Information

All Storage commands

Virsh Snapshots

Virsh CPU Commands

Virsh Memory Commands

virsh Memory Commands: virsh setmaxmem, virsh setmem, virsh dommemstat

QEMU

  • virsh qemu-attach QEMU Attach
  • virsh qemu-monitor-command QEMU Monitor Command
  • virsh qemu-monitor-event QEMU Monitor Events
    • virsh qemu-monitor-event VM_MACHINE_NAME
  • virsh qemu-agent-command QEMU Guest Agent Command

Networking

  • virsh net-autostart autostart a network
  • virsh net-create create a network from an XML file
  • virsh net-define define an inactive persistent virtual network or modify an existing persistent one from an XML file
  • virsh net-destroy destroy (stop) a network
  • virsh net-dhcp-leases print lease info for a given network
  • virsh net-dumpxml NET_NAME network information in XML
  • virsh net-edit edit XML configuration for a network
  • virsh net-event Network Events
  • virsh net-info network information
  • virsh net-list list networks
  • virsh net-name convert a network UUID to network name
  • virsh net-start start a (previously defined) inactive network
  • virsh net-undefine undefine a persistent network
  • virsh net-update update parts of an existing network's configuration
  • virsh net-uuid convert a network name to network UUID

Activities

  1. Review virsh command cheatsheet https://computingforgeeks.com/virsh-commands-cheatsheet/
  2. Read https://github.com/libvirt/libvirt/blob/master/tools/virsh.c source code.
  3. Enable access to your VM Machines via virsh console command
  4. Learn difference between virsh define and virsh create
  5. Create Live backups with active virsh blockcommit[20]
  6. Offline Migrate or move a virtual machine between two KVM servers without shared storage[21]: virsh dumpxml and virsh define

See also

References

  1. http://manpages.ubuntu.com/manpages/xenial/man1/virsh.1.html
  2. https://github.com/libvirt/libvirt/blob/master/tools/virsh.c
  3. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-managing_guests_with_virsh
  4. https://github.com/libvirt/libvirt/commit/689beaa47c51fb49fafa992dd468116b8f6b0782#diff-f41fa7374ab97c527387ea4ce48fd04e
  5. https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit
  6. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands
  7. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands
  8. https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm
  9. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_virtualization/index#creating-storage-for-virtual-machines-using-the-cli_managing-storage-for-virtual-machines-using-the-cli
  10. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_virtualization/index#creating-storage-for-virtual-machines-using-the-cli_managing-storage-for-virtual-machines-using-the-cli
  11. https://libvirt.org/news.html
  12. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-managing_guests_with_virsh
  13. https://help.ubuntu.com/community/KVM/Managing
  14. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-domain_commands-creating_a_virtual_machine_xml_dump_configuration_file
  15. https://fossies.org/linux/libvirt/NEWS
  16. https://libvirt.org/news.html
  17. https://libvirt.org/migration.html#offline
  18. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_virtualization/index#creating-storage-for-virtual-machines-using-the-cli_managing-storage-for-virtual-machines-using-the-cli
  19. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_virtualization/index#creating-storage-for-virtual-machines-using-the-cli_managing-storage-for-virtual-machines-using-the-cli
  20. https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit
  21. https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm
  22. https://github.com/virt-manager/virt-manager/tree/master/virtinst
  23. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/getting-started-with-virtualization-in-rhel-8_configuring-and-managing-virtualization

Script error: No such module "Check for unknown parameters".

Advertising: