Bug 993631 - Libvirt should report failure when detach hostdev unsuccessfully.
Libvirt should report failure when detach hostdev unsuccessfully.
Status: ASSIGNED
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Jiri Denemark
Virtualization Bugs
:
: 1255287 1258312 1456039 (view as bug list)
Depends On:
Blocks: 1172230 1133443
  Show dependency treegraph
 
Reported: 2013-08-06 06:19 EDT by Hu Jianwei
Modified: 2017-05-29 09:33 EDT (History)
14 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1133443 (view as bug list)
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Hu Jianwei 2013-08-06 06:19:37 EDT
Description of problem:
Libvirt should report failure when detach hostdev unsuccessfully.
 
Version-Release number of selected component (if applicable):
libvirt-1.1.1-2.el7.x86_64
qemu-kvm-1.5.2-1.el7.x86_64
kernel-3.10.0-3.el7.x86_64

How reproducible:
100%

Steps:
1. Define a guest with the following hostdev device
<hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
    </hostdev>

2. Execute 2.1 and 2.2 at the same time.
2.1 Start the guest.
[root@SRIOV2 ~]# virsh start r7_g
Domain r7_g started
[root@SRIOV2 ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 7     r7_g                           running

2.2 In another terminal,execute below command immediately:
[root@SRIOV2 ~]# virsh detach-device r7_g hostdev.xml
Device detached successfully                           <======= this is issue.

3. Dumpxml domain xml.
[root@SRIOV2 ~]# virsh dumpxml r7_g | grep -A10 hostdev
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </hostdev>

[root@SRIOV2 ~]# virsh dumpxml r7_g --inactive| grep -A10 hostdev
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </hostdev>

4. In guest, to check the nic status, it's in the domain.
[root@test005 ~]# lspci| grep Eth
00:03.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
[root@test005 ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr B4:B5:2F:AF:A1:00  
          inet addr:10.66.71.177  Bcast:10.66.71.255  Mask:255.255.254.0
          inet6 addr: fe80::b6b5:2fff:feaf:a100/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1932 (1.8 KiB)  TX bytes:1588 (1.5 KiB)
          Interrupt:11 Memory:fc000000-fc020000

[root@test005 ~]# ping 10.66.7.130
PING 10.66.7.130 (10.66.7.130) 56(84) bytes of data.
64 bytes from 10.66.7.130: icmp_seq=1 ttl=62 time=0.324 ms
64 bytes from 10.66.7.130: icmp_seq=2 ttl=62 time=0.282 ms
64 bytes from 10.66.7.130: icmp_seq=3 ttl=62 time=0.402 ms

--- 10.66.7.130 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2391ms
rtt min/avg/max/mdev = 0.282/0.336/0.402/0.049 ms
[root@test005 ~]# 

Actual results:
As step 2.2 shown.

Expected results:
Libvirt should report an error if detach device fail.
Comment 4 Hu Jianwei 2014-08-25 03:29:23 EDT
This bug should be tracked in rhel6, cloned it.

Bug 1133443 - Libvirt should report failure when detach hostdev unsuccessfully.
Comment 7 Jiri Denemark 2015-08-20 12:55:53 EDT
*** Bug 1255287 has been marked as a duplicate of this bug. ***
Comment 10 Jiri Denemark 2015-08-31 10:06:01 EDT
Well, the only fix (if it appears to be reasonably doable) for this is going to be in virsh so that it doesn't print the misleading "device successfully detached" message when the API returns 0.

In other words, if any application using libvirt relies on virDomainDetachDevice to return zero only if the device was actually removed, the application itself needs to be fixed because it never worked like that (although it wasn't explicitly documented). Ideally, the application should listen for a device detach event which is triggered when device removal is finished (which may happen before virDomainDetachDevice returns but it may also be send later or never). It's also possible to dump domain XML and check if the device is still there.
Comment 12 Peter Krempa 2015-09-07 04:23:01 EDT
*** Bug 1258312 has been marked as a duplicate of this bug. ***
Comment 15 Michael Liu 2016-04-27 06:57:28 EDT
The problem seems to be not on the libvirt
Comment 16 Jiri Denemark 2017-05-29 09:33:39 EDT
*** Bug 1456039 has been marked as a duplicate of this bug. ***

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