mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-18 14:54:19 +01:00
runtime: Add support for VFIO-AP pass-through
Recognise when a device to be hot-plugged is an IBM Adjunct Processor (AP) device and execute VFIO AP hot-plug accordingly. Includes unittest for recognising and uses CCW for addDeviceToBridge in hotplugVFIODevice if appropriate. Fixes: #491 Signed-off-by: Jakob-Naucke <jakob.naucke@ibm.com> Co-authored-by: Julio Montes <julio.montes@intel.com> Reviewed-by: Alice Frosi <afrosi@redhat.com>
This commit is contained in:
@@ -712,30 +712,34 @@ func (q *qemuArchBase) setIgnoreSharedMemoryMigrationCaps(ctx context.Context, q
|
||||
}
|
||||
|
||||
func (q *qemuArchBase) addDeviceToBridge(ID string, t types.Type) (string, types.Bridge, error) {
|
||||
addr, b, err := genericAddDeviceToBridge(q.Bridges, ID, t)
|
||||
if err != nil {
|
||||
return "", b, err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%02x", addr), b, nil
|
||||
}
|
||||
|
||||
func genericAddDeviceToBridge(bridges []types.Bridge, ID string, t types.Type) (uint32, types.Bridge, error) {
|
||||
var err error
|
||||
var addr uint32
|
||||
|
||||
if len(q.Bridges) == 0 {
|
||||
return "", types.Bridge{}, errors.New("failed to get available address from bridges")
|
||||
if len(bridges) == 0 {
|
||||
return 0, types.Bridge{}, errors.New("failed to get available address from bridges")
|
||||
}
|
||||
|
||||
// looking for an empty address in the bridges
|
||||
for _, b := range q.Bridges {
|
||||
for _, b := range bridges {
|
||||
if t != b.Type {
|
||||
continue
|
||||
}
|
||||
addr, err = b.AddDevice(ID)
|
||||
if err == nil {
|
||||
switch t {
|
||||
case types.CCW:
|
||||
return fmt.Sprintf("%04x", addr), b, nil
|
||||
case types.PCI, types.PCIE:
|
||||
return fmt.Sprintf("%02x", addr), b, nil
|
||||
}
|
||||
return addr, b, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", types.Bridge{}, fmt.Errorf("no more bridge slots available")
|
||||
return 0, types.Bridge{}, fmt.Errorf("no more bridge slots available")
|
||||
}
|
||||
|
||||
func (q *qemuArchBase) removeDeviceFromBridge(ID string) error {
|
||||
|
||||
Reference in New Issue
Block a user