Editing Virsh
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
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, [[shutdown]] or suspend and to manage storage, [[Virsh Snapshots|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><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 | ||
<code>virsh</code> is include in <code>[[libvirt|libvirt-client]]</code> package in [[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 |
− | * | + | * [[virt-admin]] |
− | * | + | * [[virt-host-validate]] |
− | * | + | * [[virt-login-shell]] |
− | * | + | * [[virt-pki-validate]] |
− | * | + | * [[virt-xml-validate]] |
== Basic Commands == | == Basic Commands == | ||
Line 16: | Line 15: | ||
== All Commands == | == All Commands == | ||
* <code>[[virsh --connect]]</code> | * <code>[[virsh --connect]]</code> | ||
− | |||
− | |||
* <code>[[virsh autostart]] VM_NAME</code> or <code>[[virsh autostart]] VM_NAME --disable</code> (Related: <code>[[virsh start]]</code> and <code>[[virsh pool-autostart]]</code>) | * <code>[[virsh autostart]] VM_NAME</code> or <code>[[virsh autostart]] VM_NAME --disable</code> (Related: <code>[[virsh start]]</code> and <code>[[virsh pool-autostart]]</code>) | ||
* <code>[[virsh blockcommit]]</code>. Allows Live-disk-backup-with-active-blockcommit <ref> https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit</ref> | * <code>[[virsh blockcommit]]</code>. Allows Live-disk-backup-with-active-blockcommit <ref> https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit</ref> | ||
* <code>[[virsh blockcopy]]</code> | * <code>[[virsh blockcopy]]</code> | ||
* <code>[[virsh blockjob]]</code> | * <code>[[virsh blockjob]]</code> | ||
− | |||
* <code>[[virsh change-media]]</code> | * <code>[[virsh change-media]]</code> | ||
− | * <code>[[virsh create]] [[MY_XML_VM_DEFINITION.XML/]] | + | * <code>[[virsh create]] [[/MY_XML_VM_DEFINITION.XML/]]</code> |
− | + | * <code>[[virsh define]] [[/MY_XML_VM_DEFINITION.XML/]]</code> (define machine but do not start it) | |
− | * <code>[[virsh define]] [[MY_XML_VM_DEFINITION.XML]]</code> (define machine but do not start it) | ||
** <code>[[virsh define]] xmlfile.xml --validate</code> | ** <code>[[virsh define]] xmlfile.xml --validate</code> | ||
** <code>[[virsh destroy]] VM_MACHINE_NAME </code> (Ungraceful Shutdown but do not destroy data or VM but you can corrupt guest file systems) | ** <code>[[virsh destroy]] VM_MACHINE_NAME </code> (Ungraceful Shutdown but do not destroy data or VM but you can corrupt guest file systems) | ||
Line 41: | Line 36: | ||
* <code>[[virsh dommemstat]]</code> | * <code>[[virsh dommemstat]]</code> | ||
* <code>[[virsh domname]]</code> | * <code>[[virsh domname]]</code> | ||
− | |||
* <code>virsh dump --memory-only --verbose</code> | * <code>virsh dump --memory-only --verbose</code> | ||
* <code>[[virsh dumpxml]] VMNAME</code> - domain information in XML (Can be used to move VMs between hosts <ref>https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm</ref>) | * <code>[[virsh dumpxml]] VMNAME</code> - domain information in XML (Can be used to move VMs between hosts <ref>https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm</ref>) | ||
Line 58: | Line 52: | ||
* <code>[[virsh reboot]]</code> | * <code>[[virsh reboot]]</code> | ||
* <code>virsh restore</code> | * <code>virsh restore</code> | ||
− | * <code> | + | * <code>virsh resume</code> |
− | * <code> | + | * <code>virsh save</code> |
* <code>virsh set-lifecycle-action</code>. Added in November 2017 (v.3.9.0)<ref>https://libvirt.org/news.html</ref> | * <code>virsh set-lifecycle-action</code>. Added in November 2017 (v.3.9.0)<ref>https://libvirt.org/news.html</ref> | ||
* <code>[[virsh setmaxmem]]</code> | * <code>[[virsh setmaxmem]]</code> | ||
* <code>[[virsh setmem]]</code> | * <code>[[virsh setmem]]</code> | ||
** <code>[[virsh setmem]] —-config</code> | ** <code>[[virsh setmem]] —-config</code> | ||
− | |||
* <code>[[virsh snapshot-create-as]]</code> | * <code>[[virsh snapshot-create-as]]</code> | ||
* <code>[[virsh start]]</code> | * <code>[[virsh start]]</code> | ||
− | * <code> | + | * <code>virsh suspend</code> |
+ | * <code>virsh save</code> | ||
* <code>[[virsh shutdown]]</code> | * <code>[[virsh shutdown]]</code> | ||
* <code>[[virsh undefine]]</code> | * <code>[[virsh undefine]]</code> | ||
* <code>virsh update-device</code> | * <code>virsh update-device</code> | ||
* <code>[[virsh vcpuinfo]]</code> | * <code>[[virsh vcpuinfo]]</code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Getting Information == | == Getting Information == | ||
− | * List Running Virtual Machines: | + | * List Running Virtual Machines: <code>[[virsh list]]</code><ref>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-managing_guests_with_virsh</ref><ref>https://help.ubuntu.com/community/KVM/Managing</ref> |
− | |||
** <code>virsh list --name</code> | ** <code>virsh list --name</code> | ||
− | ** <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 [[autostart]] configuration. | * <code>[[virsh dominfo]] MY_VM_NAME</code> Guess virtual machine information such us state and [[autostart]] configuration. | ||
Line 95: | Line 82: | ||
* <code>[[virsh nodeinfo]]</code> | * <code>[[virsh nodeinfo]]</code> | ||
− | * View configuration: | + | * View configuration: <code>[[virsh dumpxml]] {guest-id, VM_NAME or uuid}</code> > yourfilename.xml<ref>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</ref> |
− | |||
** Virtual interfaces: <code>virsh domiflist VM_NAME</code> | ** Virtual interfaces: <code>virsh domiflist VM_NAME</code> | ||
Line 110: | Line 96: | ||
* <code>[[virsh vol-info]] <vol></code> | * <code>[[virsh vol-info]] <vol></code> | ||
− | |||
− | |||
− | |||
Guest info: | Guest info: | ||
Line 120: | Line 103: | ||
* <code>[[virsh version]]</code> | * <code>[[virsh version]]</code> | ||
− | |||
− | |||
== Operations == | == Operations == | ||
Line 170: | Line 151: | ||
== [[Virsh CPU Commands]] == | == [[Virsh CPU Commands]] == | ||
* <code>[[virsh cpu-models]] x86_64</code> | * <code>[[virsh cpu-models]] x86_64</code> | ||
− | |||
== [[Virsh Memory Commands]] == | == [[Virsh Memory Commands]] == | ||
Line 179: | Line 159: | ||
== Networking == | == Networking == | ||
− | + | * <code>virsh net-autostart </code> autostart a network | |
+ | * <code>virsh net-create </code> create a network from an XML file | ||
+ | * <code>virsh net-define </code> define an inactive persistent virtual network or modify an existing persistent one from an XML file | ||
+ | * <code>virsh net-destroy </code> destroy (stop) a network | ||
+ | * <code>[[virsh net-dhcp-leases]] </code> print lease info for a given network | ||
+ | * <code>[[virsh net-dumpxml]]</code> NET_NAME network information in XML | ||
+ | * <code>[[virsh net-edit]]</code> edit XML configuration for a network | ||
+ | * <code>virsh net-event </code> Network Events | ||
+ | * <code>[[virsh net-info]]</code> network information | ||
+ | * <code>[[virsh net-list]]</code> list networks | ||
+ | * <code>virsh net-name </code> convert a network UUID to network name | ||
+ | * <code>virsh net-start </code> start a (previously defined) inactive network | ||
+ | * <code>virsh net-undefine </code> undefine a persistent network | ||
+ | * <code>virsh net-update </code> update parts of an existing network's configuration | ||
+ | * <code>virsh net-uuid </code> convert a network name to network UUID | ||
== Activities == | == Activities == | ||
Line 190: | Line 184: | ||
== 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> | + | * <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 | ||
* [[ovirt-RHV module]] | * [[ovirt-RHV module]] | ||
+ | * [[KVM]] and [[libvirt]] | ||
* [[virt-admin]] | * [[virt-admin]] | ||
− | |||
− | |||
− | |||
== References == | == References == |
Advertising: