[libvirt] [PATCH RFC 19/22] qemu_monitor: Make monitor callbacks optional

Chris Venteicher posted 22 patches 6 years ago
[libvirt] [PATCH RFC 19/22] qemu_monitor: Make monitor callbacks optional
Posted by Chris Venteicher 6 years ago
Qemu process code for capababilities doesn't use monitor callbacks and
defines empty callback functions.

Allow NULL to be passed to qemuMonitorOpen for callbacks and remove the
empty functions from the QMP process code.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
---
 src/qemu/qemu_monitor.c |  4 ++--
 src/qemu/qemu_process.c | 14 +-------------
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7f7013e115..77f4fe7cf7 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -813,12 +813,12 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
 {
     qemuMonitorPtr mon;
 
-    if (!cb->eofNotify) {
+    if (cb && !cb->eofNotify) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("EOF notify callback must be supplied"));
         return NULL;
     }
-    if (!cb->errorNotify) {
+    if (cb && !cb->errorNotify) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Error notify callback must be supplied"));
         return NULL;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c44e46fc88..d20f832053 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8066,18 +8066,6 @@ qemuProcessReconnectAll(virQEMUDriverPtr driver)
 }
 
 
-static void virQEMUCapsMonitorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-                                     virDomainObjPtr vm ATTRIBUTE_UNUSED,
-                                     void *opaque ATTRIBUTE_UNUSED)
-{
-}
-
-static qemuMonitorCallbacks callbacks = {
-    .eofNotify = virQEMUCapsMonitorNotify,
-    .errorNotify = virQEMUCapsMonitorNotify,
-};
-
-
 /**
  * qemuProcessFree:
  * @proc: Stores Process and Connection State
@@ -8270,7 +8258,7 @@ qemuConnectMonitorQmp(qemuProcessPtr proc)
     bool retry = true;
     bool enableJson = true;
     virQEMUDriverPtr driver = NULL;
-    qemuMonitorCallbacksPtr monCallbacks = &callbacks;
+    qemuMonitorCallbacksPtr monCallbacks = NULL;
     virDomainXMLOptionPtr xmlopt = NULL;
     virDomainChrSourceDef monConfig;
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list