[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v5 19/36] qemu_monitor: Make monitor callbacks optional



On Sun, Dec 02, 2018 at 23:10:13 -0600, Chris Venteicher wrote:
> 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 a65d638ab8..84065c59dc 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 1b6adf1b64..24945b1d17 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -8095,18 +8095,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,
> -};
> -
> -
>  /**
>   * qemuProcessQmpFree:
>   * @proc: Stores Process and Connection State
> @@ -8302,7 +8290,7 @@ qemuProcessQmpConnectMonitor(qemuProcessQmpPtr proc)
>      bool retry = true;
>      bool enableJson = true;
>      virQEMUDriverPtr driver = NULL;
> -    qemuMonitorCallbacksPtr monCallbacks = &callbacks;
> +    qemuMonitorCallbacksPtr monCallbacks = NULL;
>      virDomainXMLOptionPtr xmlopt = NULL;
>      virDomainChrSourceDef monConfig;

So qemuMonitorOpenInternal would not report an error anymore, but
qemuMonitorIO would just crash on error or eof. This doesn't sound like
a change in the right direction, does it?

Sure, we could make the code tolerant to NULL callbacks, but I think
it's actually better to require the callbacks than covering possible
programmer's errors.

Drop this patch, please.

Jirka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]