Skip to content

Switch to quick-xml#18

Merged
cgwalters merged 1 commit into
mainfrom
xml
Sep 24, 2025
Merged

Switch to quick-xml#18
cgwalters merged 1 commit into
mainfrom
xml

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

Generating and parsing XML manually by scraping and gluing strings is obviously bad.

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 significantly refactors the XML handling within the 'kit' crate by integrating the 'quick-xml' library. The change moves away from error-prone string concatenation for XML generation and simple string searching for XML parsing, replacing them with a dedicated, robust XML parsing and writing library. This enhancement centralizes XML utilities, improves the correctness and maintainability of libvirt domain and volume definitions, and makes the XML processing more resilient to malformed input.

Highlights

  • XML Library Integration: Switched from manual string-based XML handling to the 'quick-xml' crate for both generating and parsing XML, improving robustness and correctness.
  • Centralized XML Utilities: Introduced a new 'xml_utils' module to encapsulate 'quick-xml' based XML writing and parsing logic, promoting code reuse and maintainability.
  • Improved XML Generation: Refactored libvirt domain XML creation and volume metadata generation to use the new 'XmlWriter' for programmatic and safer XML construction.
  • Robust XML Parsing: Replaced custom string-scraping XML value extraction with 'quick-xml' based parsing functions for increased reliability and resilience to malformed input.
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

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 significant improvement, replacing manual XML string manipulation with the quick-xml crate. This greatly enhances the code's correctness, maintainability, and security by ensuring well-formed XML is always generated and parsed. The introduction of the xml_utils module centralizes this logic effectively. While the overall direction is excellent, I've identified a critical issue in the volume metadata handling within libvirt_upload_disk.rs where the current implementation is non-functional. I've also included a few suggestions to improve performance and code clarity in the new utilities and their corresponding tests.

Comment thread crates/kit/src/arch.rs
Comment thread crates/kit/src/libvirt/domain.rs Outdated
Comment thread crates/kit/src/xml_utils.rs Outdated
Generating and parsing XML manually by scraping and gluing strings
is obviously bad.

Assisted-by: Claude Code
Signed-off-by: Colin Walters <walters@verbum.org>
Copy link
Copy Markdown
Collaborator

@jeckersb jeckersb left a comment

Choose a reason for hiding this comment

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

Just quickly skimmed this, but definitely an improvement over the status quo 👍

@cgwalters cgwalters merged commit 37d3b7a into main Sep 24, 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