On Mon, Jul 26, 2021 at 9:47 AM Michal Prívozník <mprivozn(a)redhat.com> wrote:
On 7/23/21 6:40 PM, Jonathon Jongsma wrote:
> Unfortunately, mdevctl supports defining more than one mdev with the
> same UUID as long as they have different parent devices. (Only one of
> these devices can be active at any given time).
>
> This means that we can't use the UUID alone as a way to uniquely
> identify mdev node devices. Append the parent address to ensure
> uniqueness. For example:
>
> Before: mdev_88a6b868_46bd_4015_8e5b_26107f82da38
> After: mdev_88a6b868_46bd_4015_8e5b_26107f82da38_0000_00_02_0
>
> Related:
https://bugzilla.redhat.com/show_bug.cgi?id=1979440
>
> Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
> ---
> src/node_device/node_device_driver.c | 3 ++-
> src/node_device/node_device_udev.c | 2 +-
> tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml | 8 ++++----
> 3 files changed, 7 insertions(+), 6 deletions(-)
The patch looks good, but for some reason it leaves API breakage
aftertaste. But I guess we don't document anywhere what MDEV <name/>
looks like, do we? IOW - we are free to change it if needed.
That is true -- it does have a bit of a bad aftertaste. As far as I
know, we haven't documented or promised any specific naming format for
mdevs. But it could certainly cause some pain for people that are
using mdevs already, which might be reason enough to reject or adjust
this patch. If a person already has assigned a mdev device to their vm
with the old name, the name would change when upgrading libvirt. That
could make the domain definition become invalid.
But, we have to deal with this situation somehow. We don't have a
choice but to handle the case where mdevctl might return multiple
defined devices with the same UUID. I considered a couple of other
approaches to handling this that I rejected, such as
- only add a suffix to the second such device with the same UUID
- rejected because the name of a given device depends on the order
in which it was observed and the presence of other devices. For
example, if we have two devices: mdev_$UUID and mdev_$UUID_$PARENT,
and the first device was undefined, then when libvirt was restarted,
mdev_$UUID_$PARENT would change its name to mdev_$UUID because it is
now the only device with that UUID
- name all *active* mdevs mdev_$UUID and use a different scheme for
inactive, defined mdevs
- rejected because the device would change names when it changed
from inactive to active.
- ignore this situation because probably almost nobody uses multiple
devices with the same UUID
- but do they?
It's possible that we could make the transition a little bit less
painful by automatically translating the old name to the new one for
cases where it was unambiguous. I haven't looked into what it would
require to do something like that, but it seems possible.
Jonathon