Skip to content

utils_disk: Add a default mount option#4214

Closed
cliping wants to merge 1 commit intoavocado-framework:masterfrom
cliping:disk-mount
Closed

utils_disk: Add a default mount option#4214
cliping wants to merge 1 commit intoavocado-framework:masterfrom
cliping:disk-mount

Conversation

@cliping
Copy link
Copy Markdown
Contributor

@cliping cliping commented Aug 10, 2025

In mount(), if there are no mount option, is_mount() will always return True. So add a default mount option.

Before:
[stdlog] 2025-08-10 11:30:45,881 aexpect.client client L1412 DEBUG| Sending command (safe): findmnt -J -S /dev/sda1 -M /mnt/sda1 -t ext4 -O
[stdlog] 2025-08-10 11:30:45,986 avocado.virttest.utils_disk utils_disk L0094 INFO | Output of findmnt: findmnt: option requires an argument -- 'O'
[stdlog] Try 'findmnt --help' for more information.
[stdlog] 2025-08-10 11:30:45,986 avocado.virttest.utils_disk utils_disk L0100 INFO | /dev/sda1 is mounted
[stdlog] 2025-08-10 11:30:45,986 aexpect.client client L1412 DEBUG| Sending command (safe): mount -t ext4 -o remount, /dev/sda1 /mnt/sda1
[stdlog] 2025-08-10 11:30:46,091 aexpect.client client L1412 DEBUG| Sending command (safe): echo $?

After:
[stdlog] 2025-08-10 12:07:27,419 aexpect.client client L1412 DEBUG| Sending command (safe): findmnt -J -S /dev/sda1 -M /mnt/sda1 -t ext4 -O rw
[stdlog] 2025-08-10 12:07:27,524 avocado.virttest.utils_disk utils_disk L0094 INFO | Output of findmnt:
[stdlog] 2025-08-10 12:07:27,524 avocado.virttest.utils_disk utils_disk L0103 INFO | /dev/sda1 is not mounted
[stdlog] 2025-08-10 12:07:27,524 aexpect.client client L1412 DEBUG| Sending command (safe): mount -t ext4 -o rw /dev/sda1 /mnt/sda1

(1/1) type_specific.io-github-autotest-libvirt.migration_with_copy_storage.migration_retain_sparsity.disk_num_1.dest1_qcow2.src1_qcow2.copy_storage_all: STARTED
(1/1) type_specific.io-github-autotest-libvirt.migration_with_copy_storage.migration_retain_sparsity.disk_num_1.dest1_qcow2.src1_qcow2.copy_storage_all: PASS (213.17 s)

Summary by CodeRabbit

  • Refactor
    • Improved disk mounting process by explicitly setting read-write options and enabling verbose logging for better clarity during operations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 10, 2025

📝 Walkthrough

Walkthrough

The change updates the configure_empty_linux_disk function in virttest/utils_disk.py to modify its call to the mount function. Two new arguments are added: options='rw' for read-write mounting and verbose=True for verbose logging. No other logic or structural changes are present.

Changes

Cohort / File(s) Change Summary
Mount Function Call Update
virttest/utils_disk.py
The mount function call in configure_empty_linux_disk now includes options='rw' and verbose=True arguments.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 475ee4f and 21153e6.

📒 Files selected for processing (1)
  • virttest/utils_disk.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • virttest/utils_disk.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Static checks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27641ba and 784145a.

📒 Files selected for processing (1)
  • virttest/utils_disk.py (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
virttest/utils_disk.py

[error] 1100-1120: Black formatting check failed. The file would be reformatted. Run 'black avocado-vt/virttest/utils_disk.py' to fix code style issues.

🔇 Additional comments (1)
virttest/utils_disk.py (1)

1115-1116: Centralize mount() defaults but review all call sites

Before applying the targeted fix in utils_disk.mount(), note that we’ve identified numerous other invocations of mount() without an explicit options= argument. Defaulting empty options to "rw" will inject -o rw into each of these calls, which may subtly change behavior in different contexts. Please review whether a global "rw" default is appropriate for all of them or if specific call sites need explicit overrides.

Call sites without options= (excerpt):

  • virttest/nfs.py:225 (utils_misc.mount(self.mount_src, self.mount_dir, "nfs", perm=self.mount_options))
  • virttest/utils_libguestfs.py:708, 766
  • virttest/utils_disk.py:775, 824, 1671
  • virttest/vt_utils/filesystem.py:64, 199, 278
  • virttest/utils_v2v.py:1652
  • virttest/utils_test/init.py:711
  • virttest/gluster.py:252

Proposed global refactor in virttest/utils_disk.py:

@@ def mount(src, dst, fstype=None, options=None, verbose=False, session=None):
-    # Normalize options; keep empty string internal but avoid passing empty "-O" to findmnt
-    options = options or ""
+    # Normalize options: skip findmnt filter if empty, then default to "rw" for actual mount
+    options = options or None

-    mounted = is_mount(src, dst, fstype, options if options else None, verbose, session)
+    mounted = is_mount(src, dst, fstype, options, verbose, session)

-    if mounted and "remount" not in options:
-        options = "remount" if not options else f"remount,{options}"
+    if mounted and (not options or "remount" not in options):
+        options = "remount" if not options else f"remount,{options}"

-    # If options is still empty, apply default "rw" to align with PR objective
-    eff_options = options or "rw"
-    if eff_options:
-        cmd.extend(["-o", eff_options])
+    # Always provide an -o flag: default to "rw" when options is None
+    cmd.extend(["-o", options or "rw"])

Please confirm the default-rw behavior is acceptable across all listed call sites or adjust those that require different mount options.

Comment thread virttest/utils_disk.py Outdated
In mount(), if there are no mount option, is_mount() will always
return True. So add a default mount option in
configure_empty_linux_disk().

Signed-off-by: lcheng <lcheng@redhat.com>
@cliping
Copy link
Copy Markdown
Contributor Author

cliping commented Aug 13, 2025

Since 4199 can fix this issue. So close this PR.

@cliping cliping closed this Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant