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 2073905

Summary: Hotplug hostdev interface will fail after restart virtqemud
Product: Red Hat Enterprise Linux 9 Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: Virtualization Maintenance <virt-maint>
libvirt sub component: General QA Contact: yalzhang <yalzhang>
Status: CLOSED DUPLICATE Docs Contact:
Severity: unspecified    
Priority: unspecified CC: fjin, jferlan, jsuchane, lmen, lvivier, mprivozn, nilal, virt-maint, xuzhang, yanqzhan, yicui, ymankad
Version: 9.1Keywords: Automation
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: 2022-04-20 08:07:21 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 yalzhang@redhat.com 2022-04-11 05:49:32 UTC
Description of problem:
Hotplug hostdev interface will fail after restart virtqemud

Version-Release number of selected component (if applicable):
libvirt-8.2.0-1.el9.x86_64
qemu-kvm-6.2.0-12.el9.x86_64
kernel-5.14.0-75.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start vm;
# virsh start avocado-vt-vm1
Domain 'avocado-vt-vm1' started

2. Restart virtqemud;
# systemctl restart virtqemud

3. Hotplug hostdev interface, it will fail.
# virsh attach-interface avocado-vt-vm1 hostdev --managed 0000:3b:10.2
error: Failed to attach interface
error: internal error: unable to execute QEMU command 'device_add': vfio 0000:3b:10.2: failed to open /dev/vfio/145: Operation not permitted
# ll /dev/vfio
total 0
crw-rw-rw-. 1 root root 10, 196 Apr  8 01:54 vfio

libvirtd.log shows:
2022-04-11 05:43:31.175+0000: 593364: info : qemuMonitorJSONIOProcessLine:218 : QEMU_MONITOR_RECV_REPLY: mon=0x7fd6f4084460 reply={"id": "libvirt-15", "error": {"class": "GenericError", "desc": "vfio 0000:3b:10.2: failed to open /dev/vfio/145: Operation not permitted"}}
2022-04-11 05:43:31.175+0000: 593321: error : qemuMonitorJSONCheckErrorFull:376 : internal error: unable to execute QEMU command 'device_add': vfio 0000:3b:10.2: failed to open /dev/vfio/145: Operation not permitted

Actual results:
step 3, hotplug will not succeed

Expected results:
Hotplug succeed

Additional info:
If do not restart virtqemud, the hotplug will succeed

Comment 1 yalzhang@redhat.com 2022-04-12 03:12:14 UTC
Get the audit log when hotplug failed:
type=VIRT_RESOURCE msg=audit(1649733009.467:8235): pid=97563 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=dev reason=attach vm="avocado-vt-vm1" uuid=7f43c13c-aa25-4c14-a060-b8c20b777f31 bus=pci device="0000:3b:0a.1" exe="/usr/sbin/virtqemud" hostname=? addr=? terminal=? res=failed'UID="root" AUID="unset"

Comment 5 John Ferlan 2022-04-13 10:46:37 UTC
Nothing private about changing pools...  VFIO in libvirt is related to mediated devices, so the pool looks right to me now as sst_virtualization_rhel_9

Comment 6 Jaroslav Suchanek 2022-04-14 15:09:56 UTC
Please attach debug logs. Thanks

Comment 10 Michal Privoznik 2022-04-20 08:07:21 UTC
I believe this is just a different incarnation of bug 2075765 because "Operation not permitted" means libvirt did not allow the device in devices controller. After I've fixed aforementioned bug I can no longer reproduce this one either.

*** This bug has been marked as a duplicate of bug 2075765 ***