Skip to content

add with_topology: hotplug/unplug vCPUs with explicit sockets/cores/threads topology! - #33

Open
Anushree-Mathur wants to merge 1 commit into
lop-devops:masterfrom
Anushree-Mathur:topology_plug_unplug
Open

add with_topology: hotplug/unplug vCPUs with explicit sockets/cores/threads topology!#33
Anushree-Mathur wants to merge 1 commit into
lop-devops:masterfrom
Anushree-Mathur:topology_plug_unplug

Conversation

@Anushree-Mathur

@Anushree-Mathur Anushree-Mathur commented Aug 11, 2026

Copy link
Copy Markdown

What the test does:

  1. Defines the VM with an explicit CPU topology (topology_sockets/cores/threads) and a capped vcpu_max_num before the VM starts, instead of relying on set_vm_vcpus() topology correction.
  2. If numa=yes is also set, redistributes the pre-existing NUMA cells to match the new vcpu_max_num: CPU ranges are recalculated (cpus_per_cell = vcpu_max / num_cells) and each cell receives an equal share of the total guest memory (cell_memory_kib = mem_MiB * 1024 / num_cells).
  3. Starts the VM and verifies the initial vcpu count matches vcpu_current_num.
  4. Hotplugs vCPUs live (virsh setvcpus --live) to vcpu_plug_num, waits for the new CPUs to come online in the guest, and verifies the count.
  5. Unplugs back to vcpu_unplug_num (first bumps to vcpu_max_num to ensure all added vCPUs are hotpluggable, then reduces), and verifies the final count. Steps 3-5 are repeated test_itr times (default 1).

libvirt/tests/cfg/libvirt_vcpu_plug_unplug.cfg:
Add with_topology variant with three sub-variants for ppc64le/ppc64:

  • threads_2: sockets=1, cores=4, threads=2, vcpu_max=8
  • threads_4: sockets=1, cores=2, threads=4, vcpu_max=8
  • threads_8: sockets=1, cores=2, threads=8, vcpu_max=16 Parameters match subtests.cfg authoritative definitions exactly.
    With all above threads scenarios it will vcpu plug unplug for specified iterations!

libvirt/tests/src/libvirt_vcpu_plug_unplug.py:
Read topology_required/topology_sockets/cores/threads params.
When topology_required=yes, set vcpu/current_vcpu directly and
inject into the element via VMCPUXML, then sync.
When numa=yes is also set, re-read the inactive XML, recalculate
all NUMA cell CPU ranges and per-cell memory, and sync again.

Signed-off-by: Anushree-Mathur <anushree.mathur@linux.ibm.com>

…ogy!

What the test does:
  1. Defines the VM with an explicit CPU topology
     (topology_sockets/cores/threads) and a capped vcpu_max_num before
     the VM starts, instead of relying on set_vm_vcpus() topology
     correction.
  2. If numa=yes is also set, redistributes the pre-existing NUMA cells
     to match the new vcpu_max_num: CPU ranges are recalculated
     (cpus_per_cell = vcpu_max / num_cells) and each cell receives an
     equal share of the total guest memory
     (cell_memory_kib = mem_MiB * 1024 / num_cells).
  3. Starts the VM and verifies the initial vcpu count matches
     vcpu_current_num.
  4. Hotplugs vCPUs live (virsh setvcpus --live) to vcpu_plug_num,
     waits for the new CPUs to come online in the guest, and verifies
     the count.
  5. Unplugs back to vcpu_unplug_num (first bumps to vcpu_max_num to
     ensure all added vCPUs are hotpluggable, then reduces), and
     verifies the final count.
  Steps 3-5 are repeated test_itr times (default 1).

libvirt/tests/cfg/libvirt_vcpu_plug_unplug.cfg:
  Add with_topology variant with three sub-variants for ppc64le/ppc64:
  - threads_2: sockets=1, cores=4, threads=2, vcpu_max=8
  - threads_4: sockets=1, cores=2, threads=4, vcpu_max=8
  - threads_8: sockets=1, cores=2, threads=8, vcpu_max=16
  Parameters match subtests.cfg authoritative definitions exactly.

libvirt/tests/src/libvirt_vcpu_plug_unplug.py:
  Read topology_required/topology_sockets/cores/threads params.
  When topology_required=yes, set vcpu/current_vcpu directly and
  inject <topology> into the <cpu> element via VMCPUXML, then sync.
  When numa=yes is also set, re-read the inactive XML, recalculate
  all NUMA cell CPU ranges and per-cell memory, and sync again.
  This avoids the stale per-cell copy bug (inflating total guest RAM
  by num_cells x) that caused QEMU OOM on start.
  All non-topology variants reach set_vm_vcpus() unchanged via the
  else branch.

Signed-off-by: Anushree-Mathur <anushree.mathur@linux.ibm.com>
Signed-off-by: Anushree-Mathur <anushree.mathur@linux.ibm.com>
@Anushree-Mathur

Copy link
Copy Markdown
Author
python3 avocado-setup.py --run-suite guest_cpu_topology --guest-os SLES.16.1.ppc64le --only-filter 'virtio_scsi virtio_net qcow2' --no-download
18:51:36 INFO    : Env Config: /home/Anu/tests/config/wrapper/env.conf
18:51:36 INFO    : No Run Config: /home/Anu/tests/config/wrapper/no_run_tests.conf
18:51:36 WARNING : Overriding user setting and enabling kvm bootstrap as guest tests are requested
18:51:36 INFO    : Check for environment
18:51:39 INFO    : Creating temporary mux dir
18:51:39 INFO    :
18:51:39 INFO    : Running Guest Tests Suite cpu_topology
18:51:39 INFO    : Running: /usr/local/bin/avocado run --vt-type libvirt --vt-config /home/Anu/tests/data/avocado-vt/backends/libvirt/cfg/cpu_topology.cfg                 --force-job-id 55af53d3dffd509e1bec47c6588aaa491c41a3e4                 --job-results-dir /home/Anu/tests/results  --vt-only-filter                                             "virtio_scsi virtio_net qcow2 SLES.16.1.ppc64le"
/usr/local/lib/python3.13/site-packages/avocado/core/__init__.py:18: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.
No python imaging library installed. PPM image conversion to JPEG disabled. In order to enable it, please install python-imaging or the equivalent for your distro.
No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.
No python imaging library installed. PPM image conversion to JPEG disabled. In order to enable it, please install python-imaging or the equivalent for your distro.
JOB ID     : 55af53d3dffd509e1bec47c6588aaa491c41a3e4
JOB LOG    : /home/Anu/tests/results/job-2026-08-11T18.51-55af53d/job.log
 (01/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (01/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (77.86 s)
 (02/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (02/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (105.35 s)
 (03/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (03/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (104.63 s)
 (04/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (04/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (107.97 s)
 (05/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (05/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (8.82 s)
 (06/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (06/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (77.08 s)
 (07/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (07/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (104.38 s)
 (08/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (08/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (104.56 s)
 (09/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (09/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (107.72 s)
 (10/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (10/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (8.80 s)
 (11/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (11/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (76.54 s)
 (12/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (12/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (104.55 s)
 (13/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (13/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (105.14 s)
 (14/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (14/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (107.78 s)
 (15/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (15/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (8.81 s)
 (16/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (16/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (77.51 s)
 (17/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (17/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (104.03 s)
 (18/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (18/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (104.59 s)
 (19/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (19/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (107.65 s)
 (20/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (20/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (8.77 s)
 (21/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (21/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (73.14 s)
 (22/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (22/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (101.25 s)
 (23/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (23/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (102.86 s)
 (24/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (24/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (105.20 s)
 (25/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (25/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (7.13 s)
 (26/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (26/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (68.90 s)
 (27/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (27/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (101.63 s)
 (28/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (28/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (102.24 s)
 (29/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (29/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (104.76 s)
 (30/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (30/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (7.15 s)
 (31/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (31/35) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (77.09 s)
 (32/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: STARTED
 (32/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_2: PASS (99.29 s)
 (33/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: STARTED
 (33/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_4: PASS (100.01 s)
 (34/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: STARTED
 (34/35) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_topology.threads_8: PASS (102.23 s)
 (35/35) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (35/35) io-github-autotest-libvirt.remove_guest.without_disk: PASS (8.77 s)
RESULTS    : PASS 35 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/Anu/tests/results/job-2026-08-11T18.51-55af53d/results.html
JOB TIME   : 2885.27 s
19:39:50 INFO    :
19:39:50 INFO    : Summary of test results can be found below:
TestSuite                                                                                 TestRun    Summary

guest_cpu_topology                                                                        Run        Successfully executed
/home/Anu/tests/results/job-2026-08-11T18.51-55af53d/job.log
| PASS 35 || CANCEL 0 || ERRORS 0 || FAILURES 0 || SKIP 0 || WARN 0 || INTERRUPT 0 |

Test suites status:

TOTAL                1
RUN                  1
NOT_RUN              0
CANT_RUN             0

Final count summary for tests run:

TOTAL                35
PASS                 35
CANCEL               0
ERRORS               0
FAILURES             0
SKIP                 0
WARN                 0
INTERRUPT            0
19:39:50 INFO    : Removing temporary mux dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant