[libvirt PATCH 0/3] qemu: Find dbus-daemon at runtime

Same as the changes made recently for QEMU helpers, except even more straightforward. Andrea Bolognani (3): qemu: Find dbus-daemon at runtime meson: Stop looking for dbus-daemon qemu: Update documentation for dbus_daemon qemu.conf key meson.build | 12 ------------ src/qemu/qemu.conf.in | 4 +++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_dbus.c | 14 +++++++++----- src/qemu/test_libvirtd_qemu.aug.in | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-) -- 2.40.1

Don't bother looking at /usr/libexec, since every distro ships dbus-daemon in $PATH. Note that it's still possible for the administrator to prevent this lookup and use an arbitrary binary by setting the appropriate key in qemu.conf. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_dbus.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 7a7af2850e..06b655d870 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -175,6 +175,7 @@ qemuDBusStart(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv = vm->privateData; g_autoptr(virCommand) cmd = NULL; + g_autofree char *dbusDaemonPath = NULL; g_autofree char *shortName = NULL; g_autofree char *pidfile = NULL; g_autofree char *configfile = NULL; @@ -188,13 +189,16 @@ qemuDBusStart(virQEMUDriver *driver, if (priv->dbusDaemonRunning) return 0; - if (!virFileIsExecutable(cfg->dbusDaemonName)) { + dbusDaemonPath = virFindFileInPath(cfg->dbusDaemonName); + if (!dbusDaemonPath) { virReportSystemError(errno, _("'%1$s' is not a suitable dbus-daemon"), cfg->dbusDaemonName); return -1; } + VIR_DEBUG("Using dbus-daemon: %s", dbusDaemonPath); + if (!(shortName = virDomainDefGetShortName(vm->def))) return -1; @@ -210,7 +214,7 @@ qemuDBusStart(virQEMUDriver *driver, if (qemuSecurityDomainSetPathLabel(driver, vm, configfile, false) < 0) goto cleanup; - cmd = virCommandNew(cfg->dbusDaemonName); + cmd = virCommandNew(dbusDaemonPath); virCommandClearCaps(cmd); virCommandSetPidFile(cmd, pidfile); virCommandSetErrorFD(cmd, &errfd); @@ -223,7 +227,7 @@ qemuDBusStart(virQEMUDriver *driver, if (virPidFileReadPath(pidfile, &cpid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("dbus-daemon %1$s didn't show up"), - cfg->dbusDaemonName); + dbusDaemonPath); goto cleanup; } @@ -241,7 +245,7 @@ qemuDBusStart(virQEMUDriver *driver, if (saferead(errfd, errbuf, sizeof(errbuf) - 1) < 0) { virReportSystemError(errno, _("dbus-daemon %1$s died unexpectedly"), - cfg->dbusDaemonName); + dbusDaemonPath); } else { virReportError(VIR_ERR_OPERATION_FAILED, _("dbus-daemon died and reported: %1$s"), errbuf); @@ -253,7 +257,7 @@ qemuDBusStart(virQEMUDriver *driver, if (!virFileExists(sockpath)) { virReportError(VIR_ERR_OPERATION_TIMEOUT, _("dbus-daemon %1$s didn't show up"), - cfg->dbusDaemonName); + dbusDaemonPath); goto cleanup; } -- 2.40.1

Now that we're performing the lookup at runtime, doing it at build time is no longer necessary. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 12 ------------ src/qemu/qemu_conf.c | 1 + 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 6e65e9eec3..a99a2a260b 100644 --- a/meson.build +++ b/meson.build @@ -1666,18 +1666,6 @@ if not get_option('driver_qemu').disabled() qemu_slirp_path = '/usr/bin/slirp-helper' endif conf.set_quoted('QEMU_SLIRP_HELPER', qemu_slirp_path) - - qemu_dbus_daemon_prog = find_program( - 'dbus-daemon', - dirs: [ '/usr/bin', '/usr/libexec' ], - required: false - ) - if qemu_dbus_daemon_prog.found() - qemu_dbus_daemon_path = qemu_dbus_daemon_prog.full_path() - else - qemu_dbus_daemon_path = '/usr/bin/dbus-daemon' - endif - conf.set_quoted('QEMU_DBUS_DAEMON', qemu_dbus_daemon_path) endif endif diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c76ae7ac93..bd984448a3 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -99,6 +99,7 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig); #define QEMU_BRIDGE_HELPER "qemu-bridge-helper" #define QEMU_PR_HELPER "qemu-pr-helper" +#define QEMU_DBUS_DAEMON "dbus-daemon" virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged, -- 2.40.1

Reflect the new default value, and explain that a runtime lookup will be performed if the value is not an absolute path. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu.conf.in | 4 +++- src/qemu/test_libvirtd_qemu.aug.in | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index e1a9a5e56d..6897e0f760 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -909,7 +909,9 @@ #slirp_helper = "/usr/bin/slirp-helper" # Path to the dbus-daemon -#dbus_daemon = "/usr/bin/dbus-daemon" +# If this is not an absolute path, the program will be searched for +# in $PATH. +#dbus_daemon = "dbus-daemon" # User for the swtpm TPM Emulator # diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in index af99331886..c730df40b0 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -109,7 +109,7 @@ module Test_libvirtd_qemu = { "memory_backing_dir" = "/var/lib/libvirt/qemu/ram" } { "pr_helper" = "qemu-pr-helper" } { "slirp_helper" = "/usr/bin/slirp-helper" } -{ "dbus_daemon" = "/usr/bin/dbus-daemon" } +{ "dbus_daemon" = "dbus-daemon" } { "swtpm_user" = "tss" } { "swtpm_group" = "tss" } { "capability_filters" -- 2.40.1

On 5/10/23 21:06, Andrea Bolognani wrote:
Same as the changes made recently for QEMU helpers, except even more straightforward.
Andrea Bolognani (3): qemu: Find dbus-daemon at runtime meson: Stop looking for dbus-daemon qemu: Update documentation for dbus_daemon qemu.conf key
meson.build | 12 ------------ src/qemu/qemu.conf.in | 4 +++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_dbus.c | 14 +++++++++----- src/qemu/test_libvirtd_qemu.aug.in | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Andrea Bolognani
-
Michal Prívozník