Bug 2210287

Summary: The "dev" setting is ignored when it is used without address for passt interface
Product: Red Hat Enterprise Linux 9 Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
libvirt sub component: Networking QA Contact: yalzhang <yalzhang>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: dgibson, dzheng, haizhao, jdenemar, lmen, lvivier, mprivozn, sbrivio, virt-maint
Version: 9.3Keywords: AutomationBackLog, Triaged, Upstream
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-9.5.0-0rc1.1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:31:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version: 9.5.0
Embargoed:

Description yalzhang@redhat.com 2023-05-26 13:09:24 UTC
Description of problem:
The "dev" setting is ignored unexpectedly when it is used without
address for passt interface

Version-Release number of selected component (if applicable):
libvirt-9.3.0-2.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a vm of user type interface with passt backend as below:
# virsh dumpxml rhel --xpath //interface
<interface type="user">
  <mac address="52:54:00:49:84:12"/>
  <source dev="eno1"/>
  <portForward proto="tcp" dev="eno1">
    <range start="41335"/>
  </portForward>
  <model type="virtio"/>
  <backend type="passt"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

2. Start vm and check the passt process
# ps aux | grep 'bin/passt' | grep -v grep
qemu        9303  0.0  0.0  76344 33524 ?        Ss   08:59   0:00
/usr/bin/passt --one-off --socket
/run/libvirt/qemu/passt/7-rhel-net0.socket --mac-addr
52:54:00:49:84:12 --pid /run/libvirt/qemu/passt/7-rhel-net0-passt.pid
--interface eno1 --tcp-ports 41335

The "dev" setting is ignored unexpectedly, it should be like "--tcp-ports %eno1/41335"

Actual results:
The "dev" setting is ignored unexpectedly when it is used without address

Expected results:
The "dev" setting should be effective in the cmd line "--tcp-ports %eno1/41335"

Additional info:
And suggest to mention the "dev" attribute in the docs/formatdomain.rst

Comment 1 Michal Privoznik 2023-06-01 11:48:59 UTC
Patch posted on the list:

https://listman.redhat.com/archives/libvir-list/2023-June/240148.html

Comment 2 Michal Privoznik 2023-06-01 12:32:52 UTC
To POST:

commit 1c7335add9e28637d8a8b5039f487e5dc6a591c2
Author:     Michal Prívozník <mprivozn>
AuthorDate: Thu Jun 1 10:37:04 2023 +0200
Commit:     Michal Prívozník <mprivozn>
CommitDate: Thu Jun 1 14:25:08 2023 +0200

    qemu_passt: Format portForward device even without address
    
    It's almost like we've anticipated this. Our XML parser and
    formatter handles @address and @dev attributes of <portForward/>
    element completely independent of each other. And as of commit
    2023_03_29.b10b983~3 passt allows handling these two separately
    too. All that's left is generate the cmd line according to this
    new fact.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2210287
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: Ján Tomko <jtomko>

v9.4.0-3-g1c7335add9

Comment 5 yalzhang@redhat.com 2023-06-30 05:26:48 UTC
Hi Michal, the vm can not start successfully(See S3 below). Maybe it depends on a new passt build. Could you please help to confirm? Thank you!

S1: with both dev and address:
$ virsh dumpxml test1 --xpath //interface 
<interface type="user">
  <mac address="52:54:00:26:44:e5"/>
  <source dev="eno1"/>
  <portForward proto="tcp" dev="eno1" address='10.73.178.71'>
    <range start="41335"/>
  </portForward>
  <model type="virtio"/>
  <backend type="passt"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

will come up with:
$ ps aux | grep '/usr/bin/passt'
test       13544  0.0  0.2  76344 38124 ?        Ss   01:20   0:00 /usr/bin/passt --one-off --socket /run/user/1000/libvirt/qemu/run/passt/2-test1-net0.socket --mac-addr 52:54:00:26:44:e5 --pid /run/user/1000/libvirt/qemu/run/passt/2-test1-net0-passt.pid --interface eno1 --tcp-ports 10.73.178.71%eno1/41335

S2: only address
 <portForward proto="tcp" address='10.73.178.71'>
    <range start="41335"/>
  </portForward>

VM start successfully and the passt process is like this:
$ ps aux | grep '/usr/bin/passt'
test       13622  0.0  0.2  76344 38828 ?        Ss   01:21   0:00 /usr/bin/passt --one-off --socket /run/user/1000/libvirt/qemu/run/passt/3-test1-net0.socket --mac-addr 52:54:00:26:44:e5 --pid /run/user/1000/libvirt/qemu/run/passt/3-test1-net0-passt.pid --interface eno1 --tcp-ports 10.73.178.71/41335

S3: only dev, vm can not start successfully
<portForward proto="tcp" dev="eno1">
    <range start="41335"/>
  </portForward>

$ virsh start test1
error: Failed to start domain 'test1'
error: internal error: Child process (/usr/bin/passt --one-off --socket /run/user/1000/libvirt/qemu/run/passt/4-test1-net0.socket --mac-addr 52:54:00:26:44:e5 --pid /run/user/1000/libvirt/qemu/run/passt/4-test1-net0-passt.pid --interface eno1 --tcp-ports %eno1/41335) unexpected exit status 1: Invalid port specifier %eno1/41335

Comment 9 Jiri Denemark 2023-07-24 10:48:30 UTC
This BZ (it's pre-verification actually) is blocking libvirt packages from
making it into a RHEL compose. Could this be pre-verified earlier than after
the passt rebase in mid August? For example using passt from upstream or using
a scratch build (aka rebase pre-release) or something similar?

Comment 10 yalzhang@redhat.com 2023-07-26 06:57:56 UTC
Test with upstream passt and libvirt, the result is as expected:
# rpm -q passt libvirt
passt-g023d684-1.x86_64
libvirt-9.5.0-3.el9.x86_64

# getenforce 
Permissive

1) with address and interface:
# virsh dumpxml rhel --xpath //portForward
<portForward proto="tcp" address="10.73.178.37" dev="eno1">
  <range start="41335"/>
</portForward>

the passt cmdline:
# ps aux | grep 'usr/bin/passt' | grep -v grep 
qemu        5574  0.0  0.0  72936 37628 ?        Ss   02:54   0:00 /usr/bin/passt --one-off --socket /run/libvirt/qemu/passt/7-rhel-net0.socket --mac-addr 52:54:00:49:84:12 --pid /run/libvirt/qemu/passt/7-rhel-net0-passt.pid --interface eno1 --tcp-ports 10.73.178.37%eno1/41335

2) with address only:
# virsh dumpxml rhel --xpath //portForward
<portForward proto="tcp" address="10.73.178.37">
  <range start="41335"/>
</portForward>

the passt cmd line:
# ps aux | grep 'usr/bin/passt' | grep -v grep 
qemu        5692  0.0  0.0  72932 36628 ?        Ss   02:55   0:00 /usr/bin/passt --one-off --socket /run/libvirt/qemu/passt/8-rhel-net0.socket --mac-addr 52:54:00:49:84:12 --pid /run/libvirt/qemu/passt/8-rhel-net0-passt.pid --interface eno1 --tcp-ports 10.73.178.37/41335

3) with interface only:
# virsh dumpxml rhel --xpath //portForward
<portForward proto="tcp" dev="eno1">
  <range start="41335"/>
</portForward>

the passt cmdline:
# ps aux | grep 'usr/bin/passt' | grep -v grep 
qemu        5779  0.0  0.0  72932 36632 ?        Ss   02:56   0:00 /usr/bin/passt --one-off --socket /run/libvirt/qemu/passt/9-rhel-net0.socket --mac-addr 52:54:00:49:84:12 --pid /run/libvirt/qemu/passt/9-rhel-net0-passt.pid --interface eno1 --tcp-ports %eno1/41335

Comment 14 yalzhang@redhat.com 2023-08-23 08:00:10 UTC
Test with lastest passt downstream build, the result is as expected.
libvirt-9.5.0-5.el9.x86_64
passt-0^20230818.g0af928e-4.el9.x86_64
passt-selinux-0^20230818.g0af928e-4.el9.noarch

Comment 16 errata-xmlrpc 2023-11-07 08:31:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: libvirt security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6409