Bug 1313272 - RFC: qemu: support redirdev hotunplug
Summary: RFC: qemu: support redirdev hotunplug
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact: jiyan
URL:
Whiteboard: LibvirtFirstBug
Depends On:
Blocks: 1584571
TreeView+ depends on / blocked
 
Reported: 2016-03-01 09:53 UTC by Pei Zhang
Modified: 2018-05-31 08:46 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1584571 (view as bug list)
Environment:
Last Closed: 2018-05-30 13:16:33 UTC


Attachments (Terms of Use)

Description Pei Zhang 2016-03-01 09:53:20 UTC
Description of problem:
Since we already support attach redirdev, it's better to fix detach redirdev. 

Version-Release number of selected component (if applicable):
libvirt-1.3.2-1.fc24_v1.3.2_rc2_1_g33fb8ff.x86_64

How reproducible:
100%

Steps to Reproduce:
1.start a guest with redirdev

# virsh dumpxml vm1|grep redirdev -A 3
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir0'/>
    </redirdev>

2. prepare a redirdev xml like following

# cat usb-redir.xml 
<redirdev bus='usb' type='spicevmc'>
    </redirdev>

3.detach redirdev device

# virsh detach-device vm1 usb-redir.xml 
error: Failed to detach device from usb-redir.xml
error: Operation not supported: live detach of device 'redirdev' is not supported

# virsh detach-device vm1 usb-redir.xml --config
error: Failed to detach device from usb-redir.xml
error: Operation not supported: persistent detach of device 'redirdev' is not supported

Actual results:
As step3, fail to detach it.

Expected results:
It could be detached. 

Additional info:

using QMP to check :
before delete, using virt-viewer to open guest we could find that table "Redirect USB device" is useful. 
then we detach it via QMP
virsh # qemu-monitor-command vm1 --pretty '{"execute":"device_del","arguments":{"id":"redir0"}}'
{
    "return": {

    },
    "id": "libvirt-25"
}

Then using virt-viewer to open guest to check again, we will find that table "Redirect USB device" is gray and it cannot be used.So actually it could be detached.

Comment 1 Cole Robinson 2016-04-20 23:30:51 UTC
Fixing basically involves 2 places:

src/qemu/qemu_driver.c function qemuDomainDetachDeviceLive needs to handle REDIRDEV
a qemuDomainDetachRedirdevDevice function should be implemented in src/qemu/qemu_hotplug.c

The pattern to follow here is RNG devices and the qemuDomainDetachRNGDevice ... the actual qemu interaction logic will basically be identical, we just need to match that pattern and swap out the redirdev bits

Comment 2 Ján Tomko 2018-05-30 13:16:33 UTC
Fixed by:
commit 91a3234f3a218a581ede975164e66ce7b0347f4c
Author:     Chen Hanxiao <chenhanxiao@gmail.com>
AuthorDate: 2018-01-05 10:47:47 +0800
Commit:     John Ferlan <jferlan@redhat.com>
CommitDate: 2018-01-08 11:49:26 -0500

    qemu: Add support for hot unplugging redirdev device
    
    Commit id '162efa1a' added support hotplug a redirdev, but
    did not add the hot unplug. This patch will add that support
    to allow usage of the detach-device --live on the device.
    
    Reviewed-by: John Ferlan <jferlan@redhat.com>
    Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>

git describe: v3.10.0-138-g91a3234f3a contains: v4.0.0-rc1~50


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