gokrazy: register appliance AMIs as HVM
register-image defaults to paravirtual: arm64 rejects it outright and amd64 won't boot on Nitro. Force HVM; pick UEFI boot mode per arch. Updates #1866 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
committed by
Kristoffer Dalby
parent
5e0972344a
commit
e212b075a7
+11
-6
@@ -291,23 +291,28 @@ func waitForImportSnapshot(importTaskID string) (snapID string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeAMI(name, ebsSnapID string) (ami string, err error) {
|
func makeAMI(name, ebsSnapID string) (ami string, err error) {
|
||||||
var arch string
|
var arch, bootMode string
|
||||||
switch conf.GOARCH() {
|
switch conf.GOARCH() {
|
||||||
case "arm64":
|
case "arm64":
|
||||||
arch = "arm64"
|
// arm64 instances boot UEFI-only; "uefi-preferred" is rejected.
|
||||||
|
arch, bootMode = "arm64", "uefi"
|
||||||
case "amd64":
|
case "amd64":
|
||||||
arch = "x86_64"
|
arch, bootMode = "x86_64", "uefi-preferred"
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("unknown arch %q", conf.GOARCH())
|
return "", fmt.Errorf("unknown arch %q", conf.GOARCH())
|
||||||
}
|
}
|
||||||
out, err := exec.Command("aws", "ec2", "register-image",
|
out, err := exec.Command("aws", "ec2", "register-image",
|
||||||
"--name", name,
|
"--name", name,
|
||||||
"--architecture", arch,
|
"--architecture", arch,
|
||||||
"--root-device-name", "/dev/sda",
|
// register-image defaults to paravirtual; arm64 rejects that
|
||||||
|
// ("supports HVM AMIs only") and amd64 would produce an image that
|
||||||
|
// won't boot on Nitro. Both need HVM.
|
||||||
|
"--virtualization-type", "hvm",
|
||||||
|
"--root-device-name", "/dev/sda1",
|
||||||
"--ena-support",
|
"--ena-support",
|
||||||
"--imds-support", "v2.0",
|
"--imds-support", "v2.0",
|
||||||
"--boot-mode", "uefi-preferred",
|
"--boot-mode", bootMode,
|
||||||
"--block-device-mappings", "DeviceName=/dev/sda,Ebs={SnapshotId="+ebsSnapID+"}").CombinedOutput()
|
"--block-device-mappings", "DeviceName=/dev/sda1,Ebs={SnapshotId="+ebsSnapID+"}").CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("register image: %v: %s", err, out)
|
return "", fmt.Errorf("register image: %v: %s", err, out)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user