From d993cec578f2bbb121dcacea6728cf34da14e62e Mon Sep 17 00:00:00 2001 Message-ID: From: Boris Fiuczynski Date: Fri, 30 Jun 2023 13:34:00 +0200 Subject: [PATCH] nodedev: transient mdev update on nodeDeviceCreateXML Update the optional mdev attributes by running an mdevctl update on a new created nodedev object representing an mdev. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143158 Signed-off-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2143158 (cherry picked from commit 37481aa1f15ece6b187b8fa219966f77648c813d) Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_udev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 4c37ec3189..fce4212728 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1757,12 +1757,20 @@ nodeStateCleanup(void) static int udevHandleOneDevice(struct udev_device *device) { + virNodeDevCapType dev_cap_type; const char *action = udev_device_get_action(device); VIR_DEBUG("udev action: '%s': %s", action, udev_device_get_syspath(device)); - if (STREQ(action, "add") || STREQ(action, "change")) - return udevAddOneDevice(device); + if (STREQ(action, "add") || STREQ(action, "change")) { + int ret = udevAddOneDevice(device); + if (ret == 0 && + udevGetDeviceType(device, &dev_cap_type) == 0 && + dev_cap_type == VIR_NODE_DEV_CAP_MDEV) + if (nodeDeviceUpdateMediatedDevices() < 0) + VIR_WARN("mdevctl failed to update mediated devices"); + return ret; + } if (STREQ(action, "remove")) return udevRemoveOneDevice(device); -- 2.41.0