devices: add per-device VFIO ids

Adds per-device VFIO ids allowing IOMMU groups with
multiple devices to be passed to qemu.

Fixes #708

Signed-off-by: Edward Guzman <eguzman@nvidia.com>
This commit is contained in:
Edward Guzman 2018-09-10 17:47:52 -07:00
parent e02695bf7b
commit e21cdf13a4

View File

@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
"strconv"
"strings" "strings"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -64,14 +65,14 @@ func (device *VFIODevice) Attach(devReceiver api.DeviceReceiver) error {
} }
// Pass all devices in iommu group // Pass all devices in iommu group
for _, deviceFile := range deviceFiles { for i, deviceFile := range deviceFiles {
//Get bdf of device eg 0000:00:1c.0 //Get bdf of device eg 0000:00:1c.0
deviceBDF, err := getBDF(deviceFile.Name()) deviceBDF, err := getBDF(deviceFile.Name())
if err != nil { if err != nil {
return err return err
} }
vfio := &config.VFIODev{ vfio := &config.VFIODev{
ID: utils.MakeNameID("vfio", device.DeviceInfo.ID, maxDevIDSize), ID: utils.MakeNameID("vfio", device.DeviceInfo.ID+strconv.Itoa(i), maxDevIDSize),
BDF: deviceBDF, BDF: deviceBDF,
} }
device.vfioDevs = append(device.vfioDevs, vfio) device.vfioDevs = append(device.vfioDevs, vfio)