Saturday, July 21, 2012

KVM VFIO

1. Download source

1.1 Download linux-vfio kernel source
$ git clone git://github.com/awilliam/linux-vfio.git
1.2. Download qemu-vfio
$ git clone git://github.com/awilliam/qemu-vfio.git iommu-group-vfio

2. Compile and install

2.1 Compile qemu
$ ./configure --prefix=/usr
$ make
$ sudo make install

2.2 Compile kernel
# make menuconfig
IMPORTANT: Mark VFIO related options as , which means make them removable modules, not builtin modules. (Because you might need to reload them in the future.)
# make
# make modules_install install

3. Run kvm 

Start kvm with usual command plus :
# kvm ... -device vfio-pci,host=01:00.0,id=hostdev0

Error:
Failed to set iommu for container: Operation not permitted Failed to setup container for group 1

Solution[1]:
Check dmesg, it's probably complaining about no interrupt remapping support. If so:
# modprobe -r vfio_iommu_type1
# modprobe vfio_iommu_type1 allow_unsafe_interrupts=1

[1] http://www.mail-archive.com/kvm@vger.kernel.org/msg73068.html

4 comments:

  1. Getting error
    root@vmhost:/usr/bin/iommu-group-vfio# make menuconfig
    CHK version_gen.h
    make: *** No rule to make target `menuconfig'. Stop.

    Followed the instructions to a 'T' but get the above error message. Any idea why ?

    Jay / CompuMatter

    ReplyDelete
    Replies
    1. make menuconfig should be done at the root of a kernel source tree, not under the vfio source tree.

      Delete
  2. Hello, I'm trying to install VFIO
    But when I make linux-vfio, it got error

    drivers/regulator/s2mps11.c:441:23: error: ‘struct sec_pmic_dev’ has no member named ‘regmap’

    Any idea?

    ReplyDelete
    Replies
    1. I got solution by myself

      the code that says error is
      config.regmap = iodev->regmap;

      just change this to:
      config.regmap = iodev->regmap_pmic;

      And compile goes success.

      Delete