1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

util: extend virExecWithHook()

This patch extends virExecWithHook() to receive
capability information.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
This commit is contained in:
Taku Izumi 2012-01-30 23:51:00 -05:00 committed by Laine Stump
parent 53bd0cebd3
commit c2e146bfb0

View File

@ -394,6 +394,7 @@ prepareStdFd(int fd, int std)
* @hook optional virExecHook function to call prior to exec * @hook optional virExecHook function to call prior to exec
* @data data to pass to the hook function * @data data to pass to the hook function
* @pidfile path to use as pidfile for daemonized process (needs DAEMON flag) * @pidfile path to use as pidfile for daemonized process (needs DAEMON flag)
* @capabilities capabilities to keep
*/ */
static int static int
virExecWithHook(const char *const*argv, virExecWithHook(const char *const*argv,
@ -405,7 +406,8 @@ virExecWithHook(const char *const*argv,
unsigned int flags, unsigned int flags,
virExecHook hook, virExecHook hook,
void *data, void *data,
char *pidfile) char *pidfile,
unsigned long long capabilities)
{ {
pid_t pid; pid_t pid;
int null = -1, i, openmax; int null = -1, i, openmax;
@ -634,9 +636,9 @@ virExecWithHook(const char *const*argv,
/* The steps above may need todo something privileged, so /* The steps above may need todo something privileged, so
* we delay clearing capabilities until the last minute */ * we delay clearing capabilities until the last minute */
if ((flags & VIR_EXEC_CLEAR_CAPS) && if (capabilities || (flags & VIR_EXEC_CLEAR_CAPS))
virClearCapabilities() < 0) if (virSetCapabilities(capabilities) < 0)
goto fork_error; goto fork_error;
/* Close logging again to ensure no FDs leak to child */ /* Close logging again to ensure no FDs leak to child */
virLogReset(); virLogReset();
@ -724,7 +726,8 @@ virExecWithHook(const char *const*argv ATTRIBUTE_UNUSED,
int flags_unused ATTRIBUTE_UNUSED, int flags_unused ATTRIBUTE_UNUSED,
virExecHook hook ATTRIBUTE_UNUSED, virExecHook hook ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED,
char *pidfile ATTRIBUTE_UNUSED) char *pidfile ATTRIBUTE_UNUSED,
unsigned long long capabilities ATTRIBUTE_UNUSED)
{ {
/* XXX: Some day we can implement pieces of virCommand/virExec on /* XXX: Some day we can implement pieces of virCommand/virExec on
* top of _spawn() or CreateProcess(), but we can't implement * top of _spawn() or CreateProcess(), but we can't implement
@ -2172,7 +2175,8 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
cmd->flags, cmd->flags,
virCommandHook, virCommandHook,
cmd, cmd,
cmd->pidfile); cmd->pidfile,
cmd->capabilities);
VIR_DEBUG("Command result %d, with PID %d", VIR_DEBUG("Command result %d, with PID %d",
ret, (int)cmd->pid); ret, (int)cmd->pid);