util: make virCommandSetSendBuffer testable

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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jonathon Jongsma 2022-09-29 16:12:55 -05:00
parent 3361cfd79e
commit f3942eece5
4 changed files with 22 additions and 8 deletions

View File

@ -2119,6 +2119,7 @@ virCommandNewArgs;
virCommandNewVAList;
virCommandNonblockingFDs;
virCommandPassFD;
virCommandPeekSendBuffers;
virCommandRawStatus;
virCommandRequireHandshake;
virCommandRun;

View File

@ -78,14 +78,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 */
@ -3514,3 +3506,12 @@ virCommandSetRunAmong(virCommand *cmd,
cmd->schedCore = pid;
}
void
virCommandPeekSendBuffers(virCommand *cmd,
virCommandSendBuffer **buffers,
int *nbuffers)
{
*buffers = cmd->sendBuffers;
*nbuffers = cmd->numSendBuffers;
}

View File

@ -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

View File

@ -47,3 +47,7 @@ void virCommandSetDryRun(virCommandDryRunToken *tok,
bool bufCommandStripPath,
virCommandDryRunCallback cb,
void *opaque);
void virCommandPeekSendBuffers(virCommand *cmd,
virCommandSendBuffer **buffers,
int *nbuffers);