virsh
virsh command is used to manage KVM vps. It is part of libvirt package.
- virsh list
- virsh nodeinfo
- How to force shutdown a KVM VM with virsh
- How to delete KVM Virtual machine using virsh
To list KVM virtual machines, run
1 |
virsh list |
Start a VM
1 |
virsh start VM_ID |
To shutdown a VM, run
1 |
virsh shutdown VM_ID |
To delete a VM, run
1 |
virsh shutdown VM_ID |
Connect to Remote Server
1 |
This will take your SSH key.
List All VM
1 2 3 4 5 6 |
boby@fwhlin:~ $ virsh list --all Id Name State ---------------------------------------------------- - vm1 shut off boby@fwhlin:~ $ |
List All Running VM
1 2 3 4 5 6 7 8 9 10 |
[root@server70 ~]# virsh list Id Name State ---------------------------------------------------- 1 vm10 running 3 vm12 running 5 vm15 running 7 vm17 running 12 vm16 running [root@server70 ~]# |
Get Info About a VM
1 |
virsh dominfo VM_NAME |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@server70 ~]# virsh dominfo vm18 Id: 10 Name: vm18 UUID: b6c3a3d8-d96a-c3fa-1fad-04aff28e476a OS Type: hvm State: running CPU(s): 2 CPU time: 422.9s Max memory: 524288 KiB Used memory: 524288 KiB Persistent: yes Autostart: disable Managed save: no Security model: none Security DOI: 0 [root@server70 ~]# |
Change Memory of a VM
1 2 |
virsh dumpxml vm18 > vm18.xml virsh shutdown vm18 |
1 |
vi vm18.xml |
Find
1 2 |
<memory unit='KiB'>524288</memory> <currentMemory unit='KiB'>524288</currentMemory> |
Replace With
1 2 |
<memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> |
Load configuration
1 |
virsh define vm18.xml |
1 2 3 4 |
[root@server70 ~]# virsh define vm18.xml Domain vm18 defined from vm18.xml [root@server70 ~]# |
Start VM
1 |
virsh start vm18 |
1 2 3 4 |
[root@server70 ~]# virsh start vm18 Domain vm18 started [root@server70 ~]# |
See kvm