Skip to content

Move memory conversion helpers to libvirt module#84

Merged
cgwalters merged 5 commits into
bootc-dev:mainfrom
cgwalters:fix-unused
Oct 22, 2025
Merged

Move memory conversion helpers to libvirt module#84
cgwalters merged 5 commits into
bootc-dev:mainfrom
cgwalters:fix-unused

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

The module structure was twisted and this caused dead_code they belong, as these are libvirt-specific helpers for parsing libvirt domain XML memory specifications, not generic XML utilities.

Assisted-by: Claude Code

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @cgwalters, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the codebase by relocating libvirt-specific memory parsing and conversion utilities. The goal is to enhance the logical grouping of code, ensuring that functions directly related to libvirt XML processing reside within the dedicated libvirt module, thereby improving maintainability and code clarity.

Highlights

  • Code Relocation: The memory conversion helper functions, convert_memory_to_mb and parse_memory_mb, have been moved from generic utility modules to the libvirt module.
  • Improved Module Structure: This change clarifies that these helpers are specific to parsing libvirt domain XML memory specifications, improving the overall module organization and removing previously 'dead_code' due to twisted module structure.
  • Dependency Update: Call sites for parse_memory_mb in domain_list.rs have been updated to reflect the new location of the function within the libvirt module.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a good refactoring that moves libvirt-specific memory conversion helpers from a general utility module to the more appropriate libvirt module. This improves code organization and modularity. I've identified a critical issue related to a potential integer overflow that could lead to incorrect memory calculations, along with a few suggestions to improve code maintainability.

Comment thread crates/kit/src/libvirt/mod.rs Outdated
Comment thread crates/kit/src/libvirt/mod.rs
Comment thread crates/kit/src/lib.rs
Comment thread crates/kit/src/libvirt/mod.rs Outdated
@cgwalters cgwalters force-pushed the fix-unused branch 5 times, most recently from a2c5585 to 2aa31c4 Compare October 22, 2025 16:59
@cgwalters cgwalters enabled auto-merge (rebase) October 22, 2025 17:03
@cgwalters cgwalters requested a review from jmarrero October 22, 2025 17:03
Copy link
Copy Markdown
Collaborator

@jmarrero jmarrero left a comment

Choose a reason for hiding this comment

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

code lgtm but CI is not happy

@cgwalters
Copy link
Copy Markdown
Collaborator Author

Yeah my bad for trying to fix this manually, after chatting with an agent the issue became more obvious (I thought it was just validate failing).

The module structure was twisted and this caused dead_code
they belong, as these are libvirt-specific helpers for parsing libvirt
domain XML memory specifications, not generic XML utilities.

Assisted-by: Claude Code
Signed-off-by: Colin Walters <walters@verbum.org>
We were missing the lint setup between the main kit crate
and the workspace. Fix up the resulting warnings.

Signed-off-by: Colin Walters <walters@verbum.org>
Clean up duplication.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
Our unit stuff was messy, this cleans it up a lot.
Maybe at some point we should look for a crate that handles explicit
units.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
Refactor string parsing to use idiomatic Rust methods:
- parse_size: Use strip_suffix for unit detection instead of rfind/split_at
- parse_memory_to_mb: Use strip_suffix for G/M/K detection
- libvirt/domain: Use strip_prefix for "bridge=" prefix removal

This is cleaner, more readable, and follows Rust best practices.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters merged commit 4f26e07 into bootc-dev:main Oct 22, 2025
2 checks passed
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.

2 participants