Bug 1751461 - Setting "managed=no" in hostdev virtual network do not work
Summary: Setting "managed=no" in hostdev virtual network do not work
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Daniel Berrangé
QA Contact: jiyan
URL:
Whiteboard:
Depends On:
Blocks: 1585087
TreeView+ depends on / blocked
 
Reported: 2019-09-12 04:57 UTC by yalzhang@redhat.com
Modified: 2020-05-05 09:50 UTC (History)
5 users (show)

Fixed In Version: libvirt-5.9.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-05 09:49:41 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:2017 0 None None None 2020-05-05 09:50:27 UTC

Description yalzhang@redhat.com 2019-09-12 04:57:29 UTC
Description of problem:
Setting "managed=no" in hostdev virtual network do not work

Version-Release number of selected component (if applicable):
libvirt-5.6.0-4.module+el8.1.0+4160+b50057dc.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a hostdev interface pool with managed=no, and a vm connected to this network:
# virsh net-dumpxml passthrough1
<network>
  <name>passthrough1</name>
  <uuid>7a5ff548-75f6-45bd-8564-d944a00d1321</uuid>
  <forward mode='hostdev' **managed='no'**>
    <driver name='vfio'/>
    <address type='pci' domain='0x0000' bus='0x03' slot='0x10' function='0x3'/>
    <address type='pci' domain='0x0000' bus='0x03' slot='0x10' function='0x1'/>
  </forward>
</network>

# virsh nodedev-dumpxml pci_0000_03_10_3  | grep /driver -B2
  <driver>
    <name>igbvf</name>
  </driver>
# virsh dumpxml rhel | grep /interface -B5
    <interface type='network'>
      <mac address='52:54:00:0a:98:80'/>
      <source network='passthrough1'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </interface>
2. try to start the vm, the vm start successfully, which is not expected:
# virsh start rhel
Domain rhel started

# virsh dumpxml rhel |grep /interface -B9
    <interface type='hostdev' **managed='yes'**>
      <mac address='52:54:00:0a:98:80'/>
      <driver name='vfio'/>
      <source>
        <address type='pci' domain='0x0000' bus='0x03' slot='0x10' function='0x3'/>
      </source>
      <model type='virtio'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </interface>

# virsh nodedev-dumpxml pci_0000_03_10_3  | grep /driver -B2
  <driver>
    <name>vfio-pci</name>
  </driver>

3. Destroy the vm, the vf is reattached to the host, the behavior is the same as "managed=yes", which is not consistent with the setting "managed=no"
# virsh destroy rhel
Domain rhel destroyed

# virsh nodedev-dumpxml pci_0000_03_10_3  | grep /driver -B2
  <driver>
    <name>igbvf</name>
  </driver>

Actual results:
The "managed=no" setting in hostdev network work as "managed=yes", which is not expected

Expected results:
The guest should not start and report error as the vf is not managed by libvirt

Additional info:
on libvirt-5.0.0-12.module+el8.0.1+3755+6782b0ed.x86_64, the guest will fail to start with error as below:
# virsh start rhel
error: Failed to start domain rhel
error: Requested operation is not valid: Unmanaged PCI device 0000:03:10.3 must be manually detached from the host

Comment 1 Daniel Berrangé 2019-09-12 15:06:28 UTC
Patch proposed upstream

https://www.redhat.com/archives/libvir-list/2019-September/msg00496.html

Comment 2 Daniel Berrangé 2019-09-12 15:57:58 UTC
Merged upstream in

commit e0cb57c552b79016535199021dca5296c0ca89a3
Author: Daniel P. Berrangé <berrange>
Date:   Thu Sep 12 16:04:20 2019 +0100

    conf: correctly convert 'managed' attribute from network port
    
    The virNetworkPortDef config stores the 'managed' attribute
    as the virTristateBool type.
    
    The virDomainDef config stores the 'managed' attribute as
    the bool type.
    
    Reviewed-by: Michal Privoznik <mprivozn>
    Signed-off-by: Daniel P. Berrangé <berrange>

Comment 6 jiyan 2020-01-20 03:22:22 UTC
Reproduce this bug with libvirt-5.6.0-7.module+el8.2.0+4673+ff4b3b61.x86_64.
Verified this bug with libvirt-5.9.0-1.module+el8.2.0+4682+acceb91e.x86_64 and libvirt-6.0.0-1.module+el8.2.0+5453+31b2b136.x86_64.

Version:
libvirt-5.6.0-7.module+el8.2.0+4673+ff4b3b61.x86_64
qemu-kvm-4.1.0-14.module+el8.2.0+4673+ff4b3b61.x86_64
kernel-4.18.0-171.el8.x86_64

Steps:
1. Setup vfs on physical hosts
# virsh nodedev-dumpxml pci_0000_82_00_1
<device>
  <name>pci_0000_82_00_1</name>
  <path>/sys/devices/pci0000:80/0000:80:02.0/0000:82:00.1</path>
  <parent>pci_0000_80_02_0</parent>
  <driver>
    <name>ixgbe</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>130</bus>
    <slot>0</slot>
    <function>1</function>
    <product id='0x10fb'>82599ES 10-Gigabit SFI/SFP+ Network Connection</product>
    <vendor id='0x8086'>Intel Corporation</vendor>
    <capability type='virt_functions' maxCount='63'>
      <address domain='0x0000' bus='0x82' slot='0x10' function='0x1'/>
      <address domain='0x0000' bus='0x82' slot='0x10' function='0x3'/>
      <address domain='0x0000' bus='0x82' slot='0x10' function='0x5'/>
      <address domain='0x0000' bus='0x82' slot='0x10' function='0x7'/>
      <address domain='0x0000' bus='0x82' slot='0x11' function='0x1'/>
    </capability>
    <iommuGroup number='42'>
      <address domain='0x0000' bus='0x82' slot='0x00' function='0x1'/>
    </iommuGroup>
    <numa node='1'/>
    <pci-express>
      <link validity='cap' port='0' speed='5' width='8'/>
      <link validity='sta' speed='5' width='8'/>
    </pci-express>
  </capability>
</device>

2. Create virtual network with the vfs above and managed=no
# cat network.xml 
<network>
  <name>pt</name>
  <forward mode='hostdev' managed='no'>
    <driver name='vfio'/>
    <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x1'/>
    <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x3'/>
    <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x5'/>
  </forward>
</network>

# virsh net-define network.xml 
Network pt defined from network.xml

# virsh net-start pt
Network pt started

# virsh net-dumpxml pt 
<network>
  <name>pt</name>
  <uuid>22e3cc60-e126-438c-aca7-2993ec2174d8</uuid>
  <forward mode='hostdev' managed='no'>
    <driver name='vfio'/>
    <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x1'/>
    <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x3'/>
    <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x5'/>
  </forward>
</network>

3. Start VM with interface whose source network is the virtual network above
# virsh domstate test82 
shut off

# virsh dumpxml test82 --inactive | grep "<interface" -A9
    <interface type='network'>
      <mac address='52:54:00:0a:98:80'/>
      <source network='pt'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </interface>

# virsh start test82 
Domain test82 started

# virsh dumpxml test82 | grep "<interface" -A9
    <interface type='hostdev' managed='yes'>
      <mac address='52:54:00:0a:98:80'/>
      <driver name='vfio'/>
      <source>
        <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x1'/>
      </source>
      <model type='virtio'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </interface>

4. Update the libvrit
# yum update libvirt* -y

# systemctl restart libvirtd

# rpm -qa libvirt
libvirt-5.9.0-1.module+el8.2.0+4682+acceb91e.x86_64

5. Restart VM and check the interface dumpxml again
# virsh destroy test82 ;virsh start test82
Domain test82 destroyed

Domain test82 started

# virsh dumpxml test82 |grep "<interface" -A9
    <interface type='hostdev'>
      <mac address='52:54:00:0a:98:80'/>
      <driver name='vfio'/>
      <source>
        <address type='pci' domain='0x0000' bus='0x82' slot='0x10' function='0x1'/>
      </source>
      <model type='virtio'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </interface>

6. Update the libvirt to libvirt-6.0.0-1.module+el8.2.0+5453+31b2b136.x86_64, and then repeat the step-4 and step-5.
The result is same with step-5.

All the test results are as expected, move this bug to be verified.

Comment 8 errata-xmlrpc 2020-05-05 09:49: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, 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/RHBA-2020:2017


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