On 02/24/2015 08:34 AM, Martin Kletzander wrote:
On Mon, Feb 23, 2015 at 06:50:46AM -0500, Stefan Berger wrote:
Implement virCommandPassFDGetFDIndex to determine the index a given
file descriptor will have when passed to the child process. When this
function is called, a flag is set to prevent the reordering of the
file descriptors.

Signed-off-by: Stefan Berger <stef...@linux.vnet.ibm.com>
---
src/libvirt_private.syms |  1 +
src/util/vircommand.c    | 33 +++++++++++++++++++++++++++++++++
src/util/vircommand.h    |  3 +++
3 files changed, 37 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c156b40..aadb833 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1213,6 +1213,7 @@ virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPassFD;
+virCommandPassFDGetFDIndex;
virCommandPassListenFDs;
virCommandRawStatus;
virCommandRequireHandshake;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 6527d85..2616446 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -67,6 +67,7 @@ enum {
    VIR_EXEC_RUN_SYNC   = (1 << 3),
    VIR_EXEC_ASYNC_IO   = (1 << 4),
    VIR_EXEC_LISTEN_FDS = (1 << 5),
+    VIR_EXEC_FIXED_FDS  = (1 << 6),

The descriptors shouldn't get reordered *unless* there is
VIR_EXEC_LISTEN_FDS flag added, so FIXED_FDS shouldn't be necessary.
Or is there a bug in that approach that needs fixing?

Hm, it depends on the order in which APIs are called where we either need to protect against re-ordering (if we use indices) or we cannot allow indices to be used if we need to reorder them. So, actually the way the patch is, it isn't correct, either.

The problem of having to prevent the reordering of file descriptors when we are building the QEMU command line with file descriptors already exists today. So maybe I could just remove this flag and the related check knowing that reordering of file descriptors and building the QEMU command line that contains file descriptor (from before the order) would not be allowed today without any of the patches I am trying to add.

    Stefan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to