From 9b33c34a57e769d7580b704445a41a6494c4b41f Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 23 Nov 2022 16:26:30 +0100 Subject: [PATCH] Allow graphics mount discoverer to be instantiated independently Signed-off-by: Evan Lezar --- internal/discover/graphics.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/internal/discover/graphics.go b/internal/discover/graphics.go index 99b2a70b..c24cb4ad 100644 --- a/internal/discover/graphics.go +++ b/internal/discover/graphics.go @@ -33,6 +33,28 @@ import ( func NewGraphicsDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, cfg *Config) (Discover, error) { root := cfg.Root + mounts, err := NewGraphicsMountsDiscoverer(logger, root) + if err != nil { + return nil, fmt.Errorf("failed to create mounts discoverer: %v", err) + } + + drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, root) + if err != nil { + return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err) + } + + drmByPathSymlinks := newCreateDRMByPathSymlinks(logger, drmDeviceNodes, cfg) + + discover := Merge( + Merge(drmDeviceNodes, drmByPathSymlinks), + mounts, + ) + + return discover, nil +} + +// NewGraphicsMountsDiscoverer creates a discoverer for the mounts required by graphics tools such as vulkan. +func NewGraphicsMountsDiscoverer(logger *logrus.Logger, root string) (Discover, error) { locator, err := lookup.NewLibraryLocator(logger, root) if err != nil { return nil, fmt.Errorf("failed to construct library locator: %v", err) @@ -62,15 +84,7 @@ func NewGraphicsDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, }, ) - drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, root) - if err != nil { - return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err) - } - - drmByPathSymlinks := newCreateDRMByPathSymlinks(logger, drmDeviceNodes, cfg) - discover := Merge( - Merge(drmDeviceNodes, drmByPathSymlinks), libraries, jsonMounts, )