Skip to content

Commit

Permalink
monitor: Create MonitorHMP with readline state
Browse files Browse the repository at this point in the history
The ReadLineState in Monitor is only used for HMP monitors. Create
MonitorHMP and move it there.

Can't use container_of() in hmp_change().  Cast instead, and mark
FIXME.  Will be cleaned up shortly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190613153405.24769-5-kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Superfluous variable in monitor_data_destroy() eliminated, whitespace
tweaked in hmp_change(), commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
  • Loading branch information
kevmw authored and Markus Armbruster committed Jun 17, 2019
1 parent b8e31d6 commit 5f9dba1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 58 deletions.
4 changes: 3 additions & 1 deletion hmp.c
Expand Up @@ -1943,6 +1943,8 @@ static void hmp_change_read_arg(void *opaque, const char *password,

void hmp_change(Monitor *mon, const QDict *qdict)
{
/* FIXME Make MonitorHMP public and use container_of */
MonitorHMP *hmp_mon = (MonitorHMP *)mon;
const char *device = qdict_get_str(qdict, "device");
const char *target = qdict_get_str(qdict, "target");
const char *arg = qdict_get_try_str(qdict, "arg");
Expand All @@ -1960,7 +1962,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
if (strcmp(target, "passwd") == 0 ||
strcmp(target, "password") == 0) {
if (!arg) {
monitor_read_password(mon, hmp_change_read_arg, NULL);
monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
return;
}
}
Expand Down
5 changes: 3 additions & 2 deletions include/monitor/monitor.h
Expand Up @@ -6,6 +6,7 @@
#include "qemu/readline.h"

extern __thread Monitor *cur_mon;
typedef struct MonitorHMP MonitorHMP;

/* flags for monitor_init */
/* 0x01 unused */
Expand Down Expand Up @@ -34,8 +35,8 @@ void monitor_flush(Monitor *mon);
int monitor_set_cpu(int cpu_index);
int monitor_get_cpu_index(void);

void monitor_read_command(Monitor *mon, int show_prompt);
int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
void monitor_read_command(MonitorHMP *mon, int show_prompt);
int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
void *opaque);

AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
Expand Down

0 comments on commit 5f9dba1

Please sign in to comment.