@@ -23,6 +23,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp);
void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp);
int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp);
int monitor_init_opts(QemuOpts *opts, Error **errp);
+int monitor_chardev_name(QemuOpts *opts, char **name, Error **errp);
void monitor_cleanup(void);
int monitor_suspend(Monitor *mon);
@@ -777,6 +777,27 @@ int monitor_init_opts(QemuOpts *opts, Error **errp)
return ret;
}
+int monitor_chardev_name(QemuOpts *opts, char **namep, Error **errp)
+{
+ Visitor *v = opts_visitor_new(opts);
+ MonitorOptions *options;
+
+ visit_type_MonitorOptions(v, NULL, &options, errp);
+ visit_free(v);
+ if (!options) {
+ return -1;
+ }
+
+ if (options->chardev) {
+ *namep = g_strdup(options->chardev);
+ } else {
+ *namep = NULL;
+ }
+
+ qapi_free_MonitorOptions(options);
+ return 0;
+}
+
QemuOptsList qemu_mon_opts = {
.name = "mon",
.implied_opt_name = "chardev",
Define an accessor that returns the chardev name in monitor options. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- include/monitor/monitor.h | 1 + monitor/monitor.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+)