[PATCH 0/8] RFC New API to retrieve host node CPU map

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rationale:

In order to use the APIs listed below it is necessary for a client
to know the maximum number of node CPUs which is passed via the
maplen argument.

virDomainGetEmulatorPinInfo
virDomainGetVcpuPinInfo
virDomainGetVcpus
virDomainPinEmulator
virDomainPinVcpu
virDomainPinVcpuFlags

The current approach uses virNodeGetInfo to determine the maximum CPU number.
This can lead to incorrect results if not all node CPUs are online. 
The maximum CPU number should always be the number of CPUs present on the
host, regardless of their online/offline state.

The following example illustrates the issue:
Host has 3 logical CPUs, 1 socket, 3 cores, 1 thread.
Guest has 1 virtual CPU and is started while all 3 host CPUs are
online.

$ virsh vcpuinfo guest
VCPU:           0
CPU:            0
State:          running
CPU time:       35.4s
CPU Affinity:   yyy

$ echo 0 > /sys/devices/system/cpu/cpu1/online

$ virsh vcpuinfo guest
VCPU:           0
CPU:            0
State:          running
CPU time:       35.5s
CPU Affinity:   y-

The correct display for CPU affinity would have been y-y, as the guest
continues to use CPUs 0 and 2.
This is not a display problem only, because it is also not possible to
explicitly pin the virtual CPU to host CPUs 0 and 2, due to the
truncated CPU mask.

PROPOSAL:

To help solve the issue above I suggest a new public API:

int virNodeGetCPUMapFlags(virConnectPtr conn,
                          unsigned char **cpumap,
    			  unsigned int *online,
                          unsigned int flags);

The function will return the number of CPUs present on the host
or -1 on failure;
If cpumap is non-NULL virNodeGetCPUMapFlags will allocate an array
containing a bit map representation of the online CPUs. It's
the callers responsibility to deallocate cpumap using free().
If online is non-NULL, the variable pointed to will contain
the number of online host node CPUs.
The variable flags has been added to support future extensions
and must be set to 0.

Clients can use virNodeGetCPUMapFlags to properly determine the maximum
number of node CPUs and their online/offline state.

Remarks:
This series implements the QEMU and test drivers.
This series doesn't introduce changes to the existing vcpu pinning,
which I would submit as a succeeding patch set.
No python binding yet.

Viktor Mihajlovski (8):
  virNodeGetCPUMapFlags: Define public API.
  virNodeGetCPUMapFlags: Define driver API.
  virNodeGetCPUMapFlags: Implement public API.
  virNodeGetCPUMapFlags: Implement wire protocol.
  libvirt.h.in: Add new cpumap macro VIR_CPU_USED
  virNodeGetCPUMapFlags: Implement virsh support.
  virNodeGetCPUMapFlags: Implement support function in nodeinfo
  virNodeGetCPUMapFlags: Implement driver support

 daemon/remote.c              |   44 +++++++++++++++++++++++++++++++++
 include/libvirt/libvirt.h.in |   28 ++++++++++++++++++---
 python/generator.py          |    1 +
 src/driver.h                 |    7 +++++
 src/libvirt.c                |   56 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_private.syms     |    1 +
 src/libvirt_public.syms      |    5 +++
 src/nodeinfo.c               |   49 ++++++++++++++++++++++++++++++++++++
 src/nodeinfo.h               |    6 ++++
 src/qemu/qemu_driver.c       |    1 +
 src/remote/remote_driver.c   |   49 ++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   13 +++++++++-
 src/remote_protocol-structs  |   12 +++++++++
 src/test/test_driver.c       |   30 ++++++++++++++++++++++
 tools/virsh-host.c           |   41 ++++++++++++++++++++++++++++++
 tools/virsh.pod              |    5 +++
 16 files changed, 343 insertions(+), 5 deletions(-)

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux