[libvirt PATCH v2 18/21] meson: stop setting runtime binaries defines during compilation

Pavel Hrdina phrdina at redhat.com
Mon Apr 19 17:14:21 UTC 2021


Technically the location of these binaries may be different when
compiling libvirt or running it. This will allow users to change $PATH
to use different binaries as well.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 meson.build                            | 41 ++++----------------------
 src/bhyve/bhyve_command.c              |  4 +++
 src/locking/lock_driver_lockd.c        | 12 ++------
 src/storage/storage_backend_logical.c  | 13 ++++++++
 src/storage/storage_backend_sheepdog.c |  2 ++
 src/storage/storage_backend_zfs.c      |  3 ++
 src/storage/storage_util.h             |  6 ++++
 src/util/virnuma.c                     |  1 +
 8 files changed, 36 insertions(+), 46 deletions(-)

diff --git a/meson.build b/meson.build
index 8c71e803bf..5d8eb7f95c 100644
--- a/meson.build
+++ b/meson.build
@@ -1074,9 +1074,7 @@ libparted_version = '1.8.0'
 libparted_dep = dependency('libparted', version: '>=' + libparted_version, required: false)
 if libparted_dep.found()
   parted_prog = find_program('parted', required: false, dirs: libvirt_sbin_path)
-  if parted_prog.found()
-    conf.set_quoted('PARTED', parted_prog.path())
-  else
+  if not parted_prog.found()
     libparted_dep = dependency('', required: false)
   endif
 endif
@@ -1488,9 +1486,6 @@ if not get_option('driver_bhyve').disabled() and host_machine.system() == 'freeb
 
   if bhyve_prog.found() and bhyvectl_prog.found() and bhyveload_prog.found()
     conf.set('WITH_BHYVE', 1)
-    conf.set_quoted('BHYVE', bhyve_prog.path())
-    conf.set_quoted('BHYVECTL', bhyvectl_prog.path())
-    conf.set_quoted('BHYVELOAD', bhyveload_prog.path())
   endif
 elif get_option('driver_bhyve').enabled()
   error('The bhyve driver cannot be enabled')
@@ -1779,18 +1774,7 @@ if conf.has('WITH_LIBVIRTD')
 
     if fs_enable
       use_storage = true
-
       conf.set('WITH_STORAGE_FS', 1)
-      conf.set_quoted('MOUNT', mount_prog.path())
-      conf.set_quoted('UMOUNT', umount_prog.path())
-      conf.set_quoted('MKFS', mkfs_prog.path())
-
-      showmount_prog = find_program('showmount', required: false, dirs: libvirt_sbin_path)
-      showmount_path = ''
-      if showmount_prog.found()
-        showmount_path = showmount_prog.path()
-      endif
-      conf.set_quoted('SHOWMOUNT', showmount_path)
     endif
   endif
 
@@ -1835,11 +1819,8 @@ if conf.has('WITH_LIBVIRTD')
       'pvs', 'vgs', 'lvs',
     ]
     foreach name : lvm_progs
-      set_variable(
-        '@0 at _prog'.format(name),
-        find_program(name, required: get_option('storage_lvm'), dirs: libvirt_sbin_path)
-      )
-      if not get_variable('@0 at _prog'.format(name)).found()
+      lvm_prog = find_program(name, required: get_option('storage_lvm'), dirs: libvirt_sbin_path)
+      if not lvm_prog.found()
         lvm_enable = false
       endif
     endforeach
@@ -1847,10 +1828,6 @@ if conf.has('WITH_LIBVIRTD')
     if lvm_enable
       use_storage = true
       conf.set('WITH_STORAGE_LVM', 1)
-
-      foreach name : lvm_progs
-        conf.set_quoted(name.to_upper(), get_variable('@0 at _prog'.format(name)).path())
-      endforeach
     endif
   endif
 
@@ -1879,7 +1856,6 @@ if conf.has('WITH_LIBVIRTD')
     if sheepdogcli_prog.found()
       use_storage = true
       conf.set('WITH_STORAGE_SHEEPDOG', 1)
-      conf.set_quoted('SHEEPDOGCLI', sheepdogcli_prog.path())
     endif
   endif
 
@@ -1902,11 +1878,8 @@ if conf.has('WITH_LIBVIRTD')
   if not get_option('storage_zfs').disabled()
     zfs_enable = true
     foreach name : ['zfs', 'zpool']
-      set_variable(
-        '@0 at _prog'.format(name),
-        find_program(name, required: get_option('storage_zfs'), dirs: libvirt_sbin_path)
-      )
-      if not get_variable('@0 at _prog'.format(name)).found()
+      zfs_prog = find_program(name, required: get_option('storage_zfs'), dirs: libvirt_sbin_path)
+      if not zfs_prog.found()
         zfs_enable = false
       endif
     endforeach
@@ -1914,9 +1887,6 @@ if conf.has('WITH_LIBVIRTD')
     if zfs_enable
       use_storage = true
       conf.set('WITH_STORAGE_ZFS', 1)
-      foreach name : ['zfs', 'zpool']
-        conf.set_quoted(name.to_upper(), get_variable('@0 at _prog'.format(name)).path())
-      endforeach
     endif
   endif
 endif
@@ -2030,7 +2000,6 @@ if not get_option('numad').disabled() and numactl_dep.found()
   numad_prog = find_program('numad', required: get_option('numad'), dirs: libvirt_sbin_path)
   if numad_prog.found()
     conf.set('WITH_NUMAD', 1)
-    conf.set_quoted('NUMAD', numad_prog.path())
   endif
 elif get_option('numad').enabled()
   error('You must have numactl enabled for numad support.')
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index f8e0ce5123..061138c8ec 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -37,6 +37,10 @@
 
 #define VIR_FROM_THIS VIR_FROM_BHYVE
 
+#define BHYVE "bhyve"
+#define BHYVECTL "bhyvectl"
+#define BHYVELOAD "bhyveload"
+
 VIR_LOG_INIT("bhyve.bhyve_command");
 
 static int
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 823b918db3..ea787bf87d 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -454,7 +454,8 @@ static int virLockManagerLockDaemonNew(virLockManager *lock,
 }
 
 
-#ifdef LVS
+#define LVS "lvs"
+
 static int
 virLockManagerGetLVMKey(const char *path,
                         char **key)
@@ -508,15 +509,6 @@ virLockManagerGetLVMKey(const char *path,
 
     return ret;
 }
-#else
-static int
-virLockManagerGetLVMKey(const char *path,
-                        char **key G_GNUC_UNUSED)
-{
-    virReportSystemError(ENOSYS, _("Unable to get LVM key for %s"), path);
-    return -1;
-}
-#endif
 
 
 static int virLockManagerLockDaemonAddResource(virLockManager *lock,
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index ed8e47d880..4bbb585d07 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -40,6 +40,19 @@
 
 VIR_LOG_INIT("storage.storage_backend_logical");
 
+#define PVCREATE "pvcreate"
+#define PVREMOVE "pvremove"
+#define PVS "pvs"
+#define VGCREATE "vgcreate"
+#define VGREMOVE "vgremove"
+#define VGCHANGE "vgchange"
+#define VGSCAN "vgscan"
+#define VGS "vgs"
+#define LVCREATE "lvcreate"
+#define LVREMOVE "lvremove"
+#define LVCHANGE "lvchange"
+#define LVS "lvs"
+
 
 static int
 virStorageBackendLogicalSetActive(virStoragePoolObj *pool,
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 6490dfae52..beb6445e1e 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -35,6 +35,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
+#define SHEEPDOGCLI "dog"
+
 static int virStorageBackendSheepdogRefreshVol(virStoragePoolObj *pool,
                                                virStorageVolDef *vol);
 
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 6fabeade11..2a5d74357d 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -33,6 +33,9 @@
 
 VIR_LOG_INIT("storage.storage_backend_zfs");
 
+#define ZFS "zfs"
+#define ZPOOL "zpool"
+
 /*
  * Some common flags of zfs and zpool commands we use:
  * -H -- don't print headers and separate fields by tab
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
index aa3c25e9fc..487345ff22 100644
--- a/src/storage/storage_util.h
+++ b/src/storage/storage_util.h
@@ -25,6 +25,12 @@
 #include "storage_driver.h"
 #include "storage_backend.h"
 
+#define PARTED "parted"
+#define MOUNT "mount"
+#define UMOUNT "umount"
+#define MKFS "mkfs"
+#define SHOWMOUNT "showmount"
+
 /* Storage Pool Namespace options to share w/ storage_backend_fs.c and
  * the virStorageBackendFileSystemMountCmd method */
 typedef struct _virStoragePoolFSMountOptionsDef virStoragePoolFSMountOptionsDef;
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 31f65d8902..d3cdc3ba53 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -52,6 +52,7 @@
 
 VIR_LOG_INIT("util.numa");
 
+#define NUMAD "numad"
 
 #if WITH_NUMAD
 char *
-- 
2.30.2




More information about the libvir-list mailing list