[lxc-devel] [lxd/master] lxd/qemu: Cleanup arch checks

stgraber on Github lxc-bot at linuxcontainers.org
Fri May 22 20:03:05 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/44201b20/attachment.bin>
-------------- next part --------------
From 7aee4b362ca311c1c8e591a9382064aadcc110ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 May 2020 15:33:18 -0400
Subject: [PATCH] lxd/qemu: Cleanup arch checks
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           | 11 ++++++-----
 lxd/instance/drivers/driver_qemu_templates.go | 14 +++++++-------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index 5b4878e312..b35749df36 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -734,7 +734,8 @@ func (vm *qemu) Start(stateful bool) error {
 		"-chroot", vm.Path(),
 	}
 
-	if vm.architecture != osarch.ARCH_64BIT_POWERPC_LITTLE_ENDIAN {
+	// SMBIOS only on x86_64 and aarch64.
+	if shared.IntInSlice(vm.architecture, []int{osarch.ARCH_64BIT_INTEL_X86, osarch.ARCH_64BIT_ARMV8_LITTLE_ENDIAN}) {
 		qemuCmd = append(qemuCmd, "-smbios", "type=2,manufacturer=Canonical Ltd.,product=LXD")
 	}
 
@@ -964,8 +965,8 @@ func (vm *qemu) openUnixSocket(sockPath string) (*net.UnixConn, error) {
 }
 
 func (vm *qemu) setupNvram() error {
-	// No UEFI nvram for ppc64le.
-	if vm.architecture == osarch.ARCH_64BIT_POWERPC_LITTLE_ENDIAN {
+	// UEFI only on x86_64 and aarch64.
+	if shared.IntInSlice(vm.architecture, []int{osarch.ARCH_64BIT_INTEL_X86, osarch.ARCH_64BIT_ARMV8_LITTLE_ENDIAN}) {
 		return nil
 	}
 
@@ -1754,8 +1755,8 @@ func (vm *qemu) addMonitorConfig(sb *strings.Builder) error {
 
 // addFirmwareConfig adds the qemu config required for adding a secure boot compatible EFI firmware.
 func (vm *qemu) addFirmwareConfig(sb *strings.Builder) error {
-	// No UEFI nvram for ppc64le.
-	if vm.architecture == osarch.ARCH_64BIT_POWERPC_LITTLE_ENDIAN {
+	// UEFI only on x86_64 and aarch64.
+	if !shared.IntInSlice(vm.architecture, []int{osarch.ARCH_64BIT_INTEL_X86, osarch.ARCH_64BIT_ARMV8_LITTLE_ENDIAN}) {
 		return nil
 	}
 
diff --git a/lxd/instance/drivers/driver_qemu_templates.go b/lxd/instance/drivers/driver_qemu_templates.go
index b56e0a7238..83f552272b 100644
--- a/lxd/instance/drivers/driver_qemu_templates.go
+++ b/lxd/instance/drivers/driver_qemu_templates.go
@@ -52,7 +52,7 @@ backend = "ringbuf"
 size = "{{.ringbufSizeBytes}}B"
 
 # SCSI controller
-{{- if ne .architecture "ppc64le"}}
+{{- if eq .architecture "x86_64" "aarch64" }}
 [device "qemu_pcie1"]
 driver = "pcie-root-port"
 port = "0x10"
@@ -64,7 +64,7 @@ addr = "0x2"
 
 [device "qemu_scsi"]
 driver = "virtio-scsi-pci"
-{{- if eq .architecture "ppc64le"}}
+{{- if eq .architecture "ppc64le" }}
 bus = "pci.0"
 {{- else}}
 bus = "qemu_pcie1"
@@ -72,7 +72,7 @@ addr = "0x0"
 {{- end}}
 
 # Balloon driver
-{{- if ne .architecture "ppc64le"}}
+{{- if eq .architecture "x86_64" "aarch64" }}
 [device "qemu_pcie2"]
 driver = "pcie-root-port"
 port = "0x11"
@@ -83,7 +83,7 @@ addr = "0x2.0x1"
 
 [device "qemu_ballon"]
 driver = "virtio-balloon-pci"
-{{- if eq .architecture "ppc64le"}}
+{{- if eq .architecture "ppc64le" }}
 bus = "pci.0"
 {{- else}}
 bus = "qemu_pcie2"
@@ -95,7 +95,7 @@ addr = "0x0"
 qom-type = "rng-random"
 filename = "/dev/urandom"
 
-{{if ne .architecture "ppc64le" -}}
+{{if eq .architecture "x86_64" "aarch64" -}}
 [device "qemu_pcie3"]
 driver = "pcie-root-port"
 port = "0x12"
@@ -127,7 +127,7 @@ size = "{{.memSizeBytes}}B"
 
 var qemuVsock = template.Must(template.New("qemuVsock").Parse(`
 # Vsock
-{{if ne .architecture "ppc64le" -}}
+{{if eq .architecture "x86_64" "aarch64" -}}
 [device "qemu_pcie4"]
 driver = "pcie-root-port"
 port = "0x13"
@@ -271,7 +271,7 @@ bootindex = "{{.bootIndex}}"
 // qemuDevTapCommon is common PCI device template for tap based netdevs.
 // Use 0x4.0x as the PCIe address prefix for nic devices to allow up to 8 devices of this type.
 var qemuDevTapCommon = template.Must(template.New("qemuDevTapCommon").Parse(`
-{{if ne .architecture "ppc64le" -}}
+{{if eq .architecture "x86_64" "aarch64" -}}
 [device "qemu_pcie{{.chassisIndex}}"]
 driver = "pcie-root-port"
 port = "0x{{.nicIndex}}"


More information about the lxc-devel mailing list