libvirt/SOURCES/libvirt-m4-Provide-default-value-fore-UDEVADM.patch
2021-09-10 11:57:18 +00:00

101 lines
3.7 KiB
Diff

From 1113a43a48b3c15f908a396ec88e9499df10f7b4 Mon Sep 17 00:00:00 2001
Message-Id: <1113a43a48b3c15f908a396ec88e9499df10f7b4@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:55:38 +0200
Subject: [PATCH] m4: Provide default value fore UDEVADM
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It may happen that the system where libvirt is built at doesn't
have udevadm binary but the one where it runs does have it.
If we change how udevadm is run in virWaitForDevices() then we
can safely pass a default value in m4 macro.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 523b799d3c356b9b4ea0b117a60cfc3b603eaffa)
https://bugzilla.redhat.com/show_bug.cgi?id=1710575
Difference to the upstream commit is that I had to drop
VIR_AUTOPTR() of virCommand because that does not exist in the
downstream yet.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <3d2deafb1bf06eddd721fceb15961b27c8dbf0cf.1561643698.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
m4/virt-external-programs.m4 | 9 +++------
src/util/virutil.c | 16 ++++++++--------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4
index 3c915e1a65..f1ae104b32 100644
--- a/m4/virt-external-programs.m4
+++ b/m4/virt-external-programs.m4
@@ -45,7 +45,7 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
AC_PATH_PROG([DNSMASQ], [dnsmasq], [dnsmasq], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([RADVD], [radvd], [radvd], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([TC], [tc], [tc], [$LIBVIRT_SBIN_PATH])
- AC_PATH_PROG([UDEVADM], [udevadm], [], [$LIBVIRT_SBIN_PATH])
+ AC_PATH_PROG([UDEVADM], [udevadm], [udevadm], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([MODPROBE], [modprobe], [modprobe], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([RMMOD], [rmmod], [rmmod], [$LIBVIRT_SBIN_PATH])
AC_PATH_PROG([MMCTL], [mm-ctl], [mm-ctl], [$LIBVIRT_SBIN_PATH])
@@ -65,11 +65,8 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [
[Location or name of the mm-ctl program])
AC_DEFINE_UNQUOTED([OVSVSCTL], ["$OVSVSCTL"],
[Location or name of the ovs-vsctl program])
-
- if test -n "$UDEVADM"; then
- AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
- [Location or name of the udevadm program])
- fi
+ AC_DEFINE_UNQUOTED([UDEVADM], ["$UDEVADM"],
+ [Location or name of the udevadm program])
if test -n "$MODPROBE"; then
AC_DEFINE_UNQUOTED([MODPROBE], ["$MODPROBE"],
[Location or name of the modprobe program])
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 68d3217248..cd67f54bc2 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1621,25 +1621,25 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
#endif
-#if defined(UDEVADM)
void virWaitForDevices(void)
{
- const char *const settleprog[] = { UDEVADM, "settle", NULL };
+ virCommandPtr cmd = NULL;
+ VIR_AUTOFREE(char *) udev = NULL;
int exitstatus;
- if (access(settleprog[0], X_OK) != 0)
+ if (!(udev = virFindFileInPath(UDEVADM)))
+ return;
+
+ if (!(cmd = virCommandNewArgList(udev, "settle", NULL)))
return;
/*
* NOTE: we ignore errors here; this is just to make sure that any device
* nodes that are being created finish before we try to scan them.
*/
- ignore_value(virRun(settleprog, &exitstatus));
+ ignore_value(virCommandRun(cmd, &exitstatus));
+ virCommandFree(cmd);
}
-#else
-void virWaitForDevices(void)
-{}
-#endif
#if WITH_DEVMAPPER
bool
--
2.22.0