]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Add possibility to reset command sequence in tests
authorPeter Krempa <pkrempa@redhat.com>
Fri, 4 May 2018 14:26:08 +0000 (16:26 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Jun 2018 08:27:49 +0000 (10:27 +0200)
qemucapabilitiestest for simplicity uses one test monitor object for
simulating work of two separate inquiries of the qemu process. To allow
better testing in the future it will be required to reset the counter
so that it accurately simulates how qemu would behave.

This patch adds a private monitor API which allows to reset the counter
which will be usable only in tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor_priv.h [new file with mode: 0644]

index 6e0cdca85d781836a737f3fb3686f19804b98f4e..b29672d4f19bad7ca718b41f9bfa12a4c24af115 100644 (file)
@@ -48,6 +48,9 @@
 # include "libvirt_qemu_probes.h"
 #endif
 
+#define __QEMU_MONITOR_PRIV_H_ALLOW__
+#include "qemu_monitor_priv.h"
+
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
 VIR_LOG_INIT("qemu.qemu_monitor");
@@ -1046,6 +1049,14 @@ qemuMonitorNextCommandID(qemuMonitorPtr mon)
 }
 
 
+/* for use only in the test suite */
+void
+qemuMonitorResetCommandID(qemuMonitorPtr mon)
+{
+    mon->nextSerial = 0;
+}
+
+
 int
 qemuMonitorSend(qemuMonitorPtr mon,
                 qemuMonitorMessagePtr msg)
diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h
new file mode 100644 (file)
index 0000000..45bda27
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * qemu_monitor_priv.h: interaction with QEMU monitor console (private)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __QEMU_MONITOR_PRIV_H_ALLOW__
+# error "qemu_monitor_priv.h may only be included by qemu_monitor.c or test suites"
+#endif
+
+#ifndef __QEMU_MONITOR_PRIV_H__
+# define __QEMU_MONITOR_PRIV_H__
+
+# include "qemu_monitor.h"
+
+void
+qemuMonitorResetCommandID(qemuMonitorPtr mon);
+
+#endif