On Tue, Jul 07, 2026 at 08:51:36AM +0200, Markus Armbruster wrote:
Daniel P. Berrangé <berrange@redhat.com> writes:
This introduces abstract QOM type "monitor", with concrete subtypes "monitor-hmp" and "monitor-qmp". This is the bare minimum conversion of just the type declarations and replacing g_new/g_free with object_new/object_unref.
Command line option "-monitor" now creates a "monitor-hmp" object "/objects/compat_monitorNNN" in addition to the character device "/chardevs/compat_monitorNNN". NNN counts up from zero.
Exception: "-monitor chardev:ID" creates a "monitor-hmp" object "/objects/ID", and does not create a character device.
"-qmp" and "-qmp-pretty" work the same, except they create a "monitor-qmp" object.
"-mon" now creates either a "monitor-hmp" or "monitor-qmp" object "/objects/ID" if the option argument provides an ID, else "/objects/compat_monitorNNN".
"-gdbstub" and "-serial mon:..." now create a "monitor-hmp" object "/objects/compat_monitorNNN".
Note that the object's name in "/objects/" matches the QemuOpts ID when it exists. The only cases where it doesn't exist are "-mon" without ID, "-gdbstub" and "-serial mon:".
A future patch will make "monitor-hmp" and "monitor-qmp" work with "-object" and "object-add".
Note: there is a slight change in the NNN values assigned. The old code would increment the counter for every monitor added, regardless of whether it needed a "compat_monitorNNN" ID assignment. Now it is only incremented when an automatic ID assigned is needed, from any of -mon, -gdbstub or -serial.
This isn't quite right. The old code increments the counter for every monitor added with monitor_parse(), i.e. the monitors added with -monitor, -qmp, -qmp-pretty, and most default monitors. -mon, -serial mon:..., and -gdbstub don't use monitor_parse().
If we don't need a respin (which seems likely), I can amend this to
Note: there is a slight change in the NNN values assigned. The old code would increment the counter for every monitor added (except for -mon, -serial mon:..., -gdbstub), regardless of whether it needed a "compat_monitorNNN" ID assignment. Now it is only incremented when an automatic ID assigned is needed (but even for -mon, -serial mon:..., -gdbstub).
Yep, that works for me.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|