Skip to content

Commit

Permalink
vm_xml: set_vm_vcpus() support clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Julia Graham <[email protected]>
  • Loading branch information
rh-jugraham committed Oct 9, 2024
1 parent 5ca5488 commit ee0bbfb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions virttest/libvirt_xml/vm_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ def set_vm_vcpus(
sockets=None,
cores=None,
threads=None,
clusters=None,
add_topology=False,
topology_correction=False,
update_numa=True,
Expand All @@ -952,6 +953,7 @@ def set_vm_vcpus(
:param sockets: number of socket, default None
:param cores: number of cores, default None
:param threads: number of threads, default None
:param clusters: number of clusters, default None
:param add_topology: True to add new topology definition if not present
:param topology_correction: Correct topology if wrong already
:param update_numa: Update numa
Expand Down Expand Up @@ -990,7 +992,11 @@ def set_vm_vcpus(
cores = topology["cores"]
if not threads:
threads = topology["threads"]
if (topology or add_topology) and (sockets or cores or threads):
if not clusters:
clusters = (
topology["clusters"] if topology["clusters"] is not None else 1
)
if (topology or add_topology) and (sockets or cores or threads or clusters):
# Only operate topology tag, other tags doesn't change
try:
vmcpu_xml = vmxml["cpu"]
Expand All @@ -1000,15 +1006,19 @@ def set_vm_vcpus(
if "aarch64" in platform.platform():
vmcpu_xml.mode = "host-passthrough"
if topology_correction and (
(int(sockets) * int(cores) * int(threads)) != vcpus
(int(sockets) * int(cores) * int(threads) * int(clusters)) != vcpus
):
cores = vcpus
sockets = 1
threads = 1
clusters = 1
if not clusters:
clusters = 1
vmcpu_xml["topology"] = {
"sockets": sockets,
"cores": cores,
"threads": threads,
"clusters": clusters,
}
vmxml["cpu"] = vmcpu_xml
try:
Expand Down

0 comments on commit ee0bbfb

Please sign in to comment.