mirror of https://gitee.com/openkylin/libvirt.git
utils: Implement virCommandPassFDGetFDIndex
Implement virCommandPassFDGetFDIndex to determine the index a given file descriptor will have when passed to the child process. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
3b7f589571
commit
a06e9ce11d
|
@ -1214,6 +1214,7 @@ virCommandNewArgList;
|
||||||
virCommandNewArgs;
|
virCommandNewArgs;
|
||||||
virCommandNonblockingFDs;
|
virCommandNonblockingFDs;
|
||||||
virCommandPassFD;
|
virCommandPassFD;
|
||||||
|
virCommandPassFDGetFDIndex;
|
||||||
virCommandPassListenFDs;
|
virCommandPassListenFDs;
|
||||||
virCommandRawStatus;
|
virCommandRawStatus;
|
||||||
virCommandRequireHandshake;
|
virCommandRequireHandshake;
|
||||||
|
|
|
@ -1019,6 +1019,30 @@ virCommandPassListenFDs(virCommandPtr cmd)
|
||||||
cmd->flags |= VIR_EXEC_LISTEN_FDS;
|
cmd->flags |= VIR_EXEC_LISTEN_FDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* virCommandPassFDGetFDIndex:
|
||||||
|
* @cmd: pointer to virCommand
|
||||||
|
* @fd: FD to get index of
|
||||||
|
*
|
||||||
|
* Determine the index of the FD in the transfer set.
|
||||||
|
*
|
||||||
|
* Returns index >= 0 if @set contains @fd,
|
||||||
|
* -1 otherwise.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virCommandPassFDGetFDIndex(virCommandPtr cmd, int fd)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
while (i < cmd->npassfd) {
|
||||||
|
if (cmd->passfd[i].fd == fd)
|
||||||
|
return i;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virCommandSetPidFile:
|
* virCommandSetPidFile:
|
||||||
* @cmd: the command to modify
|
* @cmd: the command to modify
|
||||||
|
|
|
@ -62,6 +62,9 @@ void virCommandPassFD(virCommandPtr cmd,
|
||||||
|
|
||||||
void virCommandPassListenFDs(virCommandPtr cmd);
|
void virCommandPassListenFDs(virCommandPtr cmd);
|
||||||
|
|
||||||
|
int virCommandPassFDGetFDIndex(virCommandPtr cmd,
|
||||||
|
int fd);
|
||||||
|
|
||||||
void virCommandSetPidFile(virCommandPtr cmd,
|
void virCommandSetPidFile(virCommandPtr cmd,
|
||||||
const char *pidfile) ATTRIBUTE_NONNULL(2);
|
const char *pidfile) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue