qemuhotplugmock: Mock fd passing to qemu via 'SCM_RIGHTS'

We don't want to be dealing with real FDs thus we mock
'qemuMonitorIOWriteWithFD' to do the same thing as when no FD is being
passed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-02-14 15:51:37 +01:00
parent 654486bd57
commit 5b5162072c
3 changed files with 22 additions and 1 deletions

View File

@ -288,7 +288,7 @@ qemuMonitorIOProcess(qemuMonitor *mon)
/* Call this function while holding the monitor lock. */
static int
int
qemuMonitorIOWriteWithFD(qemuMonitor *mon,
const char *data,
size_t len,

View File

@ -96,3 +96,10 @@ struct _qemuMonitor {
void
qemuMonitorResetCommandID(qemuMonitor *mon);
int
qemuMonitorIOWriteWithFD(qemuMonitor *mon,
const char *data,
size_t len,
int fd)
G_GNUC_NO_INLINE;

View File

@ -28,6 +28,9 @@
#include "virmock.h"
#include <fcntl.h>
#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW
#include "qemu/qemu_monitor_priv.h"
static bool (*real_virFileExists)(const char *path);
static void
@ -107,3 +110,14 @@ qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm,
testQemuPrepareHostBackendChardevOne,
vm);
}
/* we don't really want to send fake FDs across the monitor */
int
qemuMonitorIOWriteWithFD(qemuMonitor *mon,
const char *data,
size_t len,
int fd G_GNUC_UNUSED)
{
return write(mon->fd, data, len); /* sc_avoid_write */
}