Skip to content

Conversation

@nanli1
Copy link
Contributor

@nanli1 nanli1 commented Jan 29, 2026

revoke utils_sys.display_remote_log

We need some default values for set_remote_log function to improve the convenicence, and remove the utils_sys.display_remote_log function

Signed-off-by: nanli [email protected]

avocado-framework/avocado-vt#4316

Summary by CodeRabbit

  • New Features
    • Remote libvirtd logs can now be displayed after migrations when enabled.
    • Remote SSH sessions are automatically stored and reused for subsequent operations.
    • Improved integration of remote service operations with the migration workflow for better visibility and efficiency.

✏️ Tip: You can customize this high-level summary in your review settings.

… revoke utils_sys.display_remote_log

We need some default values for set_remote_log function to improve the
convenicence, and remove the utils_sys.display_remote_log function

Signed-off-by: nanli <[email protected]>
@nanli1 nanli1 added the depend on The PR has dependency on other PRs label Jan 29, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

The changes enhance remote libvirtd logging functionality in the migration workflow. The set_remote_log method now accepts default parameter values for log configuration and logs debug messages during setup initialization. The remote SSH session established during this process is stored in self.params under the "remote_session" key for subsequent reuse. The remote libvirtd service is restarted as part of the setup, and the resulting session is preserved. In the run_migration method, if remote libvirtd logging is enabled, the system displays the remote logs immediately after the migration command completes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is incomplete and uses truncation ('and…'), making it vague and failing to fully convey the main changes of adding default parameters and removing a function. Complete the title to clearly describe both primary changes, such as: 'Add default parameters to set_remote_log and remove display_remote_log function' or specify the most important change if it's just one.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@provider/migration/base_steps.py`:
- Around line 390-398: There's a syntax error in the server_ip default: change
self.params.get("server_ip", self.params.get("migrate_dest_host)")) to
self.params.get("server_ip", self.params.get("migrate_dest_host")) and then
propagate defaults back into self.params so subsequent calls use them; e.g.
after computing
server_ip/server_pwd/server_user/remote_file_type/log_level/log_file/log_filters
assign them into self.params (self.params["server_ip"]=server_ip etc.) so
remote.run_remote_cmd and update_remote_file read the resolved values. Ensure
the corrected keys are used where referenced (server_ip, server_pwd,
server_user, remote_file_type) to avoid missing-key behavior.
- Around line 190-191: The code calls the removed function
utils_sys.display_remote_log inside the if-check
self.params.get_boolean("set_remote_libvirtd_log"); remove that call or replace
it with the new pattern using set_remote_log() — locate the conditional in
base_steps.py and either delete the utils_sys.display_remote_log(...) invocation
or invoke utils_sys.set_remote_log(self.params, self.test) (or the appropriate
set_remote_log signature) so the deprecated function is not referenced.
🧹 Nitpick comments (1)
provider/migration/base_steps.py (1)

412-414: Close remote_session during cleanup to avoid SSH leaks.

The session is stored but never closed in cleanup_default. Please close it there to avoid leaking SSH connections across tests.

♻️ Suggested cleanup
         self.test.log.debug("Recover test environment")
         if set_remote_libvirtd_log and self.remote_libvirtd_log:
             del self.remote_libvirtd_log
+        remote_session = self.params.pop("remote_session", None)
+        if remote_session:
+            remote_session.close()

Comment on lines +190 to +191
if self.params.get_boolean("set_remote_libvirtd_log"):
utils_sys.display_remote_log(self.params, self.test)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Search for display_remote_log definition and imports
rg -n "display_remote_log" --type-list

Repository: autotest/tp-libvirt

Length of output: 452


🏁 Script executed:

# Find where display_remote_log is defined and used
rg -n "def display_remote_log|display_remote_log" -A 2

Repository: autotest/tp-libvirt

Length of output: 240


🏁 Script executed:

# Check the imports and context in base_steps.py around lines 190-191
head -200 provider/migration/base_steps.py | tail -30

Repository: autotest/tp-libvirt

Length of output: 1701


🏁 Script executed:

# Also check imports at the top of the file
head -30 provider/migration/base_steps.py

Repository: autotest/tp-libvirt

Length of output: 813


🏁 Script executed:

# Search for the definition of display_remote_log function
rg -n "def display_remote_log"

Repository: autotest/tp-libvirt

Length of output: 45


🏁 Script executed:

# Check if utils_sys module exists and search for display_remote_log there
find . -name "utils_sys.py" -o -name "utils_sys" -type d

Repository: autotest/tp-libvirt

Length of output: 45


🏁 Script executed:

# Search in virttest for display_remote_log
rg -n "display_remote_log" . --type py -B 2 -A 5

Repository: autotest/tp-libvirt

Length of output: 667


🏁 Script executed:

# Check git history for references to display_remote_log removal or changes
git log --all --oneline | head -20

Repository: autotest/tp-libvirt

Length of output: 1515


🏁 Script executed:

# Search for any comments or TODOs about display_remote_log
rg -n "display_remote_log|libvirtd_log" -B 3 -A 3 --type py

Repository: autotest/tp-libvirt

Length of output: 50375


🏁 Script executed:

# Check if there's a CHANGES file or documentation about API changes
find . -name "CHANGES*" -o -name "NEWS*" -o -name "README*" | head -5

Repository: autotest/tp-libvirt

Length of output: 97


Remove the call to the revoked display_remote_log function at line 191.

The commit 7059b4f51 explicitly revoked utils_sys.display_remote_log, yet line 191 still calls this non-existent function. This will cause an AttributeError at runtime. The enhancement introduced set_remote_log() as the replacement mechanism—if remote log display is needed, use that pattern instead or remove this call entirely.

🤖 Prompt for AI Agents
In `@provider/migration/base_steps.py` around lines 190 - 191, The code calls the
removed function utils_sys.display_remote_log inside the if-check
self.params.get_boolean("set_remote_libvirtd_log"); remove that call or replace
it with the new pattern using set_remote_log() — locate the conditional in
base_steps.py and either delete the utils_sys.display_remote_log(...) invocation
or invoke utils_sys.set_remote_log(self.params, self.test) (or the appropriate
set_remote_log signature) so the deprecated function is not referenced.

Comment on lines +390 to +398
log_level = self.params.get("libvirtd_debug_level", "1")
log_file = self.params.get("libvirtd_debug_file", "/var/log/libvirt/virtqemud.log")
log_filters = self.params.get("libvirtd_debug_filters", "1:*")
remote_file_type = self.params.get("remote_file_type", "virtqemud")
server_ip = self.params.get("server_ip", self.params.get("migrate_dest_host)"))
server_user = self.params.get("server_user", "root")
server_pwd = self.params.get("server_pwd", self.params.get("migrate_dest_pwd"))

self.test.log.debug(f"Start setting {remote_file_type} log on remote host")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix the server_ip default syntax error and propagate resolved defaults.

Line 394 has a mismatched quote/paren, which is a SyntaxError. Also, remote.run_remote_cmd and update_remote_file read from self.params, so defaults won’t apply if those keys are missing unless you write them back.

🛠️ Proposed fix
-        server_ip = self.params.get("server_ip", self.params.get("migrate_dest_host)"))
-        server_user = self.params.get("server_user", "root")
-        server_pwd = self.params.get("server_pwd", self.params.get("migrate_dest_pwd"))
+        server_ip = self.params.get("server_ip", self.params.get("migrate_dest_host"))
+        server_user = self.params.get("server_user", "root")
+        server_pwd = self.params.get("server_pwd", self.params.get("migrate_dest_pwd"))
+        # Ensure downstream helpers that read params see the resolved defaults
+        self.params.update({
+            "server_ip": server_ip,
+            "server_user": server_user,
+            "server_pwd": server_pwd,
+        })
🤖 Prompt for AI Agents
In `@provider/migration/base_steps.py` around lines 390 - 398, There's a syntax
error in the server_ip default: change self.params.get("server_ip",
self.params.get("migrate_dest_host)")) to self.params.get("server_ip",
self.params.get("migrate_dest_host")) and then propagate defaults back into
self.params so subsequent calls use them; e.g. after computing
server_ip/server_pwd/server_user/remote_file_type/log_level/log_file/log_filters
assign them into self.params (self.params["server_ip"]=server_ip etc.) so
remote.run_remote_cmd and update_remote_file read the resolved values. Ensure
the corrected keys are used where referenced (server_ip, server_pwd,
server_user, remote_file_type) to avoid missing-key behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

depend on The PR has dependency on other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant