1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 00:16:04 +00:00

fix(vrtManager): a vCPU maximum the CPU topology does not make is refused first

A VM with a CPU topology takes only the maximum it makes; libvirt
refused another one after the vCPU hotplug list had been removed, so a
failed resize left hotplug off. The maximum is now checked against the
topology before anything changes, with tr and zh translations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-08 14:40:06 +03:00
parent e206862856
commit 1ddc941b2d
6 changed files with 58 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import contextlib
import ipaddress
import json
import logging
import math
import os.path
import re
import string
@ -1681,9 +1682,15 @@ class wvmInstance(wvmConnect):
raise util.OperationError(gettext_noop("The VM has no video card"))
def resize_cpu(self, cur_vcpu, vcpu):
"""
Function change ram and cpu on instance.
"""
"""The current and maximum vCPUs of a shut-off VM. A CPU topology
fixes the maximum: libvirt refuses another one."""
topology = etree.fromstring(self._XMLDesc(PERSISTENT_XML)).find("cpu/topology")
if topology is not None:
count = math.prod(int(value) for key, value in topology.attrib.items()
if key in ("sockets", "dies", "clusters", "cores", "threads"))
if count != int(vcpu):
raise util.OperationError(gettext_noop("The VM's CPU topology has %(count)s vCPUs: change it in the "
"XML editor to set another maximum"), count=count)
is_vcpus_enabled = self.get_vcpus()
if is_vcpus_enabled:
self.set_vcpu_hotplug(False)