legacy-wiki
KVM
Recovered from the older tannerjc.net wiki snapshot dated January 23, 2016.
Installing
http://www.howtoforge.com/virtualization-with-kvm-on-a-fedora-11-server-p2
egrep '(vmx|svm)' --color=always /proc/cpuinfo
shows if CPU supports it, but check dmesg to see if it is enabled
dmesg|grep kvm
yum install kvm qemu libvirt python-virtinst virt-manager
service libvirtd start
chkconfig libvirtd on
yum install bridge-utils
chkconfig NetworkManager off
chkconfig network on
Bridging
http://fedora-tunisia.org/?q=node/69
- yum install bridge-utils
[root@sasha ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
[root@sasha ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=90:E6:BA:2E:2C:BB
NM_CONTROLLED=no
ONBOOT=yes
BRIDGE=br0
MTU=9000
adding an disks and isos
Listing guests
[root@workbox ~]# virsh list --all
Id Name State
----------------------------------
- F12test shut off
- rhel4 shut off
- rhel5-test shut off
Config files
[root@workbox qemu]# pwd
/etc/libvirt/qemu
[root@workbox qemu]# ls -al
total 24
drwx------. 3 root root 4096 2010-02-18 20:59 .
drwx------. 4 root root 4096 2010-02-18 19:57 ..
-rw-------. 1 root root 1099 2010-02-18 19:58 F12test.xml
drwx------. 3 root root 4096 2010-02-18 19:39 networks
-rw-------. 1 root root 1130 2010-02-18 20:59 rhel4.xml
-rw-------. 1 root root 880 2010-02-18 20:40 rhel5-test.xml
Image location
[root@workbox images]# pwd
/var/lib/libvirt/images
[root@workbox images]# ls -al
total 5930952
drwx------. 2 root root 4096 2010-02-18 20:59 .
drwxr-xr-x. 9 root root 4096 2010-02-18 19:39 ..
-rw-------. 1 root root 8589934592 2010-02-19 18:43 F12test.img
-rw-------. 1 root root 8589934592 2010-02-21 20:25 rhel4.img
-rw-------. 1 root root 8589934592 2010-02-18 20:46 rhel5-test.img
Cloning
[root@workbox ~]# virt-clone --original rhel5-test --name node1 --file /var/lib/libvirt/images/rhel5-node1.img
Cloning /var/lib/libvirt/images/rhel5-test.img | 8.0 GB 01:42
Clone 'node1' created successfully.
[root@workbox ~]# ls -al /etc/libvirt/qemu/node*
-rw-------. 1 root root 876 2010-02-21 20:31 /etc/libvirt/qemu/node1.xml
[root@workbox ~]# ls -al /var/lib/libvirt/images/rhel5-n*
-rwxr-xr-x. 1 root root 8589934592 2010-02-21 20:33 /var/lib/libvirt/images/rhel5-node1.img
[root@workbox qemu]# diff node1.xml node2.xml
2,3c2,3
namenode1/name
uuid266a2467-e4d4-e105-4753-a58761b094ee/uuid
---
namenode2/name
uuidf0e45701-4beb-a5f4-c709-01e67f0172f1/uuid
23c23
source file='/var/lib/libvirt/images/rhel5-node1.img'/
---
source file='/var/lib/libvirt/images/rhel5-node2.img'/
27c27
mac address='00:16:36:68:79:14'/
---
mac address='00:16:36:3e:fd:e4'/
serial console access
- RHEL4 requirements: reverse the serial and terminal lines in grub.conf defined by the RHEL5 kbase
- RHEL5 requirements: http://kbase.redhat.com/faq/docs/DOC-25454
Enumerating IP addresses
[root@workbox qemu]# fgrep mac address /etc/libvirt/qemu/node*
/etc/libvirt/qemu/node1.xml: mac address='00:16:36:68:79:14'/
/etc/libvirt/qemu/node2.xml: mac address='00:16:36:3e:fd:e4'/
/etc/libvirt/qemu/node3.xml: mac address='00:16:36:00:2e:11'/
[root@trainwreck ~]# arp -a | fgrep -v -e farina -e cpe
? (192.168.1.123) at 00:24:8c:43:75:f8 [ether] on eth1
? (192.168.1.58) at 00:16:36:3e:fd:e4 [ether] on eth1
? (192.168.1.65) at 00:16:36:00:2e:11 [ether] on eth1
? (192.168.1.51) at 00:16:36:68:79:14 [ether] on eth1
Adding a disk
[root@workbox qemu]# qemu-img create -f raw /var/lib/libvirt/images/rhel5-lvmtest-RAW.img 8GB
Formatting '/var/lib/libvirt/images/rhel5-lvmtest-RAW.img', fmt=raw, size=8388608 kB
[root@workbox qemu]# file /var/lib/libvirt/images/rhel5-lvmtest-RAW.img
/var/lib/libvirt/images/rhel5-lvmtest-RAW.img: data
[root@workbox qemu]# ls -alh /var/lib/libvirt/images/rhel5-lvmtest-RAW.img
-rw-r--r-- 1 root root 8.0G 2010-02-23 19:08 /var/lib/libvirt/images/rhel5-lvmtest-RAW.img