libvirt-9.5.0-2.el9
- nodedev: transient mdev update on nodeDeviceCreateXML (rhbz#2143158) - nodedev: refactor mdevctl thread functions (rhbz#2143158) - nodedev: update mdevs from the mdevctl thread (rhbz#2143158) Resolves: rhbz#2143158
This commit is contained in:
parent
6e357dd23e
commit
04cb88e791
105
libvirt-nodedev-refactor-mdevctl-thread-functions.patch
Normal file
105
libvirt-nodedev-refactor-mdevctl-thread-functions.patch
Normal file
@ -0,0 +1,105 @@
|
||||
From 05230da856d2f016c21f49a406780fbe15f74c32 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <05230da856d2f016c21f49a406780fbe15f74c32.1689602377.git.jdenemar@redhat.com>
|
||||
From: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
Date: Wed, 5 Jul 2023 15:35:59 -0500
|
||||
Subject: [PATCH] nodedev: refactor mdevctl thread functions
|
||||
|
||||
Factor out a new scheduleMdevctlUpdate() function so that we can re-use
|
||||
it from other places. Now that other events can make it necessary to
|
||||
re-query mdevctl for mdev updates, this function will be useful for
|
||||
coalescing multiple updates in quick succession into a single mdevctl
|
||||
query.
|
||||
|
||||
Also rename a couple functions. The names weren't very descriptive of
|
||||
their behavior. For example, the old scheduleMdevctlHandler() function
|
||||
didn't actually schedule anything, it just started a thread. So rename
|
||||
it to free up the 'schedule' name for the above refactored function.
|
||||
|
||||
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
||||
(cherry picked from commit 9b7fadc5dc33b85b597c95d944dc23c02c29c29f)
|
||||
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
|
||||
|
||||
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
---
|
||||
src/node_device/node_device_udev.c | 36 ++++++++++++++++++++----------
|
||||
1 file changed, 24 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
|
||||
index fce4212728..86ef4af728 100644
|
||||
--- a/src/node_device/node_device_udev.c
|
||||
+++ b/src/node_device/node_device_udev.c
|
||||
@@ -2075,7 +2075,7 @@ udevPCITranslateInit(bool privileged G_GNUC_UNUSED)
|
||||
|
||||
|
||||
static void
|
||||
-mdevctlHandlerThread(void *opaque G_GNUC_UNUSED)
|
||||
+mdevctlUpdateThreadFunc(void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
udevEventData *priv = driver->privateData;
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&priv->mdevctlLock);
|
||||
@@ -2086,7 +2086,7 @@ mdevctlHandlerThread(void *opaque G_GNUC_UNUSED)
|
||||
|
||||
|
||||
static void
|
||||
-scheduleMdevctlHandler(int timer G_GNUC_UNUSED, void *opaque)
|
||||
+launchMdevctlUpdateThread(int timer G_GNUC_UNUSED, void *opaque)
|
||||
{
|
||||
udevEventData *priv = opaque;
|
||||
virThread thread;
|
||||
@@ -2096,7 +2096,7 @@ scheduleMdevctlHandler(int timer G_GNUC_UNUSED, void *opaque)
|
||||
priv->mdevctlTimeout = -1;
|
||||
}
|
||||
|
||||
- if (virThreadCreateFull(&thread, false, mdevctlHandlerThread,
|
||||
+ if (virThreadCreateFull(&thread, false, mdevctlUpdateThreadFunc,
|
||||
"mdevctl-thread", false, NULL) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("failed to create mdevctl thread"));
|
||||
@@ -2192,6 +2192,26 @@ mdevctlEnableMonitor(udevEventData *priv)
|
||||
}
|
||||
|
||||
|
||||
+/* Schedules an mdevctl update for 100ms in the future, canceling any existing
|
||||
+ * timeout that may have been set. In this way, multiple update requests in
|
||||
+ * quick succession can be collapsed into a single update. if @force is true,
|
||||
+ * an update thread will be spawned immediately. */
|
||||
+static void
|
||||
+scheduleMdevctlUpdate(udevEventData *data,
|
||||
+ bool force)
|
||||
+{
|
||||
+ if (!force) {
|
||||
+ if (data->mdevctlTimeout > 0)
|
||||
+ virEventRemoveTimeout(data->mdevctlTimeout);
|
||||
+ data->mdevctlTimeout = virEventAddTimeout(100, launchMdevctlUpdateThread,
|
||||
+ data, NULL);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ launchMdevctlUpdateThread(-1, data);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static void
|
||||
mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED,
|
||||
GFile *file,
|
||||
@@ -2222,15 +2242,7 @@ mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED,
|
||||
* configuration change, try to coalesce these changes by waiting for the
|
||||
* CHANGES_DONE_HINT event. As a fallback, add a timeout to trigger the
|
||||
* signal if that event never comes */
|
||||
- if (event_type != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
|
||||
- if (priv->mdevctlTimeout > 0)
|
||||
- virEventRemoveTimeout(priv->mdevctlTimeout);
|
||||
- priv->mdevctlTimeout = virEventAddTimeout(100, scheduleMdevctlHandler,
|
||||
- priv, NULL);
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- scheduleMdevctlHandler(-1, priv);
|
||||
+ scheduleMdevctlUpdate(priv, (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT));
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.41.0
|
@ -0,0 +1,50 @@
|
||||
From d993cec578f2bbb121dcacea6728cf34da14e62e Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <d993cec578f2bbb121dcacea6728cf34da14e62e.1689602377.git.jdenemar@redhat.com>
|
||||
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
||||
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 <fiuczy@linux.ibm.com>
|
||||
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
|
||||
|
||||
(cherry picked from commit 37481aa1f15ece6b187b8fa219966f77648c813d)
|
||||
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
---
|
||||
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
|
70
libvirt-nodedev-update-mdevs-from-the-mdevctl-thread.patch
Normal file
70
libvirt-nodedev-update-mdevs-from-the-mdevctl-thread.patch
Normal file
@ -0,0 +1,70 @@
|
||||
From 48813113774c7ff0ab1b43c1861b6495bb3ce830 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <48813113774c7ff0ab1b43c1861b6495bb3ce830.1689602377.git.jdenemar@redhat.com>
|
||||
From: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
Date: Thu, 6 Jul 2023 09:16:35 -0500
|
||||
Subject: [PATCH] nodedev: update mdevs from the mdevctl thread
|
||||
|
||||
Rather than directly executing mdevctl from the udev event thread when
|
||||
we determine that we need to re-query, schedule the mdevctl thread to
|
||||
run. This also helps to coalesce multiple back-to-back updates into a
|
||||
single one when there are multiple updates in a row or at startup when a
|
||||
host has a very large number of mdevs.
|
||||
|
||||
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
||||
(cherry picked from commit 14026db9b0e25739ea30685bd643ff23aca30588)
|
||||
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
|
||||
|
||||
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
|
||||
---
|
||||
src/node_device/node_device_udev.c | 13 +++++++------
|
||||
1 file changed, 7 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
|
||||
index 86ef4af728..6451574c1d 100644
|
||||
--- a/src/node_device/node_device_udev.c
|
||||
+++ b/src/node_device/node_device_udev.c
|
||||
@@ -1443,6 +1443,9 @@ udevGetDeviceDetails(struct udev_device *device,
|
||||
}
|
||||
|
||||
|
||||
+static void scheduleMdevctlUpdate(udevEventData *data, bool force);
|
||||
+
|
||||
+
|
||||
static int
|
||||
udevRemoveOneDeviceSysPath(const char *path)
|
||||
{
|
||||
@@ -1475,8 +1478,7 @@ udevRemoveOneDeviceSysPath(const char *path)
|
||||
virNodeDeviceObjEndAPI(&obj);
|
||||
|
||||
/* cannot check for mdev_types since they have already been removed */
|
||||
- if (nodeDeviceUpdateMediatedDevices() < 0)
|
||||
- VIR_WARN("mdevctl failed to update mediated devices");
|
||||
+ scheduleMdevctlUpdate(driver->privateData, false);
|
||||
|
||||
virObjectEventStateQueue(driver->nodeDeviceEventState, event);
|
||||
return 0;
|
||||
@@ -1604,8 +1606,8 @@ udevAddOneDevice(struct udev_device *device)
|
||||
has_mdev_types = virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_MDEV_TYPES);
|
||||
virNodeDeviceObjEndAPI(&obj);
|
||||
|
||||
- if (has_mdev_types && nodeDeviceUpdateMediatedDevices() < 0)
|
||||
- VIR_WARN("mdevctl failed to update mediated devices");
|
||||
+ if (has_mdev_types)
|
||||
+ scheduleMdevctlUpdate(driver->privateData, false);
|
||||
|
||||
ret = 0;
|
||||
|
||||
@@ -1767,8 +1769,7 @@ udevHandleOneDevice(struct udev_device *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");
|
||||
+ scheduleMdevctlUpdate(driver->privateData, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
--
|
||||
2.41.0
|
11
libvirt.spec
11
libvirt.spec
@ -229,7 +229,7 @@
|
||||
Summary: Library providing a simple virtualization API
|
||||
Name: libvirt
|
||||
Version: 9.5.0
|
||||
Release: 1%{?dist}%{?extra_release}
|
||||
Release: 2%{?dist}%{?extra_release}
|
||||
License: GPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OFL-1.1
|
||||
URL: https://libvirt.org/
|
||||
|
||||
@ -238,6 +238,10 @@ URL: https://libvirt.org/
|
||||
%endif
|
||||
Source: https://download.libvirt.org/%{?mainturl}libvirt-%{version}.tar.xz
|
||||
Source1: symlinks
|
||||
Patch1: libvirt-nodedev-transient-mdev-update-on-nodeDeviceCreateXML.patch
|
||||
Patch2: libvirt-nodedev-refactor-mdevctl-thread-functions.patch
|
||||
Patch3: libvirt-nodedev-update-mdevs-from-the-mdevctl-thread.patch
|
||||
|
||||
|
||||
Requires: libvirt-daemon = %{version}-%{release}
|
||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||
@ -2473,6 +2477,11 @@ exit 0
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Jul 17 2023 Jiri Denemark <jdenemar@redhat.com> - 9.5.0-2
|
||||
- nodedev: transient mdev update on nodeDeviceCreateXML (rhbz#2143158)
|
||||
- nodedev: refactor mdevctl thread functions (rhbz#2143158)
|
||||
- nodedev: update mdevs from the mdevctl thread (rhbz#2143158)
|
||||
|
||||
* Mon Jul 3 2023 Jiri Denemark <jdenemar@redhat.com> - 9.5.0-1
|
||||
- Rebased to libvirt-9.5.0 (rhbz#2175785)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user