libxl: Make 'xl vcpu-set' work properly on overcommited hosts with an override

Enterprise / Virtualization / Xen - Konrad Rzeszutek Wilk [oracle.com] - 14 May 2013 04:02 UTC

The libxl_cpu_bitmap_alloc(..) function, if provided with a zero
value for max CPUs will call xc_get_max_cpus() which will retrieve the number of physical CPUs the host has. This is usually OK if the guest's maxvcpus <= host pcpus. But if the value is different, then the bitmap for VCPUs is limited by the number of CPUs the host has.

This is incorrect as what we want is to hotplug in the guest the amount of CPUs that the user specified on the command line and not be limited by the amount of physical CPUs.

This means that a guest config like this:

vcpus=8 maxvcpus=32

and on a 4 PCPU machine doing

xl vcpu-set 16

won't work. This is b/c the the size of the bitmap is one byte so it can only hold up to 8 VCPUs. Hence anything above that is going to be ignored.

Note that this patch also fixes the bitmap setting - as it would set all of the bits allowed. Meaning if the user had a 4PCPU host we would still allow the user to set 8VCPUs. This second iteration of the patch fixes this.

Note that all of the libxl_cpu_bitmap_[test|set] silently ignore any test or sets above its size:

if (bit >= bitmap->size * 8) return 0;

so we were never notified off this bug.

This patch warns the user if they are trying to do this. If the user really wants to do this they have to provide the --ignore-host parameter to bypass this check.

afab6f6 libxl: Make 'xl vcpu-set' work properly on overcommited hosts with an override.
tools/libxl/xl_cmdimpl.c | 35 +++++++++++++++++++++++++++++------
tools/libxl/xl_cmdtable.c | 3 ++-
2 files changed, 31 insertions(+), 7 deletions(-)

Upstream: xenbits.xen.org


  • Share