[zedboot][mexec] Pave and reboot if ZBI is signed.
It is not possbile to mexec() a signed ZBI at this time.
Change-Id: I071adebf7ea393d1872cd6407b0fca89b4d86ef1
diff --git a/botanist/boot.go b/botanist/boot.go
index 0e0ff1a..e0cdd1a 100644
--- a/botanist/boot.go
+++ b/botanist/boot.go
@@ -14,6 +14,7 @@
"net"
"os"
"sort"
+ "strings"
"time"
"go.fuchsia.dev/tools/build"
@@ -164,6 +165,7 @@
// This function serves to emulate zero-state, and will eventually be superseded by an
// infra implementation.
func BootZedbootShim(ctx context.Context, addr *net.UDPAddr, imgs []build.Image) error {
+ netsvcName := kernelNetsvcName
zirconRImg := build.Image{}
for _, img := range imgs {
for _, arg := range img.PaveArgs {
@@ -176,6 +178,10 @@
}
if name == zirconRNetsvcName {
zirconRImg = img
+ // Signed ZBIs cannot be mexec()'d, so pave them to A and boot instead.
+ if strings.HasSuffix(img.Name, ".signed") {
+ netsvcName = zirconANetsvcName
+ }
break
}
}
@@ -185,7 +191,7 @@
}
if zirconRImg.Name != "" {
- imgFile, err := openNetsvcFile(kernelNetsvcName, zirconRImg.Path)
+ imgFile, err := openNetsvcFile(netsvcName, zirconRImg.Path)
if err != nil {
return err
}
@@ -194,7 +200,10 @@
return err
}
n := netboot.NewClient(time.Second)
- return n.Boot(addr)
+ if netsvcName == kernelNetsvcName {
+ return n.Boot(addr)
+ }
+ return n.Reboot(addr)
}
return fmt.Errorf("no zircon-r image found in: %v", imgs)