mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 18:11:35 +00:00
Merge pull request #2927 from alicefr/support_s390
Add s390x support for Linuxkit binary and tools
This commit is contained in:
commit
0d8fab9ac9
@ -45,7 +45,7 @@ esac
|
|||||||
# Push manifest list
|
# Push manifest list
|
||||||
OUT=$(manifest-tool $MT_ARGS push from-args \
|
OUT=$(manifest-tool $MT_ARGS push from-args \
|
||||||
--ignore-missing \
|
--ignore-missing \
|
||||||
--platforms linux/amd64,linux/arm64 \
|
--platforms linux/amd64,linux/arm64,linux/s390x \
|
||||||
--template "$TARGET"-ARCH \
|
--template "$TARGET"-ARCH \
|
||||||
--target "$TARGET")
|
--target "$TARGET")
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func (p Pkg) Build(bos ...BuildOpt) error {
|
|||||||
|
|
||||||
var suffix string
|
var suffix string
|
||||||
switch arch {
|
switch arch {
|
||||||
case "amd64", "arm64":
|
case "amd64", "arm64", "s390x":
|
||||||
suffix = "-" + arch
|
suffix = "-" + arch
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unknown arch %q", arch)
|
return fmt.Errorf("Unknown arch %q", arch)
|
||||||
|
@ -48,7 +48,7 @@ esac
|
|||||||
# Push manifest list
|
# Push manifest list
|
||||||
OUT=$(manifest-tool $MT_ARGS push from-args \
|
OUT=$(manifest-tool $MT_ARGS push from-args \
|
||||||
--ignore-missing \
|
--ignore-missing \
|
||||||
--platforms linux/amd64,linux/arm64 \
|
--platforms linux/amd64,linux/arm64,linux/s390x \
|
||||||
--template "$TARGET"-ARCH \
|
--template "$TARGET"-ARCH \
|
||||||
--target "$TARGET")
|
--target "$TARGET")
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func NewFromCLI(fs *flag.FlagSet, args ...string) (Pkg, error) {
|
|||||||
// Defaults
|
// Defaults
|
||||||
pi := pkgInfo{
|
pi := pkgInfo{
|
||||||
Org: "linuxkit",
|
Org: "linuxkit",
|
||||||
Arches: []string{"amd64", "arm64"},
|
Arches: []string{"amd64", "arm64", "s390x"},
|
||||||
GitRepo: "https://github.com/linuxkit/linuxkit",
|
GitRepo: "https://github.com/linuxkit/linuxkit",
|
||||||
Network: false,
|
Network: false,
|
||||||
DisableContentTrust: false,
|
DisableContentTrust: false,
|
||||||
|
@ -67,8 +67,12 @@ func init() {
|
|||||||
defaultArch = "aarch64"
|
defaultArch = "aarch64"
|
||||||
case "amd64":
|
case "amd64":
|
||||||
defaultArch = "x86_64"
|
defaultArch = "x86_64"
|
||||||
|
case "s390x":
|
||||||
|
defaultArch = "s390x"
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
|
case runtime.GOARCH == "s390x":
|
||||||
|
defaultAccel = "kvm"
|
||||||
case haveKVM():
|
case haveKVM():
|
||||||
defaultAccel = "kvm:tcg"
|
defaultAccel = "kvm:tcg"
|
||||||
case runtime.GOOS == "darwin":
|
case runtime.GOOS == "darwin":
|
||||||
@ -156,7 +160,7 @@ func runQemu(args []string) {
|
|||||||
|
|
||||||
// VM configuration
|
// VM configuration
|
||||||
accel := flags.String("accel", defaultAccel, "Choose acceleration mode. Use 'tcg' to disable it.")
|
accel := flags.String("accel", defaultAccel, "Choose acceleration mode. Use 'tcg' to disable it.")
|
||||||
arch := flags.String("arch", defaultArch, "Type of architecture to use, e.g. x86_64, aarch64")
|
arch := flags.String("arch", defaultArch, "Type of architecture to use, e.g. x86_64, aarch64, s390x")
|
||||||
cpus := flags.String("cpus", "1", "Number of CPUs")
|
cpus := flags.String("cpus", "1", "Number of CPUs")
|
||||||
mem := flags.String("mem", "1024", "Amount of memory in MB")
|
mem := flags.String("mem", "1024", "Amount of memory in MB")
|
||||||
|
|
||||||
@ -511,6 +515,8 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
// goArch is the GOARCH equivalent of config.Arch
|
// goArch is the GOARCH equivalent of config.Arch
|
||||||
var goArch string
|
var goArch string
|
||||||
switch config.Arch {
|
switch config.Arch {
|
||||||
|
case "s390x":
|
||||||
|
goArch = "s390x"
|
||||||
case "aarch64":
|
case "aarch64":
|
||||||
goArch = "arm64"
|
goArch = "arm64"
|
||||||
case "x86_64":
|
case "x86_64":
|
||||||
@ -525,15 +531,21 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config.Accel != "" {
|
if config.Accel != "" {
|
||||||
if config.Arch == "aarch64" {
|
switch config.Arch {
|
||||||
|
case "s390x":
|
||||||
|
qemuArgs = append(qemuArgs, "-machine", fmt.Sprintf("s390-ccw-virtio,accel=%s", config.Accel))
|
||||||
|
case "aarch64":
|
||||||
qemuArgs = append(qemuArgs, "-machine", fmt.Sprintf("virt,gic_version=host,accel=%s", config.Accel))
|
qemuArgs = append(qemuArgs, "-machine", fmt.Sprintf("virt,gic_version=host,accel=%s", config.Accel))
|
||||||
} else {
|
default:
|
||||||
qemuArgs = append(qemuArgs, "-machine", fmt.Sprintf("q35,accel=%s", config.Accel))
|
qemuArgs = append(qemuArgs, "-machine", fmt.Sprintf("q35,accel=%s", config.Accel))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if config.Arch == "aarch64" {
|
switch config.Arch {
|
||||||
|
case "s390x":
|
||||||
|
qemuArgs = append(qemuArgs, "-machine", "s390-ccw-virtio")
|
||||||
|
case "aarch64":
|
||||||
qemuArgs = append(qemuArgs, "-machine", "virt")
|
qemuArgs = append(qemuArgs, "-machine", "virt")
|
||||||
} else {
|
default:
|
||||||
qemuArgs = append(qemuArgs, "-machine", "q35")
|
qemuArgs = append(qemuArgs, "-machine", "q35")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -542,8 +554,11 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
rng = rng + ",filename=/dev/urandom"
|
rng = rng + ",filename=/dev/urandom"
|
||||||
}
|
}
|
||||||
|
if config.Arch == "s390x" {
|
||||||
|
qemuArgs = append(qemuArgs, "-object", rng, "-device", "virtio-rng-ccw,rng=rng0")
|
||||||
|
} else {
|
||||||
qemuArgs = append(qemuArgs, "-object", rng, "-device", "virtio-rng-pci,rng=rng0")
|
qemuArgs = append(qemuArgs, "-object", rng, "-device", "virtio-rng-pci,rng=rng0")
|
||||||
|
}
|
||||||
var lastDisk int
|
var lastDisk int
|
||||||
for i, d := range config.Disks {
|
for i, d := range config.Disks {
|
||||||
index := i
|
index := i
|
||||||
@ -570,7 +585,13 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
for i, p := range config.ISOImages {
|
for i, p := range config.ISOImages {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
// This is hdc/CDROM which is skipped by the disk loop above
|
// This is hdc/CDROM which is skipped by the disk loop above
|
||||||
|
if runtime.GOARCH == "s390x" {
|
||||||
|
qemuArgs = append(qemuArgs, "-device", "virtio-scsi-ccw")
|
||||||
|
qemuArgs = append(qemuArgs, "-device", "scsi-cd,drive=cd1")
|
||||||
|
qemuArgs = append(qemuArgs, "-drive", "file="+p+",format=raw,if=none,id=cd1")
|
||||||
|
} else {
|
||||||
qemuArgs = append(qemuArgs, "-cdrom", p)
|
qemuArgs = append(qemuArgs, "-cdrom", p)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
index := lastDisk + i
|
index := lastDisk + i
|
||||||
qemuArgs = append(qemuArgs, "-drive", "file="+p+",index="+strconv.Itoa(index)+",media=cdrom")
|
qemuArgs = append(qemuArgs, "-drive", "file="+p+",index="+strconv.Itoa(index)+",media=cdrom")
|
||||||
@ -599,7 +620,11 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
qemuArgs = append(qemuArgs, "-net", "none")
|
qemuArgs = append(qemuArgs, "-net", "none")
|
||||||
} else {
|
} else {
|
||||||
mac := retrieveMAC(config.StatePath)
|
mac := retrieveMAC(config.StatePath)
|
||||||
|
if config.Arch == "s390x" {
|
||||||
|
qemuArgs = append(qemuArgs, "-device", "virtio-net-ccw,netdev=t0,mac="+mac.String())
|
||||||
|
} else {
|
||||||
qemuArgs = append(qemuArgs, "-device", "virtio-net-pci,netdev=t0,mac="+mac.String())
|
qemuArgs = append(qemuArgs, "-device", "virtio-net-pci,netdev=t0,mac="+mac.String())
|
||||||
|
}
|
||||||
forwardings, err := buildQemuForwardings(config.PublishedPorts, config.Containerized)
|
forwardings, err := buildQemuForwardings(config.PublishedPorts, config.Containerized)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user