monitor: Make MonitorQMP a child class of Monitor
commitb8e31d6ccc40de09392766fc8a77133196ba8468
authorKevin Wolf <kwolf@redhat.com>
Thu, 13 Jun 2019 15:33:53 +0000 (13 17:33 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 17 Jun 2019 18:36:56 +0000 (17 20:36 +0200)
tree4b8308888a317eb716efc94cb9b41e502f208601
parentb6c7c2e4a332a921f9172cf1857438ea6706ff41
monitor: Make MonitorQMP a child class of Monitor

Currently, struct Monitor mixes state that is only relevant for HMP,
state that is only relevant for QMP, and some actually shared state.
In particular, a MonitorQMP field is present in the state of any
monitor, even if it's not a QMP monitor and therefore doesn't use the
state.

As a first step towards a clean separation between QMP and HMP, let
MonitorQMP extend Monitor and create a MonitorQMP object only when the
monitor is actually a QMP monitor.

Some places accessed Monitor.qmp unconditionally, even for HMP monitors.
They can't keep doing this now, so during the conversion, they are
either changed to become conditional on monitor_is_qmp() or to assert()
that they always get a QMP monitor.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190613153405.24769-4-kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Superfluous variable in monitor_data_destroy() eliminated]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
monitor.c