-
Notifications
You must be signed in to change notification settings - Fork 188
libvirt_mem: Add vhost configuration for SLES #6886
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -116,6 +116,56 @@ def restore_hugepages(page_size=4): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.restore() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| utils_libvirtd.libvirtd_restart() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def setup_vhost_max_mem_regions(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Configure vhost max_mem_regions for SLES systems. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SLES has lower default values compared to other distros. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This is required for memory hotplug tests with max_slots. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Must be called when no VM is using vhost modules. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This function applies runtime configuration only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| For persistent configuration across reboots, manually create: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /etc/modprobe.d/vhost.conf with content: options vhost max_mem_regions=512 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if running on SLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| distro_check = process.run("cat /etc/os-release | grep -i sles", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell=True, ignore_status=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if distro_check.exit_status == 0: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.info("SLES detected, configuring vhost max_mem_regions=512") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vm_check = process.run("virsh list --state-running | grep -v 'Id\\|^$\\|^-'", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell=True, ignore_status=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if vm_check.exit_status == 0 and vm_check.stdout_text.strip(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.warning("Running VMs detected, skipping vhost configuration for safety:") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.warning("%s", vm_check.stdout_text.strip()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.info("No running VMs detected, proceeding with vhost configuration") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.run("modprobe -r vhost_net vhost_scsi vhost_vsock vhost", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell=True, ignore_status=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = process.run("modprobe vhost max_mem_regions=512", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell=True, ignore_status=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if result.exit_status == 0: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.info("Successfully configured vhost max_mem_regions=512 at runtime") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verify_cmd = "cat /sys/module/vhost/parameters/max_mem_regions" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verify_result = process.run(verify_cmd, shell=True, ignore_status=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if verify_result.exit_status == 0: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_value = verify_result.stdout_text.strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.info("Verified vhost max_mem_regions is set to: %s", current_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if current_value != "512": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.warning("Expected 512 but got %s", current_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.debug("Could not verify vhost max_mem_regions setting") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.warning("Failed to configure vhost at runtime: %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result.stderr_text) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.debug("Non-SLES system detected, skipping vhost configuration") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.warning("Error setting up vhost max_mem_regions: %s", str(e)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+148
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setup precondition failures are downgraded to warnings, so the test can continue in invalid state. At Line 155-156 and Line 165-166, failed verification and unexpected exceptions only log warnings. For SLES-targeted setup, this should fail/cancel the test path instead of silently continuing. Suggested fix- if current_value != "512":
- logging.warning("Expected 512 but got %s", current_value)
+ if current_value != "512":
+ test.cancel("vhost max_mem_regions verification failed: expected 512, got %s"
+ % current_value)
...
- else:
- logging.warning("Failed to configure vhost at runtime: %s",
- result.stderr_text)
+ else:
+ test.cancel("Failed to configure vhost at runtime: %s" % result.stderr_text)
...
- except Exception as e:
- logging.warning("Error setting up vhost max_mem_regions: %s", str(e))
+ except Exception as e:
+ test.cancel("Error setting up vhost max_mem_regions: %s" % str(e))📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.15.15)[error] 151-151: Function call with (S604) [warning] 165-165: Do not catch blind exception: (BLE001) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def check_qemu_cmd(max_mem_rt, tg_size): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Check qemu command line options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -528,6 +578,8 @@ def modify_domain_xml(): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Destroy domain first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if vm.is_alive(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vm.destroy(gracefully=False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Configure vhost max_mem_regions for SLES (VM is now stopped) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setup_vhost_max_mem_regions() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| modify_domain_xml() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numa_info = utils_misc.NumaInfo() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.debug(numa_info.get_all_node_meminfo()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard command can misclassify
virshfailures as “safe to proceed.”At Line 135, the pipeline status reflects
grep, notvirsh. Ifvirsh listfails, this branch can still fall through and proceed with module reload. Please split command execution sovirshfailure is handled explicitly before parsing output.Suggested fix
🧰 Tools
🪛 Ruff (0.15.15)
[error] 135-135: Function call with
shell=Trueparameter identified, security issue(S604)
🤖 Prompt for AI Agents