From dbc0aa79a84277e4ddd4f8aa1bf33836b3819a41 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 28 Aug 2023 10:01:26 +0200 Subject: [PATCH] xen: set vmr.VCPUsMax to minimum of global setting and host cpu cores --- .../hypervisor/xenserver/resource/CitrixResourceBase.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index 7fcf88584693..5895f6069b56 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -1338,7 +1338,12 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS vmr.VCPUsMax = (long)vmSpec.getCpus(); } else { if (vmSpec.getVcpuMaxLimit() != null) { - vmr.VCPUsMax = (long)vmSpec.getVcpuMaxLimit(); + long vcpuMaxLimit = (long) vmSpec.getVcpuMaxLimit(); + if (vcpuMaxLimit <= _host.getCpus()) { + vmr.VCPUsMax = vcpuMaxLimit; + } else { + vmr.VCPUsMax = (long) _host.getCpus(); + } } } } else {