Skip to content

Commit 5a126c1

Browse files
authored
Merge pull request #1847 from stgraber/vm
incusd/instance/edk2: Always prefer the EDK2 override
2 parents 00be2ea + 3e85a76 commit 5a126c1

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

internal/server/instance/drivers/edk2/driver_edk2.go

+14-19
Original file line numberDiff line numberDiff line change
@@ -194,29 +194,24 @@ func GetArchitectureFirmwarePairsForUsage(hostArch int, usage FirmwareUsage) ([]
194194
for _, installation := range GetArchitectureInstallations(hostArch) {
195195
usage, found := installation.Usage[usage]
196196
if found {
197-
searchPath := installation.Path
198-
199-
// If listed path doesn't exist, consider EDK2 override path.
200-
if !util.PathExists(searchPath) {
201-
if incusEdk2Path == "" {
202-
// No fallback path, skip entirely.
197+
// Prefer the EDK2 override path if provided.
198+
for _, searchPath := range []string{incusEdk2Path, installation.Path} {
199+
if searchPath == "" || !util.PathExists(searchPath) {
203200
continue
204201
}
205202

206-
searchPath = incusEdk2Path
207-
}
208-
209-
for _, firmwarePair := range usage {
210-
codePath := filepath.Join(searchPath, firmwarePair.Code)
211-
varsPath := filepath.Join(searchPath, firmwarePair.Vars)
212-
if !util.PathExists(codePath) || !util.PathExists(varsPath) {
213-
continue
203+
for _, firmwarePair := range usage {
204+
codePath := filepath.Join(searchPath, firmwarePair.Code)
205+
varsPath := filepath.Join(searchPath, firmwarePair.Vars)
206+
if !util.PathExists(codePath) || !util.PathExists(varsPath) {
207+
continue
208+
}
209+
210+
firmwares = append(firmwares, FirmwarePair{
211+
Code: codePath,
212+
Vars: varsPath,
213+
})
214214
}
215-
216-
firmwares = append(firmwares, FirmwarePair{
217-
Code: codePath,
218-
Vars: varsPath,
219-
})
220215
}
221216
}
222217
}

0 commit comments

Comments
 (0)