monitor: reject readline monitor when HMP is disabled
When QEMU is built without HMP support, reject '-monitor' (which requests readline/HMP mode) early in monitor_new_opts() with a clear error message directing users to '-qmp' instead. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org> Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-27-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
f32f9067cf47e49d1e8ebb89ec97741eb8b01954
1 file changed
+10
monitor/monitor.c
+10
@@ -776,6 +776,16 @@ int monitor_new_opts(QemuOpts *opts, Error **errp)
776
MonitorOptions *options;
777
int ret;
778
779
+#ifndef CONFIG_HMP
780
+ const char *mode = qemu_opt_get(opts, "mode");
781
+ /* readline is HMP.. */
782
+ if (mode && g_str_equal(mode, "readline")) {
783
+ error_setg(errp, "HMP monitor is not available,"
784
+ " use '-qmp' instead of '-monitor'");
785
+ return -1;
786
+ }
787
+#endif
788
+
789
v = opts_visitor_new(opts);
790
visit_type_MonitorOptions(v, NULL, &options, errp);
791
visit_free(v);