Skip to content

Improve libvirt_vm.add_nic to support ovs virtualport attribute#4337

Merged
YongxueHong merged 1 commit intoavocado-framework:masterfrom
yanglei-rh:LIBVIRTAT-22360
Mar 12, 2026
Merged

Improve libvirt_vm.add_nic to support ovs virtualport attribute#4337
YongxueHong merged 1 commit intoavocado-framework:masterfrom
yanglei-rh:LIBVIRTAT-22360

Conversation

@yanglei-rh
Copy link
Copy Markdown
Contributor

It should be a design flaw; when netdst is ovs, attribute virtualport_type needs to be added

ID: LIBVIRTAT-22360
Signed-off-by: Lei Yang leiyang@redhat.com

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 enhances the libvirt_vm.add_nic function to properly configure virtual network interfaces when connecting to Open vSwitch bridges. It ensures that VMs are correctly provisioned with the necessary virtualport_type attribute, improving compatibility and functionality with OVS-based networks.

Highlights

  • Open vSwitch Integration: Modified libvirt_vm.add_nic to automatically include virtualport_type=openvswitch when the network destination (netdst) is an existing Open vSwitch bridge, resolving a previous design oversight.
Changelog
  • virttest/libvirt_vm.py
    • Imported utils_net module.
    • Added logic to append virtualport_type=openvswitch to NIC configuration if the network destination is an OVS bridge.
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 correctly adds support for the virtualport_type=openvswitch attribute in libvirt_vm.add_nic when the network destination is an Open vSwitch bridge. The implementation is straightforward. However, there's a potential robustness issue: the call to utils_net.ovs_br_exists() may raise an exception if OVS is not installed, causing unrelated tests to fail. I've suggested adding a try...except block to handle this gracefully, ensuring that the absence of OVS doesn't lead to test failures.

Comment thread virttest/libvirt_vm.py Outdated
@yanglei-rh
Copy link
Copy Markdown
Contributor Author

Test pass both netdst=virbr0 and netdst=ovs0.
(1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.qemu_test.netperf_stress_test.TCP_STREAM.guest2guest.q35: PASS (207.28 s)

@yanglei-rh yanglei-rh force-pushed the LIBVIRTAT-22360 branch 2 times, most recently from fb6ac48 to a077a96 Compare March 11, 2026 10:19
It should be a design flaw; when netdst is ovs, attribute
virtualport_type needs to be added

Signed-off-by: Lei Yang <leiyang@redhat.com>
@yanglei-rh
Copy link
Copy Markdown
Contributor Author

All of the following test scenarios passed the test:

  1. Server exists ovs bridge and test it
    (1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.qemu_test.netperf_stress_test.TCP_STREAM.guest2guest.q35: PASS (206.29 s)
  2. Server doesn't exists ovs bridge,but still tested, and the expected error is obtained
    (1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.qemu_test.netperf_stress_test.TCP_STREAM.guest2guest.q35: ERROR: Bridge 'ovs0' does not exist (6.76 s)
  3. Server exists ovs bridge, but testing a bridge name that does not exist
    (1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.qemu_test.netperf_stress_test.TCP_STREAM.guest2guest.q35: ERROR: Bridge 'switch' does not exist (6.53 s)
  4. Server exists ovs bridge, but test with libvirt default network
    (1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.qemu_test.netperf_stress_test.TCP_STREAM.guest2guest.q35: PASS (206.52 s)

Copy link
Copy Markdown

@YongxueHong YongxueHong left a comment

Choose a reason for hiding this comment

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

LGTM.

@yanglei-rh
Copy link
Copy Markdown
Contributor Author

Hi @Yingshun Could you please help me review this patch again? Because I changed some code to implement commit mentioned fucntion.

@YongxueHong YongxueHong merged commit 2dfb027 into avocado-framework:master Mar 12, 2026
29 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.

3 participants