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 1265587 - unbind PF will cause VF0 disappear in host, but it still exist in guest.
Summary: unbind PF will cause VF0 disappear in host, but it still exist in guest.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.2
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Alex Williamson
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-23 09:54 UTC by Yanan Fu
Modified: 2016-03-28 09:34 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-09-25 02:19:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Yanan Fu 2015-09-23 09:54:11 UTC
Description of problem:
bring up VFs,unbind VF and assign to guest with "x-req=off" :

"-device vfio-pci,host=47:06.0,id=vf-06-0,x-req=off "
boot the guest, and unbound PF: 
"echo 0000:47:00.1 > /sys/bus/pci/devices/0000\:47\:00.1/driver/unbind"
the echo operation will be blocked until user unplug the VFs, this is normal.
then in the guest and qemu monitor, can show all the vfs, but in the host,vf0 will disappear, other vfs are normal.

Version-Release number of selected component (if applicable):
host:kernel:3.10.0-316.el7.x86_64
     qemu-kvm:qemu-kvm-rhev-2.3.0-24.el7.x86_64
guest:kernel:kernel:3.10.0-316.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.bring up vfs
2.unbind VFs and assign to guest:
-device vfio-pci,host=47:06.0,id=vf-06-0,x-req=off 
-device vfio-pci,host=47:06.1,id=vf-06-1,x-req=off
3.boot the guest, then unbound the PF in host
"echo 0000:47:00.1 > /sys/bus/pci/devices/0000\:47\:00.1/driver/unbind"
4.echo operation will be blocked as "x-req=off"
5.in the guest, "lspci" and "ifconfig" , and in qemu "info pci" can see all the VFs, but in the host "ls /sys/bus/pci/drivers/vfio-pci/" have no VF0(ex:47:06.0)

if bring only one vf, the result is same. 

Actual results:
VF0 will disappear in the host.

Expected results:
VF0 exist in the host.

Additional info:
CLI:
/usr/libexec/qemu-kvm -name rhel7 -machine pc,accel=kvm,usb=off -realtime mlock=off -cpu Opteron_G5,enforce -sandbox off -m 4G -smp 8,cores=8,threads=1,sockets=1 -object memory-backend-file,prealloc=yes,size=1024M,id=ram-node0,host-nodes=0,policy=bind,mem-path=/mnt/hugetlbfs -numa node,nodeid=0,cpus=0,cpus=1,memdev=ram-node0 -object memory-backend-file,prealloc=yes,size=1024M,id=ram-node1,host-nodes=1,policy=bind,mem-path=/mnt/hugetlbfs -numa node,nodeid=1,cpus=2,cpus=3,memdev=ram-node1 -object memory-backend-file,prealloc=yes,size=1024M,id=ram-node2,host-nodes=2,policy=bind,mem-path=/mnt/hugetlbfs -numa node,nodeid=2,cpus=4,cpus=5,memdev=ram-node2 -object memory-backend-file,prealloc=yes,size=1024M,id=ram-node3,host-nodes=3,policy=bind,mem-path=/mnt/hugetlbfs -numa node,nodeid=3,cpus=6,cpus=7,memdev=ram-node3 -boot order=c,menu=on,splash-time=3000,strict=on -device ich9-usb-ehci1,id=usb0,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb0.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb0.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb0.0,firstport=4,bus=pci.0,addr=0x5.0x2 -device virtio-scsi-pci,id=scsi0,cmd_per_lun=234,bus=pci.0,addr=0x8 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/root/rhel-7.2.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,discard=unmap,werror=stop,rerror=stop,aio=threads -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x9,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -device usb-tablet,id=usb-tablet1 -monitor stdio -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttym,server,nowait -spice port=5901,addr=0.0.0.0,seamless-migration=on,disable-ticketing -k en-us -device qxl-vga,id=video0,ram_size=134217728,vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x2 -device pci-bridge,bus=pci.0,id=bridge1,chassis_nr=1,addr=0xc -netdev tap,id=hostnet0,vhost=on,id=hostnet0,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=b6:af:42:b8:46:18,bus=bridge1,addr=0x14 -rtc base=utc,clock=host,driftfix=slew -device vfio-pci,host=47:06.0,id=vf-06-0

Comment 2 Yanan Fu 2015-09-23 10:11:44 UTC
If don't unbound PF, just only unbound vf0 from vfio-pci driver:

"echo 0000:47:06.0 > /sys/bus/pci/drivers/vfio-pci/unbind"

the result is same with unbound PF:vf0 disappear in host, but exist in guest.

Comment 3 Yanan Fu 2015-09-23 10:31:35 UTC
in my latest, if don't unbind PF, just unbound VFs, not only vf0 has this issue. every vfs all have this issue.
for example:
qemu:
-device vfio-pci,host=47:06.0,id=vf-06-0,x-req=off 
-device vfio-pci,host=47:06.1,id=vf-06-1,x-req=off

in host:
#echo 0000:47:06.1 > /sys/bus/pci/drivers/vfio-pci/unbind
echo operation will be blocked as "x-req=off", in the guest, "lspci" and "ifconfig" , and in qemu "info pci" can see the VF 0000:47:06.1, but in the host "ls /sys/bus/pci/drivers/vfio-pci/" can't not see it.

Comment 4 Alex Williamson 2015-09-23 13:56:38 UTC
(In reply to Yanan Fu from comment #0) 
> Actual results:
> VF0 will disappear in the host.
> 
> Expected results:
> VF0 exist in the host.

So clearly the kernel behavior does not match your expectations, but why is your expectation correct and why is the kernel behavior incorrect?  What functional difference does it make?

When a PF is unbound, SR-IOV is typically disabled and each VF is removed in sequence, serially.  Therefore it makes sense to me that VF0 disappears from the bound devices as it's removed via the PF.  The unbind is blocked though since the user hasn't released the device.  Teardown of VF1 and therefore the unbind won't start until VF0 is released and unbound.  The driver linking shows exactly this.

In the latter case, multiple VFs are being removed concurrently and the driver link in sysfs represents that.

Does the current kernel behavior actually prevent you from doing something?  Simply being different from your expectations is not a bug.

Comment 5 Yanan Fu 2015-09-25 02:09:14 UTC
(In reply to Alex Williamson from comment #4)
> (In reply to Yanan Fu from comment #0) 
> > Actual results:
> > VF0 will disappear in the host.
> > 
> > Expected results:
> > VF0 exist in the host.
> 
> So clearly the kernel behavior does not match your expectations, but why is
> your expectation correct and why is the kernel behavior incorrect?  What
> functional difference does it make?
> 
> When a PF is unbound, SR-IOV is typically disabled and each VF is removed in
> sequence, serially.  Therefore it makes sense to me that VF0 disappears from
> the bound devices as it's removed via the PF.  The unbind is blocked though
> since the user hasn't released the device.  Teardown of VF1 and therefore
> the unbind won't start until VF0 is released and unbound.  The driver
> linking shows exactly this.
> 
> In the latter case, multiple VFs are being removed concurrently and the
> driver link in sysfs represents that.
> 
> Does the current kernel behavior actually prevent you from doing something? 
> Simply being different from your expectations is not a bug.

This behavior does not prevent my test by now.and I can understand what you say: "VF is removed in sequence, serially", but i think VF should not disappear in host until it is removed in the guest manually(device_del). 
In my test, the first VF which is in using by guest will disappear in host before it is removed in guest.

Comment 6 Alex Williamson 2015-09-25 02:19:47 UTC
Sorry, I don't think there's a bug here.  In the case of the PF, you've initiated the unbind of the PF, which attempts to unbind the VF.  The device links in the driver reflect that.  In the case of the VFs, you're initiating the unbind of each VF, and the device link in the driver reflect that.


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