Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lspci and VM passthrough #235

Open
Chris-Peterson444 opened this issue Mar 14, 2024 · 2 comments
Open

lspci and VM passthrough #235

Chris-Peterson444 opened this issue Mar 14, 2024 · 2 comments

Comments

@Chris-Peterson444
Copy link

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.

@Chris-Peterson444
Copy link
Author

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.

@martinpitt
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants