Skip to content

Commit 3fcfb26

Browse files
committed
exclude gpu audio controller
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
1 parent 42ed727 commit 3fcfb26

6 files changed

Lines changed: 23 additions & 176 deletions

File tree

pkg/capacity/pci.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ next:
346346
continue next
347347
}
348348
}
349-
349+
// skip audio controller of the gpu cards as @delandtj suggested until we found better sol
350+
if strings.HasSuffix(pci.Slot, ".1") {
351+
continue next
352+
}
350353
devices = append(devices, pci)
351354
}
352355

pkg/primitives/vm-light/vm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/threefoldtech/zosbase/pkg"
1515
"github.com/threefoldtech/zosbase/pkg/gridtypes"
1616
"github.com/threefoldtech/zosbase/pkg/gridtypes/zos"
17+
"github.com/threefoldtech/zosbase/pkg/primitives/vmgpu"
1718
provision "github.com/threefoldtech/zosbase/pkg/provision"
1819
"github.com/threefoldtech/zosbase/pkg/stubs"
1920
)
@@ -40,7 +41,7 @@ func NewManager(zbus zbus.Client) *Manager {
4041
}
4142

4243
func (m *Manager) Initialize(ctx context.Context) error {
43-
return m.initGPUs()
44+
return vmgpu.InitGPUs()
4445
}
4546

4647
func (p *Manager) Provision(ctx context.Context, wl *gridtypes.WorkloadWithID) (interface{}, error) {
@@ -148,7 +149,7 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes
148149
}
149150

150151
// expand GPUs
151-
devices, err := p.expandGPUs(config.GPU)
152+
devices, err := vmgpu.ExpandGPUs(config.GPU)
152153
if err != nil {
153154
return result, errors.Wrap(err, "failed to prepare requested gpu device(s)")
154155
}

pkg/primitives/vm/gpu.go

Lines changed: 0 additions & 163 deletions
This file was deleted.

pkg/primitives/vm/pause.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55

66
"github.com/threefoldtech/zosbase/pkg/gridtypes"
7-
"github.com/threefoldtech/zosbase/pkg/provision"
7+
provision "github.com/threefoldtech/zosbase/pkg/provision"
88
"github.com/threefoldtech/zosbase/pkg/stubs"
99
)
1010

pkg/primitives/vm/vm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/threefoldtech/zosbase/pkg"
1515
"github.com/threefoldtech/zosbase/pkg/gridtypes"
1616
"github.com/threefoldtech/zosbase/pkg/gridtypes/zos"
17+
"github.com/threefoldtech/zosbase/pkg/primitives/vmgpu"
1718
"github.com/threefoldtech/zosbase/pkg/provision"
1819
"github.com/threefoldtech/zosbase/pkg/stubs"
1920
)
@@ -40,7 +41,7 @@ func NewManager(zbus zbus.Client) *Manager {
4041
}
4142

4243
func (m *Manager) Initialize(ctx context.Context) error {
43-
return m.initGPUs()
44+
return vmgpu.InitGPUs()
4445
}
4546

4647
func (p *Manager) Provision(ctx context.Context, wl *gridtypes.WorkloadWithID) (interface{}, error) {
@@ -148,7 +149,7 @@ func (p *Manager) virtualMachineProvisionImpl(ctx context.Context, wl *gridtypes
148149
}
149150

150151
// expand GPUs
151-
devices, err := p.expandGPUs(config.GPU)
152+
devices, err := vmgpu.ExpandGPUs(config.GPU)
152153
if err != nil {
153154
return result, errors.Wrap(err, "failed to prepare requested gpu device(s)")
154155
}
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package vmlight
1+
package vmgpu
22

33
import (
44
"fmt"
55
"os"
66
"os/exec"
77
"path/filepath"
8+
"strings"
89

910
"github.com/pkg/errors"
1011
"github.com/rs/zerolog/log"
@@ -22,7 +23,7 @@ var (
2223
modules = []string{"vfio", "vfio-pci", "vfio_iommu_type1"}
2324
)
2425

25-
func (m *Manager) initGPUVfioModules() error {
26+
func InitGPUVfioModules() error {
2627
for _, mod := range modules {
2728
if err := exec.Command("modprobe", mod).Run(); err != nil {
2829
return errors.Wrapf(err, "failed to probe module: %s", mod)
@@ -38,7 +39,7 @@ func (m *Manager) initGPUVfioModules() error {
3839
}
3940

4041
// unbindBootVga is a helper method to disconnect the boot vga if needed
41-
func (m *Manager) unbindBootVga() error {
42+
func UnbindBootVga() error {
4243
const vtConsole = "/sys/class/vtconsole"
4344
vts, err := os.ReadDir(vtConsole)
4445
if err != nil && !os.IsNotExist(err) {
@@ -59,11 +60,11 @@ func (m *Manager) unbindBootVga() error {
5960
}
6061

6162
// this function will make sure ALL gpus are bind to the right driver
62-
func (m *Manager) initGPUs() error {
63+
func InitGPUs() error {
6364
if kernel.GetParams().IsGPUDisabled() {
6465
return nil
6566
}
66-
if err := m.initGPUVfioModules(); err != nil {
67+
if err := InitGPUVfioModules(); err != nil {
6768
return err
6869
}
6970

@@ -79,7 +80,7 @@ func (m *Manager) initGPUs() error {
7980
}
8081

8182
if bootVga > 0 {
82-
if err := m.unbindBootVga(); err != nil {
83+
if err := UnbindBootVga(); err != nil {
8384
log.Warn().Err(err).Msg("error while unbinding boot vga")
8485
}
8586
}
@@ -130,7 +131,7 @@ func (m *Manager) initGPUs() error {
130131
// It's required that all devices in an iommu group to be passed together to a VM
131132
// hence we need that for each GPU in the list add all the devices from each device
132133
// IOMMU group
133-
func (m *Manager) expandGPUs(gpus []zos.GPU) ([]capacity.PCI, error) {
134+
func ExpandGPUs(gpus []zos.GPU) ([]capacity.PCI, error) {
134135
if kernel.GetParams().IsGPUDisabled() {
135136
return nil, fmt.Errorf("GPU is disabled on this node")
136137
}
@@ -155,6 +156,10 @@ func (m *Manager) expandGPUs(gpus []zos.GPU) ([]capacity.PCI, error) {
155156
if err != nil {
156157
return nil, errors.Wrapf(err, "failed to list all devices belonging to '%s'", device.Slot)
157158
}
159+
// skip audio controller of the gpu cards as @delandtj suggested until we found better sol
160+
if strings.HasSuffix(device.Slot, ".1") {
161+
continue
162+
}
158163

159164
devices = append(devices, sub...)
160165
}

0 commit comments

Comments
 (0)