1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(instances): a new VM's CPU is a mode or a model the host offers, checked by libvirt

- A named CPU model is written without check='none' and with
  fallback='forbid': libvirt checks before the start that the host runs
  it, and it is not swapped for another model.
- Mode maximum is written as that mode; it was written as a model named
  maximum.
- Model names up to 64 characters: the -noTSX and -IBRS models, the ones a
  mixed set of hosts needs, were refused at 20.
- The mode or model is checked against the host's capabilities when the VM
  is defined, from the page and the API alike; no CPU element (QEMU's
  oldest default CPU) is no longer offered.
- The default CPU mode setting offers the modes the new VM dialog has;
  no-model and custom, which matched none of them, become host-model.
This commit is contained in:
catborise 2026-10-29 10:50:20 +03:00
parent d5ef7cff75
commit 5eb544eb8a
15 changed files with 139 additions and 19 deletions

View file

@ -46,7 +46,7 @@ from operations import claims, jobs
from operations.utils import busy_message, summary
from webvirtcloud.middleware import error_text, same_origin_referer
from vrtManager import util
from vrtManager.create import wvmCreate
from vrtManager.create import cpu_choices, wvmCreate
from vrtManager.instance import USAGE_MAX_WINDOW
from vrtManager.interface import wvmInterface
from vrtManager.storage import wvmStorage
@ -2237,7 +2237,9 @@ def create_instance(request, compute_id, arch, machine):
raise util.OperationError(_("You haven't defined any network pools"))
vm_form = NewVMForm(initial={
"vcpu": 1, "memory": 512, "firmware": default_firmware, "vcpu_mode": default_cpu_mode,
# a default this host does not offer is no choice: the select asks for one
"vcpu": 1, "memory": 512, "firmware": default_firmware,
"vcpu_mode": default_cpu_mode if default_cpu_mode in cpu_choices(dom_caps) else "",
"cache_mode": default_cache, "net_model": default_nic_type, "listener_addr": "0.0.0.0",
"add_cdrom": default_cdrom, "add_input": default_input_device_bus, "video": default_video,
"qemu_ga": True, "virtio": bool(virtio_support),