Search code examples
kernel-moduleqemublacklist

QEMU: blacklisting kernel module doesn't prevent it from showing up as available in `lspci`


I'm working in QEMU, and attempting to see if the guest can still use a PCI device without the corresponding kernel module loaded.

To start, lspci -v shows the following:

00:01.3 Bridge: Intel Corporation ########## PIIX4 ACPI (rev 03)
    Subsystem: Red Hat, Inc Qemu virtual machine
    Flags: medium devsel, IRQ 9
    Kernel modules: i2c_piix4

Before attempting to remove i2c_piix4, lsmod confirmed that it was loaded. To remove it, I edited /etc/modprobe.d/blacklist.conf and added the line blacklist i2c_piix4, then called sudo update-initramfs -u and rebooted. Now, the module has disappeared from lsmod, but is still listed under lspci. This is still true after modprobe -r. Have I properly blacklisted it, or is there another step I need to add?


Solution

  • lspci shows the hardware on the pci bus - no matter if a corresponding kernel module is loaded or not.

    To remove a device you can do this in the qemu monitor by id or locate it with info qtree and info qom-tree and remove it with device_del.

    But removing your specific device is not supported on the ps-i440fx architecture.

    (qemu) info qom-tree /machine/unattached/device[24]
    /device[24] (PIIX4_PM)
      /piix4-pm[0] (qemu:memory-region)
      /acpi-cpu-hotplug[0] (qemu:memory-region)
      /acpi-evt[0] (qemu:memory-region)
      /acpi-tmr[0] (qemu:memory-region)
      /apm-io[0] (qemu:memory-region)
      /bus master container[0] (qemu:memory-region)
      /bus master[0] (qemu:memory-region)
      /acpi-pci-hotplug[0] (qemu:memory-region)
      /pm-smbus[0] (qemu:memory-region)
      /acpi-gpe0[0] (qemu:memory-region)
      /i2c (i2c-bus)
      /acpi-cnt[0] (qemu:memory-region)
    (qemu)
    (qemu) device_del /machine/unattached/device[24]
    Device 'PIIX4_PM' does not support hotplugging
    (qemu)