mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
Add support for hot-plugging IBM VFIO-AP devices
Add ExecuteAPVFIOMediatedDeviceAdd to qmp.go, which executes a hotplug for an IBM Adjunct processor (AP) VFIO device (see also https://www.kernel.org/doc/html/latest/s390/vfio-ap.html ) Also includes the respective unittest and adds the VfioAP DeviceDriver constant to qemu.go. Pushing again due to incidental CI failure Fixes: #133 Signed-off-by: Jakob-Naucke <jakob.naucke@ibm.com> Reviewed-by: alicefr <afrosi@redhat.com>
This commit is contained in:
parent
4c33e5e823
commit
39c372a201
@ -123,6 +123,9 @@ const (
|
|||||||
// VfioCCW is the vfio driver with CCW transport.
|
// VfioCCW is the vfio driver with CCW transport.
|
||||||
VfioCCW DeviceDriver = "vfio-ccw"
|
VfioCCW DeviceDriver = "vfio-ccw"
|
||||||
|
|
||||||
|
// VfioAP is the vfio driver with AP transport.
|
||||||
|
VfioAP DeviceDriver = "vfio-ap"
|
||||||
|
|
||||||
// VHostVSockPCI is a generic Vsock vhost device with PCI transport.
|
// VHostVSockPCI is a generic Vsock vhost device with PCI transport.
|
||||||
VHostVSockPCI DeviceDriver = "vhost-vsock-pci"
|
VHostVSockPCI DeviceDriver = "vhost-vsock-pci"
|
||||||
|
|
||||||
|
@ -1217,6 +1217,15 @@ func (q *QMP) ExecutePCIVFIOMediatedDeviceAdd(ctx context.Context, devID, sysfsd
|
|||||||
return q.executeCommand(ctx, "device_add", args, nil)
|
return q.executeCommand(ctx, "device_add", args, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExecuteAPVFIOMediatedDeviceAdd adds a VFIO mediated AP device to a QEMU instance using the device_add command.
|
||||||
|
func (q *QMP) ExecuteAPVFIOMediatedDeviceAdd(ctx context.Context, sysfsdev string) error {
|
||||||
|
args := map[string]interface{}{
|
||||||
|
"driver": VfioAP,
|
||||||
|
"sysfsdev": sysfsdev,
|
||||||
|
}
|
||||||
|
return q.executeCommand(ctx, "device_add", args, nil)
|
||||||
|
}
|
||||||
|
|
||||||
// isSocketIDSupported returns if the cpu driver supports the socket id option
|
// isSocketIDSupported returns if the cpu driver supports the socket id option
|
||||||
func isSocketIDSupported(driver string) bool {
|
func isSocketIDSupported(driver string) bool {
|
||||||
if driver == "host-s390x-cpu" || driver == "host-powerpc64-cpu" {
|
if driver == "host-s390x-cpu" || driver == "host-powerpc64-cpu" {
|
||||||
|
@ -1100,6 +1100,23 @@ func TestQMPPCIVFIOPCIeDeviceAdd(t *testing.T) {
|
|||||||
<-disconnectedCh
|
<-disconnectedCh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQMPAPVFIOMediatedDeviceAdd(t *testing.T) {
|
||||||
|
connectedCh := make(chan *QMPVersion)
|
||||||
|
disconnectedCh := make(chan struct{})
|
||||||
|
buf := newQMPTestCommandBuffer(t)
|
||||||
|
buf.AddCommand("device_add", nil, "return", nil)
|
||||||
|
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||||
|
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||||
|
checkVersion(t, connectedCh)
|
||||||
|
sysfsDev := "/sys/devices/vfio_ap/matrix/a297db4a-f4c2-11e6-90f6-d3b88d6c9525"
|
||||||
|
err := q.ExecuteAPVFIOMediatedDeviceAdd(context.Background(), sysfsDev)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unexpected error %v", err)
|
||||||
|
}
|
||||||
|
q.Shutdown()
|
||||||
|
<-disconnectedCh
|
||||||
|
}
|
||||||
|
|
||||||
// Checks that CPU are correctly added using device_add
|
// Checks that CPU are correctly added using device_add
|
||||||
func TestQMPCPUDeviceAdd(t *testing.T) {
|
func TestQMPCPUDeviceAdd(t *testing.T) {
|
||||||
drivers := []string{"host-x86_64-cpu", "host-s390x-cpu", "host-powerpc64-cpu"}
|
drivers := []string{"host-x86_64-cpu", "host-s390x-cpu", "host-powerpc64-cpu"}
|
||||||
|
Loading…
Reference in New Issue
Block a user