]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuhotplugmock: Mock fd passing to qemu via 'SCM_RIGHTS'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 14 Feb 2022 14:51:37 +0000 (15:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 15 Feb 2022 08:32:23 +0000 (09:32 +0100)
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>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor_priv.h
tests/qemuhotplugmock.c

index f514998ba5c6b612537a2d750cfa36df43321778..dc81e41783d41ea1cd1c5e36691229fce149b3db 100644 (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,
index 606aa79fbd4caab2a332262a6c23c226851971d8..70f5f16e7203d788e0f3df4079676cb637d06113 100644 (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;
index e3f071505857c221e3ec59a4b1e17ff93cc567e4..d618ff9d0634ab7dcab0efc14bacdb4164797587 100644 (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 */
+}