-
Notifications
You must be signed in to change notification settings - Fork 179
Add vdpa_utils.py #4271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add vdpa_utils.py #4271
Conversation
JOB ID : b3bca2d94ce70d5ce4502d8a8b6bd11dc3c63b4d |
Can you provide detailed commit messages? Without that, I would not know what PR does. |
I have updated. please help review, thanks a lot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- generic/tests/cfg/netperf.cfg: Language not supported
- qemu/tests/cfg/vdpa_dpdk.cfg: Language not supported
JOB LOG : /root/avocado/job-results/job-2025-04-16T03.24-59f5e21/job.log |
LGTM |
generic/tests/cfg/netperf.cfg
Outdated
@@ -34,6 +34,7 @@ | |||
#numa configration | |||
numa_node = -1 | |||
netperf_with_numa = yes | |||
add_flows = yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be under the vdpa namespace, not for bridge
, macvtap
etc.
provider/vdpa_utils.py
Outdated
def check_ovs_status(): | ||
""" | ||
Check if ovs-vsctl and openvswitch service are installed and running. | ||
|
||
:return: True if both are available and running, otherwise False | ||
:rtype: bool | ||
""" | ||
cmd = "which ovs-vsctl && systemctl status openvswitch.service" | ||
return process.system(cmd, ignore_status=True, shell=True) == 0 | ||
|
||
|
||
def get_ovs_bridges(): | ||
""" | ||
Get all ovs bridges. | ||
|
||
:return: List of ovs bridge names | ||
:rtype: list | ||
""" | ||
cmd = "ovs-vsctl list-br" | ||
return process.system_output(cmd, shell=True).decode().split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avocado-vt supports get ovs bridge, and it can check if OVS is supported, why we need these dup code here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you are referring to OpenVSwitchControlCli_140 in virttest/openvswitch.py, which is a subclass. I tried using it, but it seems that it cannot currently jump from OpenVSwitchControl to OpenVSwitchControlCli_140, so there is a bug when using list_br.
[stderr] ovs_br_all = self.ovs.list_br()
[stderr] File "/usr/local/lib/python3.9/site-packages/virttest/openvswitch.py", line 199, in list_br
[stderr] raise NotImplementedError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean ovs implement in utils_net.py. It can get the bridge manager based on the provided bridge name, and handle port related, openflow related stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored the code in utils_net.py to use the ovs implementation, and it has passed testing and debugging. Please help review the changes.
JOB LOG : /root/avocado/job-results/job-2025-04-29T10.04-c69885b/job.log
(1/1) repeat1.Host_RHEL.m9.u6.ovmf.qcow2.virtio_blk.up.virtio_net.Guest.RHEL.9.6.0.x86_64.io-github-autotest-qemu.vdpa_dpdk.q35: STARTED
(1/1) repeat1.Host_RHEL.m9.u6.ovmf.qcow2.virtio_blk.up.virtio_net.Guest.RHEL.9.6.0.x86_64.io-github-autotest-qemu.vdpa_dpdk.q35: PASS (510.80 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /root/avocado/job-results/job-2025-04-29T10.04-c69885b/results.html
[stdlog] 2025-04-29 10:06:02,566 avocado.utils.process process L0657 INFO | Running '/bin/ovs-vsctl --db=unix:/var/run/openvswitch/db.sock list-br'
[stdlog] 2025-04-29 10:06:02,573 avocado.utils.process process L0471 DEBUG| [stdout] ens1f1np1_br
[stdlog] 2025-04-29 10:06:02,574 avocado.utils.process process L0714 INFO | Command '/bin/ovs-vsctl --db=unix:/var/run/openvswitch/db.sock list-br' finished with 0 after 0.003970255s
[stdlog] 2025-04-29 10:06:02,574 avocado.utils.process process L0657 INFO | Running 'ovs-ofctl dump-flows ens1f1np1_br'
[stdlog] 2025-04-29 10:06:02,581 avocado.utils.process process L0471 DEBUG| [stdout] NXST_FLOW reply (xid=0x4):
[stdlog] 2025-04-29 10:06:02,581 avocado.utils.process process L0471 DEBUG| [stdout] cookie=0x0, duration=0.032s, table=0, n_packets=0, n_bytes=0, idle_age=0, in_port=1 actions=output:2
[stdlog] 2025-04-29 10:06:02,581 avocado.utils.process process L0471 DEBUG| [stdout] cookie=0x0, duration=0.015s, table=0, n_packets=0, n_bytes=0, idle_age=0, in_port=2 actions=output:1
[stdlog] 2025-04-29 10:06:02,581 avocado.utils.process process L0471 DEBUG| [stdout] cookie=0x0, duration=88.580s, table=0, n_packets=20, n_bytes=1880, idle_age=24, priority=0 actions=NORMAL
[stdlog] 2025-04-29 10:06:02,581 avocado.utils.process process L0714 INFO | Command 'ovs-ofctl dump-flows ens1f1np1_br' finished with 0 after 0.003860986s
This patch introduces an OVSHandler class and supporting functions: - check ovs status and retrieve bridge/port information - handle vdpa device integration with ovs - add flow rules to ovs bridge - provide flexible bridge and port info for vm - add vdpa_dpdk case usage: add flows rules to ovs - add netperf case usage: add flows rules to ovs and get vdpa ovs port info Signed-off-by: Wenli Quan <[email protected]>
LOG_JOB = logging.getLogger("avocado.test") | ||
|
||
|
||
def check_ovs_status(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we still need this. init_system
in openvswitch.py will help set up the openvswitch service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of check_ovs_status() is to ensure that OVSHandler uses the existing ovs configuration in the system.
The initialization behavior of init_system is not suitable for this scenario.
This patch introduces an OVSHandler class and supporting functions:
port info
Signed-off-by: Wenli Quan [email protected]
id:3441