[libvirt] [PATCH v4 24/37] qemu_monitor: Make monitor callbacks optional

Chris Venteicher cventeic at redhat.com
Sat Nov 3 03:13:25 UTC 2018


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 at 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 4c0c2decf7..2071c6e846 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 9d3ce4eb6d..f545fc3b33 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8063,18 +8063,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




More information about the libvir-list mailing list