[libvirt PATCH v4 21/31] util: make virCommandSetSendBuffer testable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a private function to peek at the list of send buffers in virCommand
so that it is testable

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/libvirt_private.syms  |  1 +
 src/util/vircommand.c     | 17 +++++++++--------
 src/util/vircommand.h     |  8 ++++++++
 src/util/vircommandpriv.h |  4 ++++
 4 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 576ec8f95f..94a1fb6f33 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2086,6 +2086,7 @@ virCommandNewArgs;
 virCommandNewVAList;
 virCommandNonblockingFDs;
 virCommandPassFD;
+virCommandPeekSendBuffers;
 virCommandRawStatus;
 virCommandRequireHandshake;
 virCommandRun;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 0917bc9cfb..e81b29669a 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -77,14 +77,6 @@ struct _virCommandFD {
     unsigned int flags;
 };
 
-typedef struct _virCommandSendBuffer virCommandSendBuffer;
-struct _virCommandSendBuffer {
-    int fd;
-    unsigned char *buffer;
-    size_t buflen;
-    off_t offset;
-};
-
 struct _virCommand {
     int has_error; /* 0 on success, -1 on error  */
 
@@ -3452,3 +3444,12 @@ virCommandSetRunAmong(virCommand *cmd,
 
     cmd->schedCore = pid;
 }
+
+void
+virCommandPeekSendBuffers(virCommand *cmd,
+                          virCommandSendBuffer **buffers,
+                          int *nbuffers)
+{
+    *buffers = cmd->sendBuffers;
+    *nbuffers = cmd->numSendBuffers;
+}
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index e0002103b6..0f14d14e49 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -24,6 +24,14 @@
 #include "internal.h"
 #include "virbuffer.h"
 
+typedef struct _virCommandSendBuffer virCommandSendBuffer;
+struct _virCommandSendBuffer {
+    int fd;
+    unsigned char *buffer;
+    size_t buflen;
+    off_t offset;
+};
+
 typedef struct _virCommand virCommand;
 
 /* This will execute in the context of the first child
diff --git a/src/util/vircommandpriv.h b/src/util/vircommandpriv.h
index ff17fa5ded..d579810bb5 100644
--- a/src/util/vircommandpriv.h
+++ b/src/util/vircommandpriv.h
@@ -47,3 +47,7 @@ void virCommandSetDryRun(virCommandDryRunToken *tok,
                          bool bufCommandStripPath,
                          virCommandDryRunCallback cb,
                          void *opaque);
+
+void virCommandPeekSendBuffers(virCommand *cmd,
+                               virCommandSendBuffer **buffers,
+                               int *nbuffers);
-- 
2.39.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux