[lxc-devel] [lxd/master] lxd/qemu: Add s390x support
stgraber on Github
lxc-bot at linuxcontainers.org
Fri May 22 22:18:55 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200522/97e3b501/attachment-0001.bin>
-------------- next part --------------
From 8f4f540c60d26efcb3a6d6a1d4d3bf3419a96f1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 May 2020 18:18:38 -0400
Subject: [PATCH] lxd/qemu: Add s390x support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/instance/drivers/driver_qemu.go | 35 +++++++++-------
lxd/instance/drivers/driver_qemu_templates.go | 41 ++++++++++++++++---
2 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index bc76dc7fc0..c4929da408 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -1005,6 +1005,8 @@ func (vm *qemu) qemuArchConfig() (string, error) {
return "qemu-system-aarch64", nil
} else if vm.architecture == osarch.ARCH_64BIT_POWERPC_LITTLE_ENDIAN {
return "qemu-system-ppc64", nil
+ } else if vm.architecture == osarch.ARCH_64BIT_S390_BIG_ENDIAN {
+ return "qemu-system-s390x", nil
}
return "", fmt.Errorf("Architecture isn't supported for virtual machines")
@@ -1839,22 +1841,24 @@ func (vm *qemu) addDriveDirConfig(sb *strings.Builder, diskIndex int, fdFiles *[
// For read only shares, do not use proxy.
if shared.StringInSlice("ro", driveConf.Opts) {
return qemuDriveDir.Execute(sb, map[string]interface{}{
- "devName": driveConf.DevName,
- "mountTag": mountTag,
- "path": driveConf.DevPath,
- "readonly": true,
- "diskIndex": diskIndex,
+ "architecture": vm.architectureName,
+ "devName": driveConf.DevName,
+ "mountTag": mountTag,
+ "path": driveConf.DevPath,
+ "readonly": true,
+ "diskIndex": diskIndex,
})
}
// Only use proxy for writable shares.
proxyFD := vm.addFileDescriptor(fdFiles, driveConf.DevPath)
return qemuDriveDir.Execute(sb, map[string]interface{}{
- "devName": driveConf.DevName,
- "mountTag": mountTag,
- "proxyFD": proxyFD,
- "readonly": false,
- "diskIndex": diskIndex,
+ "architecture": vm.architectureName,
+ "devName": driveConf.DevName,
+ "mountTag": mountTag,
+ "proxyFD": proxyFD,
+ "readonly": false,
+ "diskIndex": diskIndex,
})
}
@@ -1887,11 +1891,12 @@ func (vm *qemu) addDriveConfig(sb *strings.Builder, bootIndexes map[string]int,
}
return qemuDrive.Execute(sb, map[string]interface{}{
- "devName": driveConf.DevName,
- "devPath": driveConf.DevPath,
- "bootIndex": bootIndexes[driveConf.DevName],
- "cacheMode": cacheMode,
- "aioMode": aioMode,
+ "architecture": vm.architectureName,
+ "devName": driveConf.DevName,
+ "devPath": driveConf.DevPath,
+ "bootIndex": bootIndexes[driveConf.DevName],
+ "cacheMode": cacheMode,
+ "aioMode": aioMode,
})
}
diff --git a/lxd/instance/drivers/driver_qemu_templates.go b/lxd/instance/drivers/driver_qemu_templates.go
index 83f552272b..a32a777e9d 100644
--- a/lxd/instance/drivers/driver_qemu_templates.go
+++ b/lxd/instance/drivers/driver_qemu_templates.go
@@ -19,6 +19,9 @@ gic-version = "host"
{{if eq .architecture "ppc64le" -}}
type = "pseries"
{{end -}}
+{{if eq .architecture "s390x" -}}
+type = "s390-ccw-virtio"
+{{end -}}
accel = "kvm"
usb = "off"
graphics = "off"
@@ -63,6 +66,7 @@ addr = "0x2"
{{- end }}
[device "qemu_scsi"]
+{{- if ne .architecture "s390x"}}
driver = "virtio-scsi-pci"
{{- if eq .architecture "ppc64le" }}
bus = "pci.0"
@@ -70,6 +74,9 @@ bus = "pci.0"
bus = "qemu_pcie1"
addr = "0x0"
{{- end}}
+{{- else}}
+driver = "virtio-scsi-ccw"
+{{- end}}
# Balloon driver
{{- if eq .architecture "x86_64" "aarch64" }}
@@ -82,6 +89,7 @@ addr = "0x2.0x1"
{{- end }}
[device "qemu_ballon"]
+{{- if ne .architecture "s390x"}}
driver = "virtio-balloon-pci"
{{- if eq .architecture "ppc64le" }}
bus = "pci.0"
@@ -89,6 +97,9 @@ bus = "pci.0"
bus = "qemu_pcie2"
addr = "0x0"
{{- end}}
+{{- else}}
+driver = "virtio-balloon-ccw"
+{{- end}}
# Random number generator
[object "qemu_rng"]
@@ -105,14 +116,18 @@ addr = "0x2.0x2"
{{- end }}
[device "dev-qemu_rng"]
-driver = "virtio-rng-pci"
rng = "qemu_rng"
+{{if ne .architecture "s390x" -}}
+driver = "virtio-rng-pci"
{{- if eq .architecture "ppc64le"}}
bus = "pci.0"
{{- else}}
bus = "qemu_pcie3"
addr = "0x0"
{{- end}}
+{{- else}}
+driver = "virtio-rng-ccw"
+{{- end}}
# Console
[chardev "console"]
@@ -137,14 +152,18 @@ addr = "0x2.0x3"
{{- end }}
[device]
-driver = "vhost-vsock-pci"
guest-cid = "{{.vsockID}}"
+{{if ne .architecture "s390x" -}}
+driver = "vhost-vsock-pci"
{{if eq .architecture "ppc64le" -}}
bus = "pci.0"
{{else -}}
bus = "qemu_pcie4"
addr = "0x0"
{{end -}}
+{{- else}}
+driver = "vhost-vsock-ccw"
+{{- end}}
`))
var qemuCPU = template.Must(template.New("qemuCPU").Parse(`
@@ -214,11 +233,15 @@ readonly = "on"
path = "{{.path}}"
[device "dev-qemu_config"]
-driver = "virtio-9p-pci"
fsdev = "qemu_config"
mount_tag = "config"
+{{if ne .architecture "s390x" -}}
+driver = "virtio-9p-pci"
multifunction = "on"
addr = "0x3.0x{{.diskIndex}}"
+{{- else}}
+driver = "virtio-9p-ccw"
+{{- end}}
`))
// Devices use "lxd_" prefix indicating that this is a user named device.
@@ -238,11 +261,15 @@ sock_fd = "{{.proxyFD}}"
{{- end}}
[device "dev-lxd_{{.devName}}"]
-driver = "virtio-9p-pci"
fsdev = "lxd_{{.devName}}"
mount_tag = "{{.mountTag}}"
+{{if ne .architecture "s390x" -}}
+driver = "virtio-9p-pci"
multifunction = "on"
addr = "0x3.0x{{.diskIndex}}"
+{{- else}}
+driver = "virtio-9p-ccw"
+{{- end}}
`))
// Devices use "lxd_" prefix indicating that this is a user named device.
@@ -282,15 +309,19 @@ multifunction = "on"
{{- end }}
[device "dev-lxd_{{.devName}}"]
-driver = "virtio-net-pci"
netdev = "lxd_{{.devName}}"
mac = "{{.devHwaddr}}"
+{{if ne .architecture "s390x" -}}
+driver = "virtio-net-pci"
{{if eq .architecture "ppc64le" -}}
bus = "pci.0"
{{else -}}
bus = "qemu_pcie{{.chassisIndex}}"
addr = "0x0"
{{end -}}
+{{- else}}
+driver = "virtio-net-ccw"
+{{- end}}
bootindex = "{{.bootIndex}}"
`))
More information about the lxc-devel
mailing list