]> xenbits.xensource.com Git - libvirt.git/commitdiff
Allow the iohelper path to be customized by test programs
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 10 May 2013 17:12:20 +0000 (18:12 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 10 May 2013 18:57:18 +0000 (19:57 +0100)
Currently the fdstream function hardcodes the location
of the iohelper to LIBEXECDIR "/libvirt_iohelper". This
is not convenient when trying to write test cases which
use this code. Add a virFDStreamSetIOHelper method to
allow the test cases to point to the location of the
un-installed iohelper binary.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/fdstream.c
src/fdstream.h
src/libvirt_private.syms

index a9a4851dd348665a4ca86f78ade2c114d18af8d2..d5e5aafcb5334fc08d8257e516b6714fd38d5756 100644 (file)
@@ -74,6 +74,18 @@ struct virFDStreamData {
     virMutex lock;
 };
 
+
+static const char *iohelper_path = LIBEXECDIR "/libvirt_iohelper";
+
+void virFDStreamSetIOHelper(const char *path)
+{
+    if (path == NULL)
+        iohelper_path = LIBEXECDIR "/libvirt_iohelper";
+    else
+        iohelper_path = path;
+}
+
+
 static int virFDStreamRemoveCallback(virStreamPtr stream)
 {
     struct virFDStreamData *fdst = stream->privateData;
@@ -634,7 +646,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
             goto error;
         }
 
-        cmd = virCommandNewArgList(LIBEXECDIR "/libvirt_iohelper",
+        cmd = virCommandNewArgList(iohelper_path,
                                    path,
                                    NULL);
         virCommandAddArgFormat(cmd, "%llu", length);
index d6f5a7a104bbfd0b38665b0b7292284153d915e8..3ca6256ca8eb8dd8fdfc574179fbc129373b51f9 100644 (file)
@@ -33,6 +33,9 @@ typedef void (*virFDStreamInternalCloseCb)(virStreamPtr st, void *opaque);
 typedef void (*virFDStreamInternalCloseCbFreeOpaque)(void *opaque);
 
 
+/* Only for use by test suite */
+void virFDStreamSetIOHelper(const char *path);
+
 int virFDStreamOpen(virStreamPtr st,
                     int fd);
 
index 2d7fe5b40f4b2b28648d0da6c5fe1ee954b0ce00..ef65a8be38e782c454c0791f83bc2bdbd4ceb42d 100644 (file)
@@ -699,6 +699,7 @@ virFDStreamConnectUNIX;
 virFDStreamCreateFile;
 virFDStreamOpen;
 virFDStreamOpenFile;
+virFDStreamSetIOHelper;
 
 
 # libvirt_internal.h