1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| func (p *FPGAPlugin) Allocate(ctx context.Context, req *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error) {
responses := &pluginapi.AllocateResponse{}
for _, cr := range req.ContainerRequests {
resp := &pluginapi.ContainerAllocateResponse{
Envs: map[string]string{
"FPGA_DEVICE_IDS": strings.Join(cr.DevicesIDs, ","),
"FPGA_BITSTREAM": "/opt/bitstreams/default.aocx",
},
Mounts: []*pluginapi.Mount{
{
ContainerPath: "/opt/bitstreams",
HostPath: "/opt/fpga/bitstreams",
ReadOnly: true,
},
},
Devices: []*pluginapi.DeviceSpec{},
}
for _, id := range cr.DevicesIDs {
resp.Devices = append(resp.Devices, &pluginapi.DeviceSpec{
HostPath: "/dev/xfpga/" + id,
ContainerPath: "/dev/xfpga/" + id,
Permissions: "rw",
})
}
responses.ContainerResponses = append(responses.ContainerResponses, resp)
}
return responses, nil
}
|