vm:kvm
Table of Contents
KVM
List, Start and Stop guest machines
Use the virtualisation shell command, virsh
List running Guests:-
[root@kvmhost ~]# virsh list Id Name State ---------------------------------- 1 quincekvm running 2 elastixkvm running 8 pearkvm running
List all Guests
[root@kvmhost ~]# virsh list --all Id Name State ---------------------------------------------------- 23 lithium running 24 neon running - gy-rpt shut off - nw65-01 shut off
Set Guest to Auto Start:-
[root@vm2 ~]# virsh autostart quincekvm Domain quince marked as autostarted
Stop and start Guest:-
[root@vm2 ~]# virsh shutdown elastixkvm Domain elastixkvm is being shutdown [root@vm2 ~]# [root@vm2 ~]# virsh start elastixkvm Domain elastixkvm started [root@vm2 ~]#
Export xml
virsh dumpxml target > /path/to/target.xml
Import xml file
root@optiplex ~]# virsh create /etc/libvirt/qemu/hydrogen.xml Domain hydrogen created from /etc/libvirt/qemu/hydrogen.xml [root@optiplex ~]# virsh list --all Id Name State ---------------------------------------------------- ...edited... 25 hydrogen running
Convert image to suitable format for KVM
Source was image used on VMware originally, this needed to be imported to KVM.
[root@optiplex nw65-01]# ls -l drwxr-xr-x 2 root root 4096 Apr 25 2015 Logs -rw------- 1 root root 1036648448 Apr 25 2015 nw65-01-disk1.vmdk [root@optiplex nw65-01]# file nw65-01-disk1.vmdk nw65-01-disk1.vmdk: VMware4 disk image [root@optiplex nw65-01]# qemu-img convert -f vmdk -O qcow2 nw65-01-disk1.vmdk nw65-01-disk1.qcow [root@optiplex nw65-01]# ls -l total 2024672 drwxr-xr-x 2 root root 4096 Apr 25 2015 Logs -rw-r--r-- 1 root root 1036648448 Sep 6 13:04 nw65-01-disk1.qcow -rw------- 1 root root 1036648448 Apr 25 2015 nw65-01-disk1.vmdk [root@optiplex nw65-01]# file nw65-01-disk1.qcow nw65-01-disk1.qcow: Qemu Image, Format: Qcow , Version: 2 [root@optiplex nw65-01]#
Despite being the same file size, the original vmdk and the new qcow2 images are different:-
[root@optiplex nw65-01]# md5sum nw65-01-disk1.qcow 1dd9fbb4ffe33caaa22b57f510494fff nw65-01-disk1.qcow [root@optiplex nw65-01]# md5sum nw65-01-disk1.vmdk 375f4632b70a655f92d8d2c9b0dc4bcb nw65-01-disk1.vmdk [root@optiplex nw65-01]#
Storage Pools
Storage pool is showing as inactive in web gui:-
root@kvm01:/data/iso# virsh pool-list --all Name State Autostart ------------------------------------------- default active yes iso inactive yes vm01 active yes root@kvm01:/data/iso# virsh pool-start iso Pool iso started root@kvm01:/data/iso# virsh pool-list --all Name State Autostart ------------------------------------------- default active yes iso active yes vm01 active yes
vm/kvm.txt · Last modified: by andrew