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 2018448

Summary: [Machines] Can not delete host device because the source info are not right
Product: Red Hat Enterprise Linux 9 Reporter: Xianghua Chen <xchen>
Component: cockpit-machinesAssignee: Katerina Koukiou <kkoukiou>
Status: CLOSED ERRATA QA Contact: Xianghua Chen <xchen>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: mpitt, skobyda, wshi, ymao, yunyang
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 9.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cockpit-machines-268-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:19:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Xianghua Chen 2021-10-29 11:11:11 UTC
Description of problem:
Can not delete host device because the source info are not right

Version-Release number of selected component (if applicable):
cockpit-machines-254-1.el9.noarch
cockpit-255-1.el9.x86_64
libvirt-dbus-1.4.1-5.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a running vm 

2. Enter the vm details page, Click "Add host device", there is lots of USB hub listed

3. Choose 2 different devices and click Add, and there is xml info related after that:

# virsh dumpxml cirros1 | grep -iC 5 hostdev

    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x1d6b'/>
        <product id='0x0001'/>
        <address bus='6' device='1'/>
      </source>
      <alias name='hostdev0'/>
      <address type='usb' bus='0' port='1'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x1d6b'/>
        <product id='0x0001'/>
        <address bus='7' device='1'/>
      </source>
      <alias name='hostdev1'/>
      <address type='usb' bus='0' port='2'/>
    </hostdev>

4. The 2 devices will be added successfully and shown on the page.

But the "Device" and "Bus" are not corresponding to the value listed in previous dialog and the xml:

E.g. : It all shows 008 as Bus, which should be 006 and 007

5. Click "Remove" and confirm on the remove dialog

It will fail with :

The usb host device could not be deleted
ERROR No matching objects found for --remove-device 008.001



Actual results:
Refer to step 4 & step 5


Expected results:
1. The Device and Bus shown on the page should be the same with xml and listed on the host in step 4
2. It should be deleted successfully in step 5

Additional info:

Comment 1 Simon Kobyda 2021-12-15 11:41:05 UTC
When host device is attached to a VM, it is automatically detached from host. So it seems that when a host device is detached and then reattached from the host, it changes its device number upon reattachement. Could you please provide system logs, ideally an output of command "$dmesg --time-format iso", after reproducing this error?

Comment 3 Simon Kobyda 2022-01-04 13:47:42 UTC
From the logs, I see that a usb 4-3 device us unplugged, and then replugged with different device number:
2021-12-16T05:15:22,650402-05:00 usb 4-3: USB disconnect, device number 99
2021-12-16T05:15:23,068373-05:00 usb 4-3: new high-speed USB device number 100 using xhci_hcd

Therefore the problem is that when virt-xml uses incorrect (old) device number when we call it to hotunplug the device. So I think a proper fix should be to use standard libvirt API for detaching host devices.

Comment 4 Martin Pitt 2022-01-21 08:10:35 UTC
Being fixed in https://github.com/cockpit-project/cockpit-machines/pull/472

Comment 6 Martin Pitt 2022-02-24 09:32:31 UTC
Moving to 9.1. Running out of time for 9.0 now, and we currently have very little dev capacity for c-machines.

Comment 9 Xianghua Chen 2022-05-19 09:33:36 UTC
Verified with package:
cockpit-269-1.el9.x86_64
cockpit-machines-268-1.el9.noarch
libvirt-daemon-8.2.0-1.el9.x86_64

Steps:
1. Prepare a running vm 

2. Enter the vm details page, Click "Add host device", there is lots of USB hub listed

3. Choose 2 different devices and click Add, and there is xml info related after that:
# virsh dumpxml cirros1 | grep -iC 5 hostdev

4. The 2 devices will be added successfully and shown on the page.
And the "Device" and "Bus" are  corresponding to the value listed in previous dialog and the xml

5. Click "Remove" and confirm on the remove dialog, it can be removed.

6. Add the devices again and remove again, no other errors involved.

So verified.

Comment 11 errata-xmlrpc 2022-11-15 10:19:39 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 (cockpit-machines bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8094