diff --git a/pixiecore/boot.ipxe b/pixiecore/boot.ipxe index 4b1efca..ac33df2 100644 --- a/pixiecore/boot.ipxe +++ b/pixiecore/boot.ipxe @@ -21,6 +21,16 @@ set user-class pixiecore echo metal-stack pixie +echo Manufacturer: ${manufacturer} + +# Detect serial console based on manufacturer. +# Implicitly ttyS1 is used as console for Supermicro. + +set console ttyS1 +set sp:hex 20 && set sp ${sp:string} +iseq ${manufacturer} Dell${sp}Inc. && set console ttyS0 || +iseq ${manufacturer} Giga${sp}Computing && set console ttyS0 || + # Try to get a filename from ProxyDHCP, retrying a couple of times if # we fail. :loop diff --git a/pixiecore/http.go b/pixiecore/http.go index f809fc2..4482a28 100644 --- a/pixiecore/http.go +++ b/pixiecore/http.go @@ -196,6 +196,7 @@ func ipxeScript(mach Machine, spec *Spec, serverHost string) ([]byte, error) { urlTemplate := fmt.Sprintf("http://%s/_/file?name=%%s&type=%%s&mac=%%s", serverHost) var b bytes.Buffer b.WriteString("#!ipxe\n") + b.WriteString("isset ${console} || set console ttyS1\n") u := fmt.Sprintf(urlTemplate, url.QueryEscape(string(spec.Kernel)), "kernel", url.QueryEscape(mach.MAC.String())) fmt.Fprintf(&b, "kernel --name kernel %s\n", u) for i, initrd := range spec.Initrd { @@ -218,6 +219,7 @@ func ipxeScript(mach Machine, spec *Spec, serverHost string) ([]byte, error) { if err != nil { return nil, fmt.Errorf("expanding cmdline %q: %w", spec.Cmdline, err) } + b.WriteString("console=${console},115200n8 ") b.WriteString(cmdline) b.WriteByte('\n') diff --git a/pixiecore/http_test.go b/pixiecore/http_test.go index bb23788..2422c34 100644 --- a/pixiecore/http_test.go +++ b/pixiecore/http_test.go @@ -66,12 +66,13 @@ func TestIpxe(t *testing.T) { } expected := `#!ipxe +isset ${console} || set console ttyS1 kernel --name kernel http://localhost:1234/_/file?name=k-01%3A02%3A03%3A04%3A05%3A06-0&type=kernel&mac=01%3A02%3A03%3A04%3A05%3A06 initrd --name initrd0 http://localhost:1234/_/file?name=i1-01%3A02%3A03%3A04%3A05%3A06-0&type=initrd&mac=01%3A02%3A03%3A04%3A05%3A06 initrd --name initrd1 http://localhost:1234/_/file?name=i2-01%3A02%3A03%3A04%3A05%3A06-0&type=initrd&mac=01%3A02%3A03%3A04%3A05%3A06 imgfetch --name ready http://localhost:1234/_/booting?mac=01%3A02%3A03%3A04%3A05%3A06 || imgfree ready || -boot kernel initrd=initrd0 initrd=initrd1 thing=http://localhost:1234/_/file?name=f-01%3A02%3A03%3A04%3A05%3A06-0 foo=bar +boot kernel initrd=initrd0 initrd=initrd1 console=${console},115200n8 thing=http://localhost:1234/_/file?name=f-01%3A02%3A03%3A04%3A05%3A06-0 foo=bar ` if rr.Body.String() != expected { t.Fatalf("Wrong iPXE script\nwant: %s\ngot: %s", expected, rr.Body.String()) @@ -91,12 +92,13 @@ boot kernel initrd=initrd0 initrd=initrd1 thing=http://localhost:1234/_/file?nam } expected = `#!ipxe +isset ${console} || set console ttyS1 kernel --name kernel http://localhost:1234/_/file?name=k-fe%3Afe%3Afe%3Afe%3Afe%3Afe-1&type=kernel&mac=fe%3Afe%3Afe%3Afe%3Afe%3Afe initrd --name initrd0 http://localhost:1234/_/file?name=i1-fe%3Afe%3Afe%3Afe%3Afe%3Afe-1&type=initrd&mac=fe%3Afe%3Afe%3Afe%3Afe%3Afe initrd --name initrd1 http://localhost:1234/_/file?name=i2-fe%3Afe%3Afe%3Afe%3Afe%3Afe-1&type=initrd&mac=fe%3Afe%3Afe%3Afe%3Afe%3Afe imgfetch --name ready http://localhost:1234/_/booting?mac=fe%3Afe%3Afe%3Afe%3Afe%3Afe || imgfree ready || -boot kernel initrd=initrd0 initrd=initrd1 thing=http://localhost:1234/_/file?name=f-fe%3Afe%3Afe%3Afe%3Afe%3Afe-1 foo=bar +boot kernel initrd=initrd0 initrd=initrd1 console=${console},115200n8 thing=http://localhost:1234/_/file?name=f-fe%3Afe%3Afe%3Afe%3Afe%3Afe-1 foo=bar ` if rr.Body.String() != expected { t.Fatalf("Wrong iPXE script\nwant: %s\ngot: %s", expected, rr.Body.String())