Skip to content

Installing KVM on CentOs 6.7

Kyuho Jeong edited this page Jan 5, 2016 · 1 revision
sudo yum install kvm libvirt
sudo service libvirtd restart

You should also refer to the documents of (https://github.com/ipop-project/Documentation/wiki/Installing-KVM-on-cloudlab)

On Centos, OS ISO file and disk image file must be placed at /var/lib/libvirt/images

XML file template

<domain type='kvm'>
  <name>vm0</name>
  <uuid>f5b8c05b-9c7a-3211-49b9-2bd635f7e2ab</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type>hvm</type>
    <boot dev='cdrom'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="raw"/>
      <source file="/var/lib/libvirt/images/vm0.img"/>
      <target dev="vda" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/var/lib/libvirt/images/CentOS-6.7-x86_64-bin-DVD1.iso"/>
      <target dev="hdc" bus="ide"/>
      <readonly/>
      <address type="drive" controller="0" bus="1" target="0" unit="0"/>
    </disk>
    <controller type="ide" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
    </controller>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport="yes" listen='0.0.0.0'/>
    <console type='pty'>
      <target port='0'/>
    </console>
    <interface type='bridge'>
      <mac address='52:54:00:d1:6d:b9'/>
      <source bridge='virbr0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:d1:6d:ba'/>
    </interface>
  </devices>
</domain>

If your network administrator is strict, you need to check the firewall rules. Make sure that the VNC port is allowed.

sudo iptables -L

And don't forget the last reject line, if there was.

REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Maybe your second network interface is attached to virbr0 as well, you may want to detach it manually.

Clone this wiki locally