提交 7d84ca46 编写于 作者: N Nehal J Wani 提交者: Daniel P. Berrange

Use virFileFindResource to locate iohelper for virFileWrapperFdNew

Instead of hardcoding LIBEXECDIR as the location of the libvirt_iohelper
binary, use virFileFindResource to optionally find it in the current
build directory.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 391ac4d9
...@@ -200,6 +200,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) ...@@ -200,6 +200,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
bool output = false; bool output = false;
int pipefd[2] = { -1, -1 }; int pipefd[2] = { -1, -1 };
int mode = -1; int mode = -1;
char *iohelper_path = NULL;
if (!flags) { if (!flags) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -243,8 +244,15 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) ...@@ -243,8 +244,15 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
goto error; goto error;
} }
ret->cmd = virCommandNewArgList(LIBEXECDIR "/libvirt_iohelper", if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
name, "0", NULL); "src",
LIBEXECDIR)))
goto error;
ret->cmd = virCommandNewArgList(iohelper_path, name, "0", NULL);
VIR_FREE(iohelper_path);
if (output) { if (output) {
virCommandSetInputFD(ret->cmd, pipefd[0]); virCommandSetInputFD(ret->cmd, pipefd[0]);
virCommandSetOutputFD(ret->cmd, fd); virCommandSetOutputFD(ret->cmd, fd);
...@@ -275,6 +283,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) ...@@ -275,6 +283,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
return ret; return ret;
error: error:
VIR_FREE(iohelper_path);
VIR_FORCE_CLOSE(pipefd[0]); VIR_FORCE_CLOSE(pipefd[0]);
VIR_FORCE_CLOSE(pipefd[1]); VIR_FORCE_CLOSE(pipefd[1]);
virFileWrapperFdFree(ret); virFileWrapperFdFree(ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册