Freeing host resources from the default device drivers

Red Hat Enterprise Linux 8.6 LPAR mode KVM guest

Proceed according to your type of pass-through device.

DASD

Write the bus ID of the DASD to the unbind attribute of its device driver module. Then, write the bus ID of the subchannel to the unbind attribute the subchannel device driver.

# echo <device_bus_id> > /sys/bus/ccw/drivers/dasd-eckd/unbind
# echo <subchannel_bus_id> > /sys/bus/css/devices/<subchannel_bus_id>/driver/unbind
Tip: Use the lscss command to obtain a mapping of device bus IDs and subchannel IDs.
Example: In this example, a DASD with bus ID 0.0.3000 is freed from the dasd-eckd device driver.
# lscss -d 0.0.3000
Device   Subchan. DevType CU Type Use PIM PAM POM CHPIDs
-------------------------------------------------------------------
0.0.3000 0.0.0004 3390/0A 3990/E9 YES C0  C0  FF  34400000 00000000
# echo 0.0.3000 > /sys/bus/ccw/drivers/dasd-eckd/unbind
# echo 0.0.0004 > /sys/bus/css/devices/0.0.0004/driver/unbind

PCIe devices

Before you begin: PCI devices can be configured for automatic management by libvirt (see the information about configuring VFIO pass-through devices in KVM Virtual Server Management, SC34-2752). This management includes a dynamic host preparation. Perform the steps that follow only for devices that are not managed by libvirt.
Write the function address of the PCIe device to the unbind attribute of its device driver.
# echo <function_address> > /sys/bus/pci/drivers/<pci_device_driver>/unbind
Tip: Issue lspci -v to find out which device driver controls the device of interest.
Example:
~]# lspci -v
0001:00:00.0 Ethernet controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 048d
Physical Slot: 00000015
...
Kernel driver in use: mlx4_core
Kernel modules: mlx4_core
# echo 0001:00:00.0 > /sys/bus/pci/drivers/mlx4_core/unbind

Cryptographic adapter resources

Cryptographic adapter resources are managed as AP queues (see Cryptographic domains). Two 256-bit masks, one for adapters and the other for domains, rule which AP queues are controlled by the zcrypt device driver.

Taking a crude approach, you could issue one of the following commands or both to free all AP queues from direct host control.
# echo 0x0 > /sys/bus/ap/apmask
# echo 0x0 > /sys/bus/ap/aqmask
After issuing these commands, all AP queues that were originally available to the host are now eligible for KVM guest use and the host can no longer use them.

For information about handling AP queues more selectively, see Kernel parameters and Freeing AP queues for KVM guests.