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 1979761 - Can not define mdev device successfully when using xml dumped from mdev device defined by mdevctl
Summary: Can not define mdev device successfully when using xml dumped from mdev devic...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jonathon Jongsma
QA Contact: zhentang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-07-07 01:13 UTC by yafu
Modified: 2022-05-17 13:02 UTC (History)
6 users (show)

Fixed In Version: libvirt-7.7.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 12:45:04 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2022:2390 0 None None None 2022-05-17 12:45:18 UTC

Description yafu 2021-07-07 01:13:18 UTC
Description of problem:
Can not define mdev device successfully when using xml dumped from mdev device defined by mdevctl

Version-Release number of selected component (if applicable):
libvirt-daemon-7.5.0-1.module+el8.5.0+11664+59f87560.x86_64
qemu-kvm-6.0.0-21.module+el8.5.0+11555+e0ab0d09.x86_64
mdevctl-0.78-1.el8.noarch


How reproducible:
100%

Steps to Reproduce:
1.Define mdev device with mdevctl:
# mdevctl define --uuid=83a54ae7-09b1-4046-b0e2-b31de31505a0 --parent=0000:5b:00.0 --type=nvidia-262 -a

2.List the mdev device:
#virsh nodedev-list --cap mdev --inactive
mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0

3.Dump the mdev device xml:
#virsh nodedev-dumpxml mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0 > mdev-2.xml

4.Check the xml:
#cat mdev-2.xml
<device>
  <name>mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0</name>
  <parent>0000:5b:00.0</parent>
  <capability type='mdev'>
    <type id='nvidia-262'/>
    <uuid>83a54ae7-09b1-4046-b0e2-b31de31505a0</uuid>
    <iommuGroup number='0'/>
  </capability>
</device>

5.Undefine the mdev device:
#virsh undefine mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0

6.Create the mdev device with xml:
# virsh nodedev-define mdev-2.xml 
error: Failed to define node device from 'mdev-2.xml'
error: internal error: invalid use of command API

Actual results:
Can not define mdev device successfully when using xml dumped from mdev device defined by mdevctl.

Expected results:
Should define mdev device successfully when using xml dumped from mdev device defined by mdevctl.

Additional info:
1.Can define mdev device successfully if modifying the parent address from '0000:5b:00.0' to 'pci_0000_5b_00_0'.

Comment 1 Jonathon Jongsma 2021-07-08 18:16:47 UTC
Good catch. Unfortunately this is a bit tricky to fix for all scenarios because of the fact that mdevctl supports defining mdevs for parent devices that do not actually exist (yet) on the host system. 

For active mdevs and for inactive mdevs whose parent devices are present, it's pretty straightforward to convert from '0000:5b:00.0' to 'pci_0000_5b_00_0'. But for those devices whose parents are not present on the host, there's no valid parent id that we can use in that field. I proposed a fix upstream that used the correct parent ID where possible but assigned "parentless" devices to the root "computer" device in libvirt. So for those devices with valid parents, dumping xml and defining should work. But for those without parents, dumping to xml and defining from that xml would still fail because the "computer" device is not a valid parent.

Comment 2 John Ferlan 2021-09-08 13:30:43 UTC
Bulk update: Move RHEL-AV bugs to RHEL9. If necessary to resolve in RHEL8, then clone to the current RHEL8 release.

Comment 3 Jonathon Jongsma 2021-09-14 18:53:39 UTC
The following commits should fully fix this issue. 

Included in release 7.6.0
51fbbfdce8141d5a25edcf66ba3a95ac23b29f94 nodedev: fix parent device of inactive mdevs

Included in release 7.7.0
fdfe4b2837c3408edc57f6d3bf393dc16cd0ac64 nodedev: add internal virNodeDeviceObjListFind()
a9c1febcf43544fb9b9e59e8b45161d11260d9aa nodedev: fix xml output for mdev parents in test suite
e44408dd9c45cb4f5e41caef4a9d2b7d2b8eb528 nodedev: cache parent address in mdev caps
d5ae634ba284fcb1aa40634ad3c0a9e820ec916a nodedev: Add parser validation for node devices
08d29eb3b1d2361b7c70eaf0e269165387cf2756 nodedev: add PostParse callback for nodedev parsing
3bd8181bc5548a0ce81107cbfb480dfdcba5679d nodedev: Handle inactive mdevs with the same UUID
fcae7a44c3b3559d1d8e05543deee41db7a8fdb1 nodedev: look up mdevs by UUID and parent

Since libvirt was recently rebased to 7.7.0, this issue should now be fixed as well.

Comment 7 zhentang 2021-10-15 03:13:41 UTC
Verified on env:
libvirt-7.8.0-1.el9
qemu-kvm-6.1.0-5.el9

Comment 10 zhentang 2021-11-03 07:13:40 UTC
verified on Env:
libvirt-7.8.0-1.el9

Mdev device defined success.

# virsh nodedev-dumpxml mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0_0000_00_02_0 
<device>
  <name>mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0_0000_00_02_0</name>
  <parent>pci_0000_00_02_0</parent>
  <capability type='mdev'>
    <type id='nvidia-262'/>
    <uuid>83a54ae7-09b1-4046-b0e2-b31de31505a0</uuid>
    <iommuGroup number='0'/>
  </capability>
</device>


# virsh nodedev-dumpxml mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0_0000_00_02_0 >mdevtest.xml
# virsh nodedev-undefine mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0_0000_00_02_0 
Undefined node device 'mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0_0000_00_02_0'

# virsh nodedev-define mdevtest.xml 
Node device 'mdev_83a54ae7_09b1_4046_b0e2_b31de31505a0_0000_00_02_0' defined from 'mdevtest.xml'

Comment 12 errata-xmlrpc 2022-05-17 12:45:04 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 (new packages: libvirt), 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:2390


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