render / rpms / libvirt

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