From b0c2bdd66bcfb5e7a1f68351718b7601a941cde4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Thu, 21 Mar 2024 15:45:27 -0400 Subject: [PATCH] incusd/instance/qemu: Fix handling of > 64 limits.cpu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Sponsored-by: ActivePort (https://www.activeport.com.au) --- internal/server/instance/drivers/driver_qemu.go | 3 +++ internal/server/instance/drivers/driver_qemu_templates.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/internal/server/instance/drivers/driver_qemu.go b/internal/server/instance/drivers/driver_qemu.go index 481ab23f836..71614a00c4b 100644 --- a/internal/server/instance/drivers/driver_qemu.go +++ b/internal/server/instance/drivers/driver_qemu.go @@ -3433,6 +3433,9 @@ func (d *qemu) addCPUMemoryConfig(cfg *[]cfgSection, cpuInfo *cpuTopology) error if d.architectureSupportsCPUHotplug() { cpuOpts.cpuCount = 1 cpuOpts.cpuCores = 1 + + // Expose the total requested by the user already so the hotplug limit can be set higher if needed. + cpuOpts.cpuRequested = cpuInfo.cores } else { cpuOpts.cpuCount = cpuInfo.cores cpuOpts.cpuCores = cpuInfo.cores diff --git a/internal/server/instance/drivers/driver_qemu_templates.go b/internal/server/instance/drivers/driver_qemu_templates.go index 2817cce4e71..68fe9804ee1 100644 --- a/internal/server/instance/drivers/driver_qemu_templates.go +++ b/internal/server/instance/drivers/driver_qemu_templates.go @@ -425,6 +425,7 @@ type qemuNumaEntry struct { type qemuCPUOpts struct { architecture string cpuCount int + cpuRequested int cpuSockets int cpuCores int cpuThreads int @@ -489,6 +490,8 @@ func qemuCPU(opts *qemuCPUOpts, pinning bool) []cfgSection { max := 64 if int(cpu.Total) < max { max = int(cpu.Total) + } else if opts.cpuRequested > max { + max = opts.cpuRequested } else if opts.cpuCount > max { max = opts.cpuCount }