mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Find helpers at runtime
Use the recently introduced virFindFileInPathFull() function to discover the path for qemu-bridge-helper and qemu-pr-helper at runtime. Note that it's still possible for the administrator to prevent this lookup and use arbitrary binaries by setting the appropriate keys in qemu.conf: this simply removes the need to perform the lookup at build time, and thus to have the helpers installed in the build environment. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
ef91f9e52a
commit
934113d376
@ -327,7 +327,14 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *cfg,
|
||||
int *tapfd,
|
||||
unsigned int flags)
|
||||
{
|
||||
const char *const bridgeHelperDirs[] = {
|
||||
"/usr/libexec",
|
||||
"/usr/lib/qemu",
|
||||
"/usr/lib",
|
||||
NULL,
|
||||
};
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
g_autofree char *bridgeHelperPath = NULL;
|
||||
char *errbuf = NULL, *cmdstr = NULL;
|
||||
int pair[2] = { -1, -1 };
|
||||
|
||||
@ -339,13 +346,17 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *cfg,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virFileIsExecutable(cfg->bridgeHelperName)) {
|
||||
bridgeHelperPath = virFindFileInPathFull(cfg->bridgeHelperName, bridgeHelperDirs);
|
||||
|
||||
if (!bridgeHelperPath) {
|
||||
virReportSystemError(errno, _("'%1$s' is not a suitable bridge helper"),
|
||||
cfg->bridgeHelperName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd = virCommandNew(cfg->bridgeHelperName);
|
||||
VIR_DEBUG("Using qemu-bridge-helper: %s", bridgeHelperPath);
|
||||
|
||||
cmd = virCommandNew(bridgeHelperPath);
|
||||
if (flags & VIR_NETDEV_TAP_CREATE_VNET_HDR)
|
||||
virCommandAddArgFormat(cmd, "--use-vnet");
|
||||
virCommandAddArgFormat(cmd, "--br=%s", brname);
|
||||
|
@ -2818,10 +2818,15 @@ qemuProcessStartPRDaemonHook(void *opaque)
|
||||
int
|
||||
qemuProcessStartManagedPRDaemon(virDomainObj *vm)
|
||||
{
|
||||
const char *const prHelperDirs[] = {
|
||||
"/usr/libexec",
|
||||
NULL,
|
||||
};
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
virQEMUDriver *driver = priv->driver;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||
int errfd = -1;
|
||||
g_autofree char *prHelperPath = NULL;
|
||||
g_autofree char *pidfile = NULL;
|
||||
g_autofree char *socketPath = NULL;
|
||||
pid_t cpid = -1;
|
||||
@ -2832,12 +2837,16 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm)
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
if (!virFileIsExecutable(cfg->prHelperName)) {
|
||||
prHelperPath = virFindFileInPathFull(cfg->prHelperName, prHelperDirs);
|
||||
|
||||
if (!prHelperPath) {
|
||||
virReportSystemError(errno, _("'%1$s' is not a suitable pr helper"),
|
||||
cfg->prHelperName);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Using qemu-pr-helper: %s", prHelperPath);
|
||||
|
||||
if (!(pidfile = qemuProcessBuildPRHelperPidfilePath(vm)))
|
||||
goto cleanup;
|
||||
|
||||
@ -2853,7 +2862,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(cmd = virCommandNewArgList(cfg->prHelperName,
|
||||
if (!(cmd = virCommandNewArgList(prHelperPath,
|
||||
"-k", socketPath,
|
||||
NULL)))
|
||||
goto cleanup;
|
||||
@ -2881,7 +2890,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm)
|
||||
if (virPidFileReadPath(pidfile, &cpid) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("pr helper %1$s didn't show up"),
|
||||
cfg->prHelperName);
|
||||
prHelperPath);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -2899,7 +2908,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm)
|
||||
if (saferead(errfd, errbuf, sizeof(errbuf) - 1) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("pr helper %1$s died unexpectedly"),
|
||||
cfg->prHelperName);
|
||||
prHelperPath);
|
||||
} else {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("pr helper died and reported: %1$s"), errbuf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user