Skip to content

Commit 5f8833c

Browse files
committed
qemu: UEFI: fix warning Unexpected result from downloader.Download()
Fix issue 2083 Signed-off-by: Akihiro Suda <[email protected]>
1 parent 9d4eccb commit 5f8833c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

pkg/qemu/qemu.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -571,25 +571,33 @@ func Cmdline(cfg Config) (exe string, args []string, err error) {
571571
}
572572
if !legacyBIOS {
573573
var firmware string
574-
for _, f := range y.Firmware.Images {
575-
switch f.VMType {
576-
case "", limayaml.QEMU:
577-
if f.Arch == *y.Arch {
578-
firmwareCandidate := filepath.Join(cfg.InstanceDir, filenames.QemuEfiCodeFD)
579-
if _, err = fileutils.DownloadFile(firmwareCandidate, f.File, true, "UEFI code", *y.Arch); err != nil {
580-
logrus.WithError(err).Warnf("failed to download %q", f.Location)
581-
continue
574+
downloadedFirmware := filepath.Join(cfg.InstanceDir, filenames.QemuEfiCodeFD)
575+
if _, stErr := os.Stat(downloadedFirmware); errors.Is(stErr, os.ErrNotExist) {
576+
loop:
577+
for _, f := range y.Firmware.Images {
578+
switch f.VMType {
579+
case "", limayaml.QEMU:
580+
if f.Arch == *y.Arch {
581+
if _, err = fileutils.DownloadFile(downloadedFirmware, f.File, true, "UEFI code "+f.Location, *y.Arch); err != nil {
582+
logrus.WithError(err).Warnf("failed to download %q", f.Location)
583+
continue loop
584+
}
585+
firmware = downloadedFirmware
586+
logrus.Infof("Using firmware %q (downloaded from %q)", firmware, f.Location)
587+
break loop
582588
}
583-
firmware = firmwareCandidate
584-
break
585589
}
586590
}
591+
} else {
592+
firmware = downloadedFirmware
593+
logrus.Infof("Using existing firmware (%q)", firmware)
587594
}
588595
if firmware == "" && *y.Arch != limayaml.RISCV64 {
589596
firmware, err = getFirmware(exe, *y.Arch)
590597
if err != nil {
591598
return "", nil, err
592599
}
600+
logrus.Infof("Using system firmware (%q)", firmware)
593601
}
594602
if firmware != "" {
595603
args = append(args, "-drive", fmt.Sprintf("if=pflash,format=raw,readonly=on,file=%s", firmware))

0 commit comments

Comments
 (0)