Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm_xml: set_vm_vcpus() support clusters #4006

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading