This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2160348 - Attach direct type interface with VF and vlan setting failed for the second time
Summary: Attach direct type interface with VF and vlan setting failed for the second time
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Virtualization Maintenance
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-01-12 06:08 UTC by Meina Li
Modified: 2023-09-22 15:56 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-22 15:56:44 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)
libvirtd.log (3.26 MB, text/plain)
2023-01-28 02:58 UTC, Meina Li
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   RHEL-7305 0 None Migrated None 2023-09-22 15:51:59 UTC
Red Hat Issue Tracker RHELPLAN-144901 0 None None None 2023-01-12 06:09:29 UTC

Description Meina Li 2023-01-12 06:08:32 UTC
Description of problem:
Attach direct type interface with VF and vlan setting failed for the second time

Version-Release number of selected component (if applicable):
libvirt-8.10.0-2.el9.x86_64
qemu-kvm-7.2.0-2.el9.x86_64
kernel-5.14.0-226.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Initialize the vfs, then check the mac address.
# echo 0 >/sys/class/net/ens1f0/device/sriov_numvfs
# echo 1 >/sys/class/net/ens1f0/device/sriov_numvfs

2. Prepare the interface xml.
# cat interface.xml 
<interface type='direct'>
<mac address='7a:3d:d6:18:19:76'/>
<vlan>
        <tag id='50'/>
      </vlan>
<source dev='enp59s2f16v0' mode='passthrough'/>
      <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
</interface>

3. Attach the interface to the guest.
# virsh attach-device lmn interface.xml 
Device attached successfully
# virsh dumpxml lmn | xmllint --xpath //interface -
<interface type="direct">
      <mac address="7a:3d:d6:18:19:76"/>
      <source dev="enp59s2f16v0" mode="passthrough"/>
      <vlan>
        <tag id="50"/>
      </vlan>
      <target dev="macvtap12"/>
      <model type="rtl8139"/>
      <alias name="net0"/>
      <address type="pci" domain="0x0000" bus="0x09" slot="0x00" function="0x0"/>
    </interface>

4. Detach the interface.
# virsh detach-device lmn interface.xml 
Device detached successfully
# virsh dumpxml lmn | xmllint --xpath //interface -
XPath set is empty

5. Attach the interface again.
# virsh attach-device lmn interface.xml 
error: Failed to attach device from interface.xml
error: Cannot set interface flags on 'enp59s2f16v0': No such device

# ip l show enp59s2f16v0
36: enp59s2f16v0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether e6:9b:12:18:87:ee brd ff:ff:ff:ff:ff:ff

Actual results:
Attach failed as above step 5.

Expected results:
Attach successfully.

Additional info:
1) Can attach the interface without vlan setting successfully in step 5.
2) libvirtd.log: 
2023-01-12 03:59:27.023+0000: 7347: error : virNetDevSetIFFlag:621 : Cannot set interface flags on 'enp59s2f16v0': No such device

Comment 1 Laurent Vivier 2023-01-18 18:31:57 UTC
Jarda, it seems related to libvirt.

Comment 2 Jaroslav Suchanek 2023-01-19 13:55:06 UTC
We might need the full libvirt debug logs for this. Seems like the device hasn't been re-created on the host of the detach. Some udev feature?

Laine, please have a look. Thanks.

Comment 3 Meina Li 2023-01-28 02:58:20 UTC
Created attachment 1940836 [details]
libvirtd.log

Comment 4 Michal Privoznik 2023-03-14 11:35:18 UTC
This must be something out of libvirt's control. Here's a snippet from the logs:

2023-01-28 02:55:00.486+0000: 705217: debug : virDomainAttachDevice:8720 : dom=0x7f02d40028b0, (VM: name=lmn, uuid=ed0e603e-68fc-4bc6-9ac9-39e69759709e), xml=<interface type='direct'>
<mac address='7a:3d:d6:18:19:76'/>
<vlan>
        <tag id='50'/>
      </vlan>
<source dev='enp59s2f16v0' mode='passthrough'/>
      <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
</interface>


2023-01-28 02:55:01.849+0000: 705217: debug : virNetDevSetMACInternal:282 : SIOCSIFHWADDR enp59s2f16v0 MAC=7a:3d:d6:18:19:76 - Success
2023-01-28 02:55:01.951+0000: 705217: debug : virNetDevSetVfVlan:1622 : RTM_SETLINK ens1f0 vf 0 vlanid=50 - Success
2023-01-28 02:55:01.958+0000: 705217: debug : virNetlinkNewLink:593 : Creating macvtap interface 'macvtap1'
2023-01-28 02:55:01.959+0000: 705217: info : virNetDevMacVLanCreate:122 : created device: 'macvtap1'
2023-01-28 02:55:01.959+0000: 705217: debug : virNetDevVPortProfileAssociate:1238 : profile:'(nil)' vmOp: create device: macvtap1@enp59s2f16v0 mac: 7a:3d:d6:18:19:76 uuid: ed0e603e-68fc-4bc6-9ac9-39e69759709e
2023-01-28 02:55:01.959+0000: 705217: info : virObjectUnref:378 : OBJECT_UNREF: obj=0x7f029802a0e0
2023-01-28 02:55:01.960+0000: 705217: info : virSecuritySELinuxFSetFilecon:1390 : Setting SELinux context on fd 24 to 'system_u:object_r:tun_tap_device_t:s0:c460,c791'
2023-01-28 02:55:01.960+0000: 705217: error : virNetDevSetIFFlag:616 : Cannot set interface flags on 'enp59s2f16v0': No such device
2023-01-28 02:55:01.972+0000: 705217: debug : virNetDevVPortProfileDisassociate:1304 : profile:'(nil)' vmOp: destroy device: macvtap1@enp59s2f16v0 mac: 7a:3d:d6:18:19:76
2023-01-28 02:55:01.972+0000: 705217: info : virNetDevMacVLanDelete:137 : delete device: 'macvtap1'

2023-01-28 02:55:02.039+0000: 705217: debug : virPCIGetVirtualFunctionsFull:2400 : Found 1 virtual functions for /sys/class/net/ens1f0/device
2023-01-28 02:55:02.040+0000: 705217: debug : virJSONValueFromString:1683 : string={
  "adminMac": "52:53:1e:59:e1:30",
  "vlanTag": 0,
  "mac": "52:53:1e:59:e1:30"
}


2023-01-28 02:55:02.040+0000: 705217: debug : virPCIGetVirtualFunctionsFull:2400 : Found 1 virtual functions for /sys/class/net/ens1f0/device
2023-01-28 02:55:02.049+0000: 705217: debug : virNetDevSetMACInternal:282 : SIOCSIFHWADDR enp59s2f16v0 MAC=52:53:1e:59:e1:30 - Success

(I've limited the output only to the thread that's executing the API)

So, firstly, at 02:55:01.849+0000 the MAC address is set on the device successfully. But when the device is brought online (virNetDevSetIFFlag()) the device suddenly disappears 02:55:01.960+0000 (i.e. 111ms later), only to reappear back again when its original MAC address is restored at 02:55:02.049+0000 (i.e. 89ms after the failure). I wonder whether us, creating a macvtap resulted in some udev actions, that maybe temporarily renamed the device.

Also, this is how virNetDevSetIFFlag() is implemented:

virNetDevSetIFFlag(const char *ifname, int flag, bool val)
{
    ...
    if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
        return -1;

    if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
        virReportSystemError(errno,
                             _("Cannot get interface flags on '%s'"),
                             ifname);
        return -1;
    }

    ...
    if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
            virReportSystemError(errno,
                                 _("Cannot set interface flags on '%s'"),
                                 ifname);
            return -1;
        }
    }

    return 0;
}

And the error message we see comes from the SIOCSIFFLAGS, not SIOCGIFFLAGS. So the device was definitely accessible when getting the flags. Therefore I think we're just racing with something (I suspect udev). But placing 'udevadm settle' anywhere just doesn't feel right.

Comment 5 RHEL Program Management 2023-09-22 15:51:38 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 6 RHEL Program Management 2023-09-22 15:56:44 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.