lspci and VM passthrough
Chris-Peterson444 opened this issue · comments
Inspired by your fake-devices-wrapper
in ubuntu-drivers-common in Ubuntu I am trying to generate fake PCI devices to pass to a virtual machine (QEMU) to test automatic detection of drivers for installation. Although to do this I need to get the output of lspci
to pass the host address to the vfio-pci
driver in qemu.
The problem is that I get the following when trying to run lspci
with the wrapper script (w/ the aticard device for example):
lspci: sysfs_scan: Couldn't parse entry name aticard
This happens with all of the devices and I haven't figured out a way to make sysfs_scan happy.
I enabled extra logging with UMOCKDEV_DEBUG=all
and an extra line is printed:
testbed wrapped opendir(/sys/bus/pci/devices) -> /tmp/umockdev.DDN3K2/sys/bus/pci/devices
which is correct. I suspect there's something I missing with the setup of the test devices, but I'm not sure how to investigate further.
Any hints on how to debug this further (or tips for mocking devices in a VM) would be greatly appreciated.
I got a little more traction on this. lspci
is expecting a device formatted like %x:%x:%x.%d
, which is alright because now this is starting to look like the kind of format QEMU is expecting. Although now wrapping QEMU we get
testbed wrapped stat64(/sys/bus/pci/devices/0040:00:00.0) -> /tmp/umockdev.9LKRK2/sys/bus/pci/devices/0040:00:00.0
kvm: -device vfio-pci,host=40:0:0.0: vfio /sys/bus/pci/devices/0040:00:00.0: no such host device: No such file or directory
Which is certainly not true, I stat the file just fine, but perhaps the error is hiding more and there's some more configuration here I'm missing.
It's also useful to strace the process with and without umockdev wrapping. That's what I usually do when new glibc versions break the tests. It could also just be that this uses the 37th variant of some fxstatat64withbenefits() syscall that the preload doesn't wrap? Your debug excerpt certainly makes it seem that this isn't the case, but strace is more thorough.