Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2128563

Summary: [RFE] Support to hotplug/hotunplug for usb controllers/hub/ccid/sata/virtio-serial controller
Product: Red Hat Enterprise Linux 9 Reporter: Han Han <hhan>
Component: libvirtAssignee: Virtualization Maintenance <virt-maint>
libvirt sub component: General QA Contact: Han Han <hhan>
Status: CLOSED MIGRATED Docs Contact:
Severity: unspecified    
Priority: low CC: lmen, meili, virt-maint, xuzhang, yalzhang, yduan, zhetang
Version: 9.2Keywords: FutureFeature, MigratedToJIRA, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-07 20:34:13 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
the VM XML and hcis.sh none

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