diff --git a/mantle/cmd/kola/kola.go b/mantle/cmd/kola/kola.go index bc7606db3f..77ad7fbca7 100644 --- a/mantle/cmd/kola/kola.go +++ b/mantle/cmd/kola/kola.go @@ -275,7 +275,6 @@ func writeProps() error { Platform: kolaPlatform, Distro: kola.Options.Distribution, IgnitionVersion: kola.Options.IgnitionVersion, - Board: kola.QEMUOptions.Board, OSContainer: kola.Options.OSContainer, AWS: AWS{ Region: kola.AWSOptions.Region, diff --git a/mantle/cmd/kola/options.go b/mantle/cmd/kola/options.go index 338884e1e4..b200894c12 100644 --- a/mantle/cmd/kola/options.go +++ b/mantle/cmd/kola/options.go @@ -30,7 +30,6 @@ import ( var ( outputDir string kolaPlatform string - defaultTargetBoard = sdk.DefaultBoard() kolaArchitectures = []string{"amd64"} kolaPlatforms = []string{"aws", "azure", "do", "esx", "gce", "openstack", "packet", "qemu", "qemu-unpriv"} kolaDistros = []string{"fcos", "rhcos"} @@ -133,7 +132,6 @@ func init() { sv(&kola.PacketOptions.StorageURL, "packet-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Google Storage base URL for temporary uploads") // QEMU-specific options - sv(&kola.QEMUOptions.Board, "board", defaultTargetBoard, "target board") sv(&kola.QEMUOptions.Firmware, "qemu-firmware", "bios", "Boot firmware: bios,uefi,uefi-secure") sv(&kola.QEMUOptions.DiskImage, "qemu-image", "", "path to CoreOS disk image") sv(&kola.QEMUOptions.DiskSize, "qemu-size", "", "Resize target disk via qemu-img resize [+]SIZE") diff --git a/mantle/cmd/kola/qemuexec.go b/mantle/cmd/kola/qemuexec.go index dcbe47dcdb..c53b8f6258 100644 --- a/mantle/cmd/kola/qemuexec.go +++ b/mantle/cmd/kola/qemuexec.go @@ -57,7 +57,7 @@ func init() { func runQemuExec(cmd *cobra.Command, args []string) error { var err error - builder := platform.NewBuilder(kola.QEMUOptions.Board, ignition, forceConfigInjection) + builder := platform.NewBuilder(ignition, forceConfigInjection) if len(knetargs) > 0 { builder.IgnitionNetworkKargs = knetargs } diff --git a/mantle/cmd/kola/testiso.go b/mantle/cmd/kola/testiso.go index e3423bbea5..fd08aff27b 100644 --- a/mantle/cmd/kola/testiso.go +++ b/mantle/cmd/kola/testiso.go @@ -84,7 +84,6 @@ func runTestIso(cmd *cobra.Command, args []string) error { CosaBuildDir: kola.Options.CosaBuild, CosaBuild: kola.CosaBuild, - Board: kola.QEMUOptions.Board, Firmware: kola.QEMUOptions.Firmware, } diff --git a/mantle/kola/tests/ignition/mount.go b/mantle/kola/tests/ignition/mount.go index 60e08f4464..63c3a432cf 100644 --- a/mantle/kola/tests/ignition/mount.go +++ b/mantle/kola/tests/ignition/mount.go @@ -21,12 +21,12 @@ import ( ignconverter "github.com/coreos/ign-converter" ignv3types "github.com/coreos/ignition/v2/config/v3_0/types" - "github.com/coreos/mantle/kola" "github.com/coreos/mantle/kola/cluster" "github.com/coreos/mantle/kola/register" "github.com/coreos/mantle/platform" "github.com/coreos/mantle/platform/conf" "github.com/coreos/mantle/platform/machine/unprivqemu" + "github.com/coreos/mantle/system" "github.com/coreos/mantle/util" ) @@ -181,7 +181,7 @@ func createClusterValidate(c cluster.TestCluster, options platform.MachineOption func setupIgnitionConfig() { containerpartdeviceid := "by-partlabel/CONTR" logpartdeviceid := "by-partlabel/LOG" - if kola.QEMUOptions.Board == "s390x-usr" { + if system.RpmArch() == "s390x" { containerpartdeviceid = "by-partuuid/63194b49-e4b7-43f9-9a8b-df0fd8279bb7" logpartdeviceid = "by-partuuid/6385b84e-2c7b-4488-a870-667c565e01a8" } diff --git a/mantle/platform/machine/unprivqemu/cluster.go b/mantle/platform/machine/unprivqemu/cluster.go index 0e2f0a0e03..efab7849b4 100644 --- a/mantle/platform/machine/unprivqemu/cluster.go +++ b/mantle/platform/machine/unprivqemu/cluster.go @@ -87,8 +87,7 @@ func (qc *Cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo consolePath: filepath.Join(dir, "console.txt"), } - board := qc.flight.opts.Board - builder := platform.NewBuilder(board, confPath, false) + builder := platform.NewBuilder(confPath, false) defer builder.Close() builder.Uuid = qm.id builder.Firmware = qc.flight.opts.Firmware diff --git a/mantle/platform/metal.go b/mantle/platform/metal.go index 2b4fb8253f..a805efea49 100644 --- a/mantle/platform/metal.go +++ b/mantle/platform/metal.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/coreos/mantle/cosa" + "github.com/coreos/mantle/system" "github.com/coreos/mantle/system/exec" "github.com/pkg/errors" ) @@ -36,10 +37,10 @@ var liveKargs = []string{"ignition.firstboot", "ignition.platform.id=metal"} var ( // TODO expose this as an API that can be used by cosa too consoleKernelArgument = map[string]string{ - "amd64-usr": "ttyS0", - "ppc64le-usr": "hvc0", - "arm64-usr": "ttyAMA0", - "s390x-usr": "ttysclp0", + "x86_64": "ttyS0", + "ppc64le": "hvc0", + "aarch64": "ttyAMA0", + "s390x": "ttysclp0", } ) @@ -47,7 +48,6 @@ type Install struct { CosaBuildDir string CosaBuild *cosa.Build - Board string Firmware string Insecure bool QemuArgs []string @@ -199,7 +199,7 @@ func (inst *Install) setup(kern *kernelSetup) (*installerRun, error) { return nil, fmt.Errorf("Missing initramfs artifact") } - builder := NewBuilder(inst.Board, "", false) + builder := NewBuilder("", false) builder.Firmware = inst.Firmware builder.AddDisk(&Disk{ Size: "12G", // Arbitrary @@ -207,7 +207,7 @@ func (inst *Install) setup(kern *kernelSetup) (*installerRun, error) { // This applies just in the legacy case builder.Memory = 1536 - if inst.Board == "s390x-usr" { + if system.RpmArch() == "s390x" { // FIXME - determine why this is builder.Memory = int(math.Max(float64(builder.Memory), 16384)) } @@ -245,23 +245,23 @@ func (inst *Install) setup(kern *kernelSetup) (*installerRun, error) { pxe := pxeSetup{} pxe.tftpipaddr = "192.168.76.2" - switch inst.Board { - case "amd64-usr": + switch system.RpmArch() { + case "x86_64": pxe.boottype = "pxe" pxe.networkdevice = "e1000" pxe.pxeimagepath = "/usr/share/syslinux/" break - case "ppc64le-usr": + case "ppc64le": pxe.boottype = "grub" pxe.networkdevice = "virtio-net-pci" break - case "s390x-usr": + case "s390x": pxe.boottype = "pxe" pxe.networkdevice = "virtio-net-ccw" pxe.tftpipaddr = "10.0.2.2" pxe.bootindex = "1" default: - return nil, fmt.Errorf("Unsupported arch %s", inst.Board) + return nil, fmt.Errorf("Unsupported arch %s" + system.RpmArch()) } mux := http.NewServeMux() @@ -297,7 +297,7 @@ func (inst *Install) setup(kern *kernelSetup) (*installerRun, error) { } func renderBaseKargs(t *installerRun) []string { - return append(baseKargs, fmt.Sprintf("console=%s", consoleKernelArgument[t.inst.Board])) + return append(baseKargs, fmt.Sprintf("console=%s", consoleKernelArgument[system.RpmArch()])) } func renderInstallKargs(t *installerRun) []string { @@ -338,7 +338,7 @@ func (t *installerRun) completePxeSetup(kargs []string) error { KERNEL %s APPEND initrd=%s %s `, t.kern.kernel, t.kern.initramfs, kargsStr)) - if t.inst.Board == "s390x-usr" { + if system.RpmArch() == "s390x" { pxeconfig = []byte(kargsStr) } ioutil.WriteFile(filepath.Join(pxeconfigdir, "default"), pxeconfig, 0777) diff --git a/mantle/platform/qemu.go b/mantle/platform/qemu.go index 5a59fc08ed..64141efd30 100644 --- a/mantle/platform/qemu.go +++ b/mantle/platform/qemu.go @@ -21,11 +21,11 @@ import ( "os" "path/filepath" "regexp" - "runtime" "strconv" "strings" "syscall" + "github.com/coreos/mantle/system" "github.com/coreos/mantle/system/exec" "github.com/coreos/mantle/util" "github.com/pkg/errors" @@ -136,8 +136,6 @@ func (inst *QemuInstance) Destroy() { // QemuBuilder is a configurator that can then create a qemu instance type QemuBuilder struct { - Board string - // Config is a path to Ignition configuration Config string @@ -165,9 +163,8 @@ type QemuBuilder struct { fds []*os.File } -func NewBuilder(board, config string, forceIgnInjection bool) *QemuBuilder { +func NewBuilder(config string, forceIgnInjection bool) *QemuBuilder { ret := QemuBuilder{ - Board: board, Config: config, ForceConfigInjection: forceIgnInjection, Firmware: "bios", @@ -188,17 +185,17 @@ func (builder *QemuBuilder) AddFd(fd *os.File) string { } // virtio returns a virtio device argument for qemu, which is architecture dependent -func virtio(board, device, args string) string { +func virtio(device, args string) string { var suffix string - switch board { - case "amd64-usr", "ppc64le-usr": + switch system.RpmArch() { + case "x86_64", "ppc64le": suffix = "pci" - case "arm64-usr": + case "aarch64": suffix = "device" - case "s390x-usr": + case "s390x": suffix = "ccw" default: - panic(board) + panic(fmt.Sprintf("RpmArch %s unhandled in virtio()", system.RpmArch())) } return fmt.Sprintf("virtio-%s-%s,%s", device, suffix, args) } @@ -215,7 +212,7 @@ func (builder *QemuBuilder) addQcow2DiskFd(fd *os.File, channel string, options builder.diskId += 1 switch channel { case "virtio": - builder.Append("-device", virtio(builder.Board, "blk", fmt.Sprintf("drive=%s%s", id, opts))) + builder.Append("-device", virtio("blk", fmt.Sprintf("drive=%s%s", id, opts))) case "nvme": builder.Append("-device", fmt.Sprintf("nvme,drive=%s%s", id, opts)) default: @@ -238,14 +235,14 @@ func (builder *QemuBuilder) EnableUsermodeNetworking(forwardedPort uint) { netdev += fmt.Sprintf(",hostname=%s", builder.Hostname) } - builder.Append("-netdev", netdev, "-device", virtio(builder.Board, "net", "netdev=eth0")) + builder.Append("-netdev", netdev, "-device", virtio("net", "netdev=eth0")) } // supportsFwCfg if the target system supports injecting // Ignition via the qemu -fw_cfg option. func (builder *QemuBuilder) supportsFwCfg() bool { - switch builder.Board { - case "s390x-usr", "ppc64le-usr": + switch system.RpmArch() { + case "s390x", "ppc64le": return false } return true @@ -255,8 +252,8 @@ func (builder *QemuBuilder) supportsFwCfg() bool { func (builder *QemuBuilder) supportsSwtpm() bool { // Yes, this is the same as supportsFwCfg *currently* but // might not be in the future. - switch builder.Board { - case "s390x-usr", "ppc64le-usr": + switch system.RpmArch() { + case "s390x", "ppc64le": return false } return true @@ -512,10 +509,10 @@ func (builder *QemuBuilder) finalize() { // Then later, other non-x86_64 seemed to just copy that. memory := 1024 - switch builder.Board { - case "arm64-usr": - case "s390x-usr": - case "ppc64le-usr": + switch system.RpmArch() { + case "aarch64": + case "s390x": + case "ppc64le": memory = 2048 } builder.Memory = memory @@ -529,40 +526,33 @@ func (builder *QemuBuilder) Append(args ...string) { // baseQemuArgs takes a board and returns the basic qemu // arguments needed for the current architecture. -func baseQemuArgs(board string) []string { - combo := runtime.GOARCH + "--" + board - switch combo { - case "amd64--amd64-usr": +func baseQemuArgs() []string { + switch system.RpmArch() { + case "x86_64": return []string{ "qemu-system-x86_64", "-machine", "accel=kvm", "-cpu", "host", } - case "amd64--arm64-usr": - return []string{ - "qemu-system-aarch64", - "-machine", "virt", - "-cpu", "cortex-a57", - } - case "arm64--arm64-usr": + case "aarch64": return []string{ "qemu-system-aarch64", "-machine", "virt,accel=kvm,gic-version=3", "-cpu", "host", } - case "s390x--s390x-usr": + case "s390x": return []string{ "qemu-system-s390x", "-machine", "s390-ccw-virtio,accel=kvm", "-cpu", "host", } - case "ppc64le--ppc64le-usr": + case "ppc64le": return []string{ "qemu-system-ppc64", "-machine", "pseries,accel=kvm,kvm-type=HV", } default: - panic("host-guest combo not supported: " + combo) + panic(fmt.Sprintf("RpmArch %s combo not supported for qemu ", system.RpmArch())) } } @@ -601,7 +591,7 @@ func (builder *QemuBuilder) Exec() (*QemuInstance, error) { inst := QemuInstance{} - argv := baseQemuArgs(builder.Board) + argv := baseQemuArgs() argv = append(argv, "-m", fmt.Sprintf("%d", builder.Memory)) switch builder.Firmware { @@ -618,7 +608,7 @@ func (builder *QemuBuilder) Exec() (*QemuInstance, error) { // We always provide a random source argv = append(argv, "-object", "rng-random,filename=/dev/urandom,id=rng0", - "-device", virtio(builder.Board, "rng", "rng=rng0")) + "-device", virtio("rng", "rng=rng0")) if builder.Uuid != "" { argv = append(argv, "-uuid", builder.Uuid) }