2

I'm trying to gpu passthrough with qemu-kvm using virsh on Lubuntu 17.10

I installed Windows 7 (UEFI) and it runs ok but the device driver doesn't install saying

Insufficient resource (error 12).

so I dumped gpu rom and added

<rom bar='on' file='/home/gpu.dump'/>

in <hostdev> of gpu pci.

I did

chmod 777 /home 

and

gpu.dump, user = "root" group = "root" 

in advance

Whenever I add rom... line in virsh script, I encounter an error message like this

############################################################################### "Error starting domain: internal error: process exited while connecting to monitor: 2017-12-13T09:45:38.629221Z qemu-system-x86_64:
-chardev pty,id=charserial0: char device redirected to /dev/pts/2 (label charserial0) 2017-12-13T09:45:39.146358Z qemu-system-x86_64:
-device vfio-pci,host=03:00.0,id=hostdev0,bus=pci.0,addr=0x7,romfile=/home/gt710.dump: failed to find romfile "/home/gt710.dump"

Traceback (most recent call last):   File "/usr/share/virt-manager/virtManager/asyncjob.py", line 88, in cb_wrapper
    callback(asyncjob, *args, **kwargs)   File "/usr/share/virt-manager/virtManager/asyncjob.py", line 124, in tmpcb
    callback(*args, **kwargs)   File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 83, in newfn
    ret = fn(self, *args, **kwargs)   File "/usr/share/virt-manager/virtManager/domain.py", line 1405, in startup
    self._backend.create()   File "/usr/lib/python2.7/dist-packages/libvirt.py", line 1062, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self) libvirtError: internal error: process exited while connecting to monitor: 2017-12-13T09:45:38.629221Z qemu-system-x86_64:
-chardev pty,id=charserial0: char device redirected to /dev/pts/2 (label charserial0) 2017-12-13T09:45:39.146358Z qemu-system-x86_64:
-device vfio-pci,host=03:00.0,id=hostdev0,bus=pci.0,addr=0x7,romfile=/home/gt710.dump: failed to find romfile "/home/gt710.dump"
###############################################################################

What should I do now? I couldn't sleep about 30hrs :-(

2 Answers 2

12

If this error because of AppArmor, just move ROM file to /usr/share/vgabios (make this dir if it not exists). This path is allowed to be read from kvm-qemu by default apparmor profile.

Some other allowed by default paths:

  # access to firmware's etc
  /usr/share/kvm/** r,
  /usr/share/qemu/** r,
  /usr/share/qemu-kvm/** r,
  /usr/share/bochs/** r,
  /usr/share/openbios/** r,
  /usr/share/openhackware/** r,
  /usr/share/proll/** r,
  /usr/share/vgabios/** r,
  /usr/share/seabios/** r,
  /usr/share/misc/sgabios.bin r,
  /usr/share/ovmf/** r,
  /usr/share/OVMF/** r,
  /usr/share/AAVMF/** r,
  /usr/share/qemu-efi/** r,
  /usr/share/slof/** r,
0

The 'failed to find romfile' error is most likely because AppArmor should be enabled by default in Ubuntu (at least in Ubuntu Desktop/Server, otherwise the issue is likely SELinux similarly to the below solution for AppArmor):

Solution

libvirt automatically creates/manages AppArmor profiles stored in /etc/apparmor.d/libvirt/ for each vm. The process adds file exceptions for certain devices bound to the vm (I'm not an expert on it, but it seems like it doesn't count the rom file).

But you can force it into adding an exception for the rom file by adding any type of device sourced from a file. I use a fake cd drive that looks like the following:

Add the following code to your xml configuration:

<devices>
...
<disk type='file' device='cdrom'>
    <driver name='qemu' type='raw'/>
    <source file='/path/to/the.rom'/>
    <target dev='sdb' bus='sata'/>
    <readonly/>
</disk>
...
</devices>

If you are still having issues

This is generally not recommended as it will disable AppArmor protection entirely for this one VM.

  1. Look at your configuration: virsh edit VMNAME

  2. Find the uuid line that looks like: <uuid>YOUR-UUID</uuid>

  3. Run sudo aa-complain /etc/apparmor.d/libvirt/libvirt-YOUR-UUId to disable the enforcement of the policy

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .