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 1335798 - target dev name will be ignored for network interface when interface type=direct
Summary: target dev name will be ignored for network interface when interface type=direct
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Laine Stump
QA Contact: yalzhang@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-13 08:57 UTC by yisun
Modified: 2017-08-01 23:51 UTC (History)
4 users (show)

Fixed In Version: libvirt-3.2.0-4.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 17:09:12 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description yisun 2016-05-13 08:57:38 UTC
description:
target dev name will be ignored for network interface when interface type=direct

versions:
libvirt-1.3.4-1.el7.x86_64
qemu-kvm-rhev-2.6.0-1.el7.x86_64
libvirt-docs-1.3.4-1.el7.x86_64

please note, this may be a doc issue.


reproduction:
100%


steps:
1. #virsh edit virtlab_test
...
    <interface type='direct'>
      <mac address='54:52:00:54:9e:f4'/>
      <source dev='eno1' mode='bridge'/>
      <model type='virtio'/>
      <target dev='test_macvtap0'/> <==== set target name to "test_macvtap0"
    </interface>
...

2. # virsh start virtlab_test
Domain virtlab_test started

3. # virsh dumpxml virtlab_test | grep interface -A6
    <interface type='direct'>
      <mac address='54:52:00:54:9e:f4'/>
      <source dev='eno1' mode='bridge'/>
      <target dev='macvtap0'/>    <=== target dev name automatically set to macvtap0
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

4. # vim /usr/share/doc/libvirt-docs-1.3.4/formatdomain.html
...
          <a name="elementsNICSTargetOverride" shape="rect" id="elementsNICSTargetOverride">Overriding the target element</a>
...
 	If no target is specified, certain hypervisors will
      automatically generate a name for the created tun device. This
      name can be manually specified, however the name <i>should not
      start with either 'vnet' or 'vif'</i>, which are prefixes
      reserved by libvirt and certain hypervisors. Manually specified
      targets using these prefixes may be ignored.

Actual result:
target name cannot be manually set, it's ignored by libvirt and automatically set to "macvtap#", and this is not mentioned in libvirt-doc's formatdomain.html

Expected result:
Target name can be manually set, or explicitly mention the logic in libvirt doc.

Comment 2 Laine Stump 2017-03-27 02:06:30 UTC
Posted a patch to resolve this upstream:

 https://www.redhat.com/archives/libvir-list/2017-March/msg01260.html

Comment 3 Laine Stump 2017-04-25 18:58:54 UTC
Posted V2 patches upstream:

https://www.redhat.com/archives/libvir-list/2017-April/msg01193.html

Comment 4 Laine Stump 2017-05-02 15:20:23 UTC
Pushed upstream, will be in libvirt-3.3.0:

commit a05400ef55c7c67c6b211dfa5a33400870d470ca
Author: Laine Stump <laine>
Date:   Tue Apr 25 14:09:45 2017 -0400

    util: make macvtap/macvlan generated name #defines available to other files
    
commit 9cb891141c4a5a96243c61518c4e0dbcf6a86c24
Author: Laine Stump <laine>
Date:   Sun Mar 26 21:57:54 2017 -0400

    conf: don't ignore <target dev='blah'/> for macvtap interfaces
    
commit 30e672301dd16e0433e23864e21dcc9d0c311e8c
Author: Laine Stump <laine>
Date:   Tue Apr 25 14:43:24 2017 -0400

    util: rename/move VIR_NET_GENERATED_PREFIX to be consistent

Comment 7 yalzhang@redhat.com 2017-05-07 05:20:59 UTC
test on libvirt-3.2.0-4.el7.x86_64, 

1. when set target dev as "macvtapx" or "vnetx" the target name will be ignored, and default to macvtapn, n is ordered by number
2. set target dev as any string without the prefix "macvtap" or "vnet", the target name will be used
3. set the target dev to null, it will report error
4. set the target dev to the one already exists, will report error

the result is as expected, set this bug to be verified.

1. attach-interface

# virsh attach-interface rhel7 direct enp0s25 --target test 
Interface attached successfully

# virsh dumpxml rhel7 | grep /interface -B9
...
   <interface type='direct'>
      <mac address='52:54:00:73:67:d9'/>
      <source dev='enp0s25' mode='vepa'/>
      <target dev='test'/>
      <model type='rtl8139'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

# ip l show | grep test
8: test@enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 500

2. attach-device
# cat macvtap.xml 
 <interface type='direct' trustGuestRxFilters='no'>
 <source dev='enp0s25' mode='bridge'/>
 <target dev='tap1'/>
  </interface>

# virsh attach-device rhel7 macvtap.xml
Device attached successfully

# virsh dumpxml rhel7 | grep /interface -B9
   <interface type='direct' trustGuestRxFilters='no'>
      <mac address='52:54:00:28:3d:29'/>
      <source dev='enp0s25' mode='bridge'/>
      <target dev='tap1'/>
      <model type='rtl8139'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>

3. edit
 # virsh edit rhel7
   <interface type='direct'>
      <mac address='52:54:00:70:aa:44'/>
      <source dev='enp0s25' mode='vepa'/>
      <model type='rtl8139'/>
      <target dev='1234'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
# virsh start rhel7
Domain rhel7 started
# ip l show | grep 1234
17: 1234@enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 500

4. set to macvtap100 or vnet100, it will be ignored
# virsh edit rhel7
    <interface type='direct'>
      <mac address='52:54:00:70:aa:44'/>
      <source dev='enp0s25' mode='vepa'/>
    <target dev='macvtap100'/>
     <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
# virsh dumpxml rhel7 | grep macvtap100
# 

5. set to 'macvlan100' or 'vif100', it will not be ignored
# virsh dumpxml rhel7 | grep /interface -B7
    <interface type='direct'>
      <mac address='52:54:00:70:aa:44'/>
      <source dev='enp0s25' mode='vepa'/>
      <target dev='macvlan100'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

# ip l show | grep macvlan100
19: macvlan100@enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 500

6. set <target dev=''/>, it will report error
# virsh edit rhel7
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

7. 
# ip l show | grep sdfd
23: sdfdfffffffff@enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 500
# virsh attach-interface rhel7 direct enp0s25 --target sdfdfffffffff 
error: Failed to attach interface
error: Unable to create macvtap device sdfdfffffffff: File exists


file:///usr/share/doc/libvirt-docs-3.2.0/html/formatdomain.html#elementsNICSTargetOverride

If no target is specified, certain hypervisors will automatically generate a name for the created tun device. This name can be manually specified, however the name should not start with either 'vnet', 'vif', 'macvtap', or 'macvlan', which are prefixes reserved by libvirt and certain hypervisors. Manually specified targets using these prefixes may be ignored.

Comment 8 errata-xmlrpc 2017-08-01 17:09:12 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, 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/RHEA-2017:1846

Comment 9 errata-xmlrpc 2017-08-01 23:51:16 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, 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/RHEA-2017:1846


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