]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemuxml2argvmock: Allow 'safe' file descriptors in mocked virCommandPassFD
authorPeter Krempa <pkrempa@redhat.com>
Tue, 14 Aug 2018 13:02:56 +0000 (15:02 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 24 Aug 2018 13:58:34 +0000 (15:58 +0200)
Allow FDs which are marked as safe for FD passing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
tests/qemuxml2argvmock.c

index 4df92cf3965bce77d36c02cc49d4b8f48ce38611..581f7202278eed7c464e10cd6790b3aba7db57d8 100644 (file)
@@ -184,12 +184,26 @@ virNetDevRunEthernetScript(const char *ifname ATTRIBUTE_UNUSED,
     return 0;
 }
 
+static void (*real_virCommandPassFD)(virCommandPtr cmd, int fd, unsigned int flags);
+
+static const int testCommandPassSafeFDs[] = { -1 };
+
 void
-virCommandPassFD(virCommandPtr cmd ATTRIBUTE_UNUSED,
-                 int fd ATTRIBUTE_UNUSED,
-                 unsigned int flags ATTRIBUTE_UNUSED)
+virCommandPassFD(virCommandPtr cmd,
+                 int fd,
+                 unsigned int flags)
 {
-    /* nada */
+    size_t i;
+
+    for (i = 0; i < ARRAY_CARDINALITY(testCommandPassSafeFDs); i++) {
+        if (testCommandPassSafeFDs[i] == fd) {
+            if (!real_virCommandPassFD)
+                VIR_MOCK_REAL_INIT(virCommandPassFD);
+
+            real_virCommandPassFD(cmd, fd, flags);
+            return;
+        }
+    }
 }
 
 int