mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-27 07:22:07 +03:00
conf, qemu: consider available CPUs in vcpupin/emulatorpin output
The output of vcpupin and emulatorpin for a domain with vcpu placement='static' is based on a default bitmap that contains all possible CPUs in the host, regardless of the CPUs being offline or not. E.g. for a Linux host with this CPU setup (from lscpu): On-line CPU(s) list: 0,8,16,24,32,40,(...),184 Off-line CPU(s) list: 1-7,9-15,17-23,25-31,(...),185-191 And a domain with this configuration: <vcpu placement='static'>1</vcpu> 'virsh vcpupin' will return the following: $ sudo ./run tools/virsh vcpupin vcpupin_test VCPU CPU Affinity ---------------------- 0 0-191 This is benign by its own, but can make the user believe that all CPUs from the 0-191 range are eligible for pinning. Which can lead to situations like this: $ sudo ./run tools/virsh vcpupin vcpupin_test 0 1 error: Invalid value '1' for 'cpuset.cpus': Invalid argument This is exarcebated by the fact that 'virsh vcpuinfo' considers only available host CPUs in the 'CPU Affinity' field: $ sudo ./run tools/virsh vcpuinfo vcpupin_test (...) CPU Affinity: y-------y-------y-------(...) This patch changes the default bitmap of vcpupin and emulatorpin, in the case of domains with static vcpu placement, to all available CPUs instead of all possible CPUs. Aside from making it consistent with the behavior of 'vcpuinfo', users will now have one less incentive to try to pin a vcpu in an offline CPU. https://bugzilla.redhat.com/show_bug.cgi?id=1434276 Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
42036650c6
commit
2020c6af8a
@ -2089,11 +2089,9 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
|
||||
if (hostcpus < 0)
|
||||
return -1;
|
||||
|
||||
if (!(allcpumap = virBitmapNew(hostcpus)))
|
||||
if (!(allcpumap = virHostCPUGetAvailableCPUsBitmap()))
|
||||
return -1;
|
||||
|
||||
virBitmapSetAll(allcpumap);
|
||||
|
||||
for (i = 0; i < maxvcpus && i < ncpumaps; i++) {
|
||||
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i);
|
||||
virBitmapPtr bitmap = NULL;
|
||||
|
@ -5425,7 +5425,6 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
|
||||
virDomainDefPtr def;
|
||||
bool live;
|
||||
int ret = -1;
|
||||
int hostcpus;
|
||||
virBitmapPtr cpumask = NULL;
|
||||
g_autoptr(virBitmap) bitmap = NULL;
|
||||
virBitmapPtr autoCpuset = NULL;
|
||||
@ -5442,9 +5441,6 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
|
||||
if (!(def = virDomainObjGetOneDefState(vm, flags, &live)))
|
||||
goto cleanup;
|
||||
|
||||
if ((hostcpus = virHostCPUGetCount()) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (live)
|
||||
autoCpuset = QEMU_DOMAIN_PRIVATE(vm)->autoCpuset;
|
||||
|
||||
@ -5456,9 +5452,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
|
||||
autoCpuset) {
|
||||
cpumask = autoCpuset;
|
||||
} else {
|
||||
if (!(bitmap = virBitmapNew(hostcpus)))
|
||||
if (!(bitmap = virHostCPUGetAvailableCPUsBitmap()))
|
||||
goto cleanup;
|
||||
virBitmapSetAll(bitmap);
|
||||
cpumask = bitmap;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user