This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
Bug 2128563 - [RFE] Support to hotplug/hotunplug for usb controllers/hub/ccid/sata/virtio-serial controller
Summary: [RFE] Support to hotplug/hotunplug for usb controllers/hub/ccid/sata/virtio-s...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.2
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: rc
: ---
Assignee: Virtualization Maintenance
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-21 04:27 UTC by Han Han
Modified: 2023-07-07 20:34 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-07-07 20:34:13 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
the VM XML and hcis.sh (1.63 KB, application/gzip)
2022-09-21 04:27 UTC, Han Han
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   RHEL-740 0 None None None 2023-07-07 20:34:13 UTC
Red Hat Issue Tracker RHELPLAN-134472 0 None None None 2022-09-21 04:39:23 UTC

Description Han Han 2022-09-21 04:27:53 UTC
Created attachment 1913243 [details]
the VM XML and hcis.sh

Description of problem:
Support hotplug/hotunplug to these USB controller/devices:
- nec-usb-xhci
- piix3-usb-uhci
- piix4-usb-uhci
- qemu-xhci
- usb-ehci
- usb-hub
- usb-ccid

Version-Release number of selected component (if applicable):
libvirt-8.7.0-1.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start an VM
2. Try to attach USB nec-xhci controller/ccid controller/hub:
➜  ~ cat hub.xml 
<hub type='usb'/>
➜  ~ virsh attach-device rhel-9.2 hub.xml
error: Failed to attach device from hub.xml
error: Operation not supported: live attach of device 'hub' is not supported

➜  ~ cat nec-xhci.xml 
<controller type='usb' index='1' model='nec-xhci'/>
➜  ~ virsh attach-device rhel-9.2 nec-xhci.xml
error: Failed to attach device from nec-xhci.xml
error: Operation not supported: 'usb' controller cannot be hot plugged.

➜  ~ cat ccid.xml 
<controller type='ccid' index='0'/>
➜  ~ virsh attach-device rhel-9.2 ccid.xml
error: Failed to attach device from ccid.xml
error: Operation not supported: 'ccid' controller cannot be hot plugged.

In fact, hot-plug for these devices is supported in qemu:
➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_add","arguments":{"driver":"usb-hub","bus":"usb.0","port":5,"id":"usb-hub"}}'
{"return":{},"id":"libvirt-574"}
➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_del","arguments":{"id":"usb-hub"}}'                                          
{"return":{},"id":"libvirt-575"}

➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_add","arguments":{"driver":"usb-ccid","bus":"usb.0","port":5,"id":"usb-ccid"}}'
{"return":{},"id":"libvirt-576"}
➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_del","arguments":{"id":"usb-ccid"}}'                                           
{"return":{},"id":"libvirt-577"}

Run hcis.sh to get all the USB controllers with hot-plug/hot-unplug support:
➜  ~ bash /tmp/hcis.sh 
...
Hotplug/Hotunplug nec-usb-xhci
{"return":{},"id":"libvirt-594"}

{"return":{},"id":"libvirt-595"}

Hotplug/Hotunplug piix3-usb-uhci
{"return":{},"id":"libvirt-596"}

{"return":{},"id":"libvirt-597"}

Hotplug/Hotunplug piix4-usb-uhci
{"return":{},"id":"libvirt-598"}

{"return":{},"id":"libvirt-599"}

Hotplug/Hotunplug qemu-xhci
{"return":{},"id":"libvirt-600"}

{"return":{},"id":"libvirt-601"}

Hotplug/Hotunplug usb-ehci
{"return":{},"id":"libvirt-602"}

{"return":{},"id":"libvirt-603"}
 

Actual results:
As above

Expected results:
Support hotplug/hotunplug for the devices mentioned in the subject

Additional info:
See the VM XML and hcis.sh in the attachment

Comment 1 Han Han 2022-09-21 07:12:19 UTC
QEMU version: qemu-kvm-7.1.0-1.el9.x86_64

Comment 2 Han Han 2022-09-22 07:11:10 UTC
Support hot-plug/hot-unplug for virtio-serial/SATA as well:
virtio-serial:
➜  ~ cat serial.xml                         
<controller type='virtio-serial' index='0'/>
➜  ~ virsh attach-device rhel-9.2 serial.xml
error: Failed to attach device from serial.xml
error: Operation not supported: 'virtio-serial' controller cannot be hot plugged.

➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_add","arguments":{"driver":"virtio-serial-pci","id":"serial","bus":"pci.9"}}'
{"return":{},"id":"libvirt-609"}

(VM)[root@localhost ~]# lspci -s 09:00.0
09:00.0 Communication controller: Red Hat, Inc. Virtio console (rev 01)

➜  ~ virsh qemu-monitor-command rhel-9.2 --hmp info pci|grep serial -B6
  Bus  9, device   0, function 0:
    Class 1920: PCI device 1af4:1043
      PCI subsystem 1af4:1100
      IRQ 0, pin A
      BAR1: 32 bit memory at 0xfd800000 [0xfd800fff].
      BAR4: 64 bit prefetchable memory at 0xfba00000 [0xfba03fff].
      id "serial"
➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_del","arguments":{"id":"serial"}}'                                           
{"return":{},"id":"libvirt-619"}
(VM)[root@localhost ~]# lspci -s 09:00.0

➜  ~ virsh qemu-monitor-command rhel-9.2 --hmp info pci|grep serial -B6


SATA:
➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_add","arguments":{"driver":"ahci","id":"sata","bus":"pci.9"}}'
{"return":{},"id":"libvirt-666"}
(guest)[root@localhost ~]# lspci -s 09:00.0
09:00.0 SATA controller: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] (rev 02)

➜  ~ virsh qemu-monitor-command rhel-9.2 '{"execute":"device_del","arguments":{"id":"sata"}}'  
{"return":{},"id":"libvirt-668"}
[root@localhost ~]# lspci -s 09:00.0


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