Bug 802856

Summary: Missing support for persistent hotplug attach/detach of <hostdev> devices
Product: Red Hat Enterprise Linux 6 Reporter: Laine Stump <laine>
Component: libvirtAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2CC: acathrow, ajia, dallan, dyuan, honzhang, mshao, mzhan, rwu, weizhan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.10-6.el6 Doc Type: Bug Fix
Doc Text:
In previous versions of RHEL, a <hostdev> device could be hotplugged to a guest, but making that device persistent across restarts of the guest required separately editing the guest configuration. The patch that closes this bug adds support for persistent hotplug of <hostdev> devices, both to the libvirt API and to the virsh commandline utility.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:50:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Laine Stump 2012-03-13 16:17:24 UTC
Fixed in this upstream commit:

commit edb6fc3a7f0de4a4881862287b412b66b8153768
Author: Laine Stump <laine>
Date:   Wed Mar 7 16:05:34 2012 -0500

    qemu: support persistent hotplug of <hostdev> devices
    
    For some reason, although live hotplug of <hostdev> devices is
    supported, persistent hotplug is not. This patch adds the proper
    VIR_DOMAIN_DEVICE_HOSTDEV cases to the switches in
    qemuDomainAttachDeviceConfig and qemuDomainDetachDeviceConfig.

Comment 1 Laine Stump 2012-03-16 14:23:16 UTC
A backported fix has been posted to rhvirt-patches for inclusion in the RHEL build of libvirt:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2012-March/msg01461.html

Comment 4 hongming 2012-03-20 05:37:41 UTC
Use libvirt-0.9.10-2.el6.x86_64 to reproduce the bug.

#virsh attach-device rhel6 hostdev.xml --persistent
error: Failed to attach device from hostdev.xml
error: unsupported configuration:persistent attach of device is not supported.


Verify steps

1.enable kernel iommu. edit grub.conf
add intel_iommu=on at the end of kernel line.

2.For platform just support vt-d1(host kernel) and host kernel
larger than 171 kernel, do the following steps.
modprobe -r kvm_intel
modprobe -r kvm
modprobe kvm allow_unsafe_assigned_interrupts=1
modprobe kvm_intel


3.# rpm -q libvirt
libvirt-0.9.10-6.el6.x86_64


4.Check device list, prepare hotplug network from host to guest.
computer |
+- pci_0000_00_19_0 
| |
| +- net_eth0_44_37_e6_67_11_a2


4.# virsh nodedev-dumpxml pci_0000_00_19_0

5. Prepare hostdev.xml that like as following
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x00' slot='0x19' function='0x0'/>
</source>
</hostdev>


5.# virsh attach-device rhel6 hostdev.xml --persistent
Device attached successfully

6. In guest, using lspci, and ping to check the host network device is working
fine.

7. # virsh destroy rhel6

8. # virsh start rhel6

9. The host network device still works fine in guest.

10. # virsh detach-device rhel6 hostdev.xml --persistent
Device detached successfully

The host network device automatically be re-attached to host. 

11. # virsh destroy rhel6

12. # virsh start rhel6

Results
The host network device don't exist in guest. 

So it is verified.

Comment 5 Laine Stump 2012-05-08 18:15:09 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
In previous versions of RHEL, a <hostdev> device could be hotplugged to a guest, but making that device persistent across restarts of the guest required separately editing the guest configuration. The patch that closes this bug adds support for persistent hotplug of <hostdev> devices, both to the libvirt API and to the virsh commandline utility.

Comment 7 errata-xmlrpc 2012-06-20 06:50:17 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.

http://rhn.redhat.com/errata/RHSA-2012-0748.html