[libvirt PATCH 0/2] Minor fd passing fixes

Following up Peter's series, here's a couple additional minor cleanups that simply remove some unused functions related to fd passing. Jonathon Jongsma (2): util: remove virCommandPassFDGetFDIndex() util: Remove virCommandPassFDIndex() src/libvirt_private.syms | 2 -- src/util/vircommand.c | 55 ++-------------------------------------- src/util/vircommand.h | 3 --- 3 files changed, 2 insertions(+), 58 deletions(-) -- 2.35.3

commit f9236200 removed the last use of this function, so it can be dropped. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/libvirt_private.syms | 1 - src/util/vircommand.c | 27 --------------------------- src/util/vircommand.h | 3 --- 3 files changed, 31 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9309259751..66f73e84aa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2057,7 +2057,6 @@ virCommandNewArgs; virCommandNewVAList; virCommandNonblockingFDs; virCommandPassFD; -virCommandPassFDGetFDIndex; virCommandPassFDIndex; virCommandRawStatus; virCommandRequireHandshake; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 41cf552d7b..f3c26a2673 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1077,33 +1077,6 @@ virCommandPassFD(virCommand *cmd, int fd, unsigned int flags) virCommandPassFDIndex(cmd, fd, flags, NULL); } -/* - * 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(virCommand *cmd, int fd) -{ - size_t i = 0; - - if (virCommandHasError(cmd)) - return -1; - - while (i < cmd->npassfd) { - if (cmd->passfd[i].fd == fd) - return i; - i++; - } - - return -1; -} - /** * virCommandSetPidFile: * @cmd: the command to modify diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 600806a987..c534a9bb16 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -61,9 +61,6 @@ void virCommandPassFDIndex(virCommand *cmd, unsigned int flags, size_t *idx) G_GNUC_NO_INLINE; -int virCommandPassFDGetFDIndex(virCommand *cmd, - int fd); - void virCommandSetPidFile(virCommand *cmd, const char *pidfile) ATTRIBUTE_NONNULL(2); -- 2.35.3

On Fri, May 13, 2022 at 14:32:41 -0500, Jonathon Jongsma wrote:
commit f9236200 removed the last use of this function, so it can be dropped.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/libvirt_private.syms | 1 - src/util/vircommand.c | 27 --------------------------- src/util/vircommand.h | 3 --- 3 files changed, 31 deletions(-)
Reviewed-by: Peter Krempa <pkrempa@redhat.com>

The last use of this function was removed in commit 6d161bcc, so the function is no longer used except as an internal implementation for virCommandPassFD(). Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/libvirt_private.syms | 1 - src/util/vircommand.c | 28 ++-------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 66f73e84aa..d95c181793 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2057,7 +2057,6 @@ virCommandNewArgs; virCommandNewVAList; virCommandNonblockingFDs; virCommandPassFD; -virCommandPassFDIndex; virCommandRawStatus; virCommandRequireHandshake; virCommandRun; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index f3c26a2673..d78c666f28 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1021,11 +1021,10 @@ virCommandNewVAList(const char *binary, va_list list) VIR_FORCE_CLOSE(fd) /** - * virCommandPassFDIndex: + * virCommandPassFD: * @cmd: the command to modify * @fd: fd to reassign to the child * @flags: extra flags; binary-OR of virCommandPassFDFlags - * @idx: pointer to fill with the index of the FD in the transfer set * * Transfer the specified file descriptor to the child, instead * of closing it on exec. @fd must not be one of the three @@ -1036,7 +1035,7 @@ virCommandNewVAList(const char *binary, va_list list) * should cease using the @fd when this call completes */ void -virCommandPassFDIndex(virCommand *cmd, int fd, unsigned int flags, size_t *idx) +virCommandPassFD(virCommand *cmd, int fd, unsigned int flags) { if (!cmd) { VIR_COMMAND_MAYBE_CLOSE_FD(fd, flags); @@ -1052,29 +1051,6 @@ virCommandPassFDIndex(virCommand *cmd, int fd, unsigned int flags, size_t *idx) } virCommandFDSet(cmd, fd, flags); - - if (idx) - *idx = cmd->npassfd - 1; -} - -/** - * virCommandPassFD: - * @cmd: the command to modify - * @fd: fd to reassign to the child - * @flags: extra flags; binary-OR of virCommandPassFDFlags - * - * Transfer the specified file descriptor to the child, instead - * of closing it on exec. @fd must not be one of the three - * standard streams. - * - * If the flag VIR_COMMAND_PASS_FD_CLOSE_PARENT is set then fd will - * be closed in the parent no later than Run/RunAsync/Free. The parent - * should cease using the @fd when this call completes - */ -void -virCommandPassFD(virCommand *cmd, int fd, unsigned int flags) -{ - virCommandPassFDIndex(cmd, fd, flags, NULL); } /** -- 2.35.3

On Fri, May 13, 2022 at 14:32:42 -0500, Jonathon Jongsma wrote:
The last use of this function was removed in commit 6d161bcc, so the function is no longer used except as an internal implementation for virCommandPassFD().
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/libvirt_private.syms | 1 - src/util/vircommand.c | 28 ++-------------------------- 2 files changed, 2 insertions(+), 27 deletions(-)
You also need to remove the declaration from vircommand.h, with that: Reviewed-by: Peter Krempa <pkrempa@redhat.com>
participants (2)
-
Jonathon Jongsma
-
Peter Krempa