From e21cdf13a4d59c66cf0f4ee0055be3a9e3c1a2d9 Mon Sep 17 00:00:00 2001 From: Edward Guzman Date: Mon, 10 Sep 2018 17:47:52 -0700 Subject: [PATCH] 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 --- virtcontainers/device/drivers/vfio.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virtcontainers/device/drivers/vfio.go b/virtcontainers/device/drivers/vfio.go index b29cccd675..7b58eb781c 100644 --- a/virtcontainers/device/drivers/vfio.go +++ b/virtcontainers/device/drivers/vfio.go @@ -10,6 +10,7 @@ import ( "fmt" "io/ioutil" "path/filepath" + "strconv" "strings" "github.com/sirupsen/logrus" @@ -64,14 +65,14 @@ func (device *VFIODevice) Attach(devReceiver api.DeviceReceiver) error { } // Pass all devices in iommu group - for _, deviceFile := range deviceFiles { + for i, deviceFile := range deviceFiles { //Get bdf of device eg 0000:00:1c.0 deviceBDF, err := getBDF(deviceFile.Name()) if err != nil { return err } vfio := &config.VFIODev{ - ID: utils.MakeNameID("vfio", device.DeviceInfo.ID, maxDevIDSize), + ID: utils.MakeNameID("vfio", device.DeviceInfo.ID+strconv.Itoa(i), maxDevIDSize), BDF: deviceBDF, } device.vfioDevs = append(device.vfioDevs, vfio)