[libvirt PATCH 1/2] nodedev: fix parent device of inactive mdevs

Jonathon Jongsma jjongsma at redhat.com
Fri Jul 9 14:48:28 UTC 2021


On Fri, Jul 9, 2021 at 6:11 AM Boris Fiuczynski <fiuczy at linux.ibm.com> wrote:
>
> Some observations without these patches
>
>
> # mdevctl list -d
> e60cef97-3f6b-485e-ac46-0520f9f66ac2 0.0.0033 vfio_ccw-io manual (active)
>
> # virsh nodedev-list --cap mdev
> mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
>
> # virsh nodedev-list --inactive --cap mdev
>
> # virsh nodedev-dumpxml mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>
> <path>/sys/devices/css0/0.0.0033/e60cef97-3f6b-485e-ac46-0520f9f66ac2</path>
>    <parent>css_0_0_0033</parent>
>    <driver>
>      <name>vfio_mdev</name>
>    </driver>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
> # virsh nodedev-destroy mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> Destroyed node device 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2'
>
> # virsh nodedev-list --inactive --cap mdev
> mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
>
>
> QUESTION: My mdev is defined and active. I know this from looking at
> mdevctl.
> As the option inactive seems not to match the mdevctl option defined how
> can I find out that I can e.g. use nodedev-undefine without
> stopping/destroying it first?
> Do we need another option like defined on nodedev-list?
>
>
> Anyway using nodedev-dumpxml I get the parent correctly.
> # virsh nodedev-dumpxml mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>    <parent>css_0_0_0033</parent>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
>
> And now the wrap up to start over again...
>
>
> # virsh nodedev-undefine mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> Undefined node device 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2'
>
> # virsh nodedev-list --inactive --cap mdev
> mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
>
> # virsh nodedev-list --all --cap mdev
> mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
>
> # virsh nodedev-list --cap mdev
>
> # mdevctl list -d
> # mdevctl list
>
> # virsh nodedev-dumpxml mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>    <parent>css_0_0_0033</parent>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
> # virsh nodedev-start mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> error: Failed to start device mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> error: internal error: Unable to create mediated device: Config for
> e60cef97-3f6b-485e-ac46-0520f9f66ac2 does not exist, define it first?
>
> # virsh nodedev-undefine mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> Undefined node device 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2'
>
> # virsh nodedev-list --all --cap mdev
> mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
>
>
> That is definitely a bug.
> But in all dumped XMLs the parent seems to be provided correctly.

This looks like the bug parsing an empty list that you just submitted
a patch for.


> # cat mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2.xml
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>
> <path>/sys/devices/css0/0.0.0033/e60cef97-3f6b-485e-ac46-0520f9f66ac2</path>
>    <parent>css_0_0_0033</parent>
>    <driver>
>      <name>vfio_mdev</name>
>    </driver>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
> # virsh nodedev-define mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2.xml
> Node device 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2' defined from
> 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2.xml'
>
> # virsh nodedev-list --all --cap mdev
> mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
>
> # mdevctl list -d
> e60cef97-3f6b-485e-ac46-0520f9f66ac2 0.0.0033 vfio_ccw-io manual
> # virsh nodedev-dumpxml mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>    <parent>css_0_0_0033</parent>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
>
> Rerunning it with the dumpxml from the defined only mdev.
>
>
> # virsh nodedev-undefine mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> Undefined node device 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2'
>
> # mdevctl list -d
> # virsh nodedev-dumpxml mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>    <parent>css_0_0_0033</parent>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
> # cat mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2_defined.xml
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>    <parent>css_0_0_0033</parent>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
> # virsh nodedev-define mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2_defined.xml
> Node device 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2' defined from
> 'mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2_defined.xml'
>
> # mdevctl list -d
> e60cef97-3f6b-485e-ac46-0520f9f66ac2 0.0.0033 vfio_ccw-io manual
>
> # virsh nodedev-dumpxml mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2
> <device>
>    <name>mdev_e60cef97_3f6b_485e_ac46_0520f9f66ac2</name>
>    <parent>css_0_0_0033</parent>
>    <capability type='mdev'>
>      <type id='vfio_ccw-io'/>
>      <uuid>e60cef97-3f6b-485e-ac46-0520f9f66ac2</uuid>
>      <iommuGroup number='1'/>
>    </capability>
> </device>
>
>
> So either I misunderstood the problem you are trying to resolve or it
> exists on PCI only.

Ah, this bug only manifests for inactive devices that were loaded from
mdevctl without first being processed by libvirt some other way. So,
in your example, the bug is not present because libvirt parsed the
appropriate parent id from your XML input. Here are a couple simple
ways to reproduce the bug:
 - define a device outside of libvirt (using mdevctl directly) and
then dump the xml in libvirt.
 - define the device with nodedev-define, then restart the libvirt
daemon so that the cached value from the XML input is forgotten. Then
dump xml for the defined device.

Jonathon




More information about the libvir-list mailing list