All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Christian Brauner <brauner@kernel.org>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Thomas Huth" <th.huth+qemu@posteo.eu>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v3 3/5] qapi: add monitor-add, monitor-remove, query-monitors commands
Date: Tue, 7 Apr 2026 11:45:53 +0100	[thread overview]
Message-ID: <adTgYYklczPVA40Q@redhat.com> (raw)
In-Reply-To: <20260407-work-qmp-monitor-hotplug-v3-3-cb259800fffb@kernel.org>

On Tue, Apr 07, 2026 at 09:32:47AM +0200, Christian Brauner wrote:
> Add QMP commands for dynamic monitor lifecycle management:
> 
> - monitor-add: Create a QMP monitor on an existing chardev at runtime.
>   The chardev must exist and not already have a frontend attached
>   (enforced by qemu_chr_fe_init()).  The new monitor starts in
>   capability negotiation mode.
> 
> - monitor-remove: Remove a dynamically-added monitor.  CLI-created
>   monitors cannot be removed.  The removal sequence is:

Why should we block removal of statically created monitors ? Our
normal approach is that the creation of objects via the command
line & QMP be indistinguishable.


> diff --git a/qapi/control.json b/qapi/control.json
> index 9a5302193d..fd58b57c31 100644
> --- a/qapi/control.json
> +++ b/qapi/control.json
> @@ -211,3 +211,107 @@
>        '*pretty': 'bool',
>        'chardev': 'str'
>    } }
> +
> +##
> +# @monitor-add:
> +#
> +# Add a QMP monitor on an existing character device backend.
> +#
> +# The chardev must already exist (created via chardev-add or CLI).
> +# The monitor begins in capability negotiation mode -- the first
> +# client to connect receives the QMP greeting.
> +#
> +# @id: Monitor identifier, must be unique among monitors
> +#
> +# @chardev: Name of the character device backend to attach to
> +#
> +# @pretty: Enable pretty-printing of QMP responses (default: false)
> +#
> +# Errors:
> +#     - GenericError if @id is already in use
> +#     - GenericError if @chardev does not exist
> +#
> +# Since: 11.0

We're just about to release 11.0, so 11.1 is the earliest
opportunity to merge anything now.

> +#
> +# .. qmp-example::
> +#
> +#     -> { "execute": "monitor-add",
> +#          "arguments": { "id": "extra-qmp",
> +#                         "chardev": "qmp-extra" } }
> +#     <- { "return": {} }
> +##
> +{ 'command': 'monitor-add',
> +  'data': { 'id': 'str',
> +            'chardev': 'str',
> +            '*pretty': 'bool' } }
> +
> +##
> +# @monitor-remove:
> +#
> +# Remove a dynamically added QMP monitor.
> +#
> +# The monitor must have been created via monitor-add.  Monitors
> +# created via CLI options (-mon, -qmp) cannot be removed.  The
> +# underlying chardev is NOT removed -- use chardev-remove separately
> +# if desired.
> +#
> +# If a client is currently connected, the connection is dropped.
> +#
> +# @id: Monitor identifier as passed to monitor-add
> +#
> +# Errors:
> +#     - GenericError if @id does not exist
> +#     - GenericError if the monitor was not dynamically added

I don't think we need to include "GenericError" in the description.
We've abandoned the idea of error classes in general, so everything
is GenericError  except for a bit of historical cruft.

> +#
> +# Since: 11.0
> +#
> +# .. qmp-example::
> +#
> +#     -> { "execute": "monitor-remove",
> +#          "arguments": { "id": "extra-qmp" } }
> +#     <- { "return": {} }
> +##
> +{ 'command': 'monitor-remove',
> +  'data': { 'id': 'str' } }
> +
> +##
> +# @MonitorInfo:
> +#
> +# Information about a QMP/HMP monitor.
> +#
> +# @id: Monitor identifier (absent for CLI-created monitors without
> +#     an explicit id)

We can't make 'id' mandatory for the existing arg without breaking
compat, but IMHO we should allocate an auto-generated 'id' if the
user omits it.

> +#
> +# @mode: Monitor mode (readline or control)
> +#
> +# @chardev: Name of the attached character device
> +#
> +# @dynamic: true if created via monitor-add (removable), false if
> +#     created via CLI
> +#
> +# Since: 11.0
> +##
> +{ 'struct': 'MonitorInfo',
> +  'data': { '*id': 'str',
> +            'mode': 'MonitorMode',
> +            'chardev': 'str',
> +            'dynamic': 'bool' } }
> +
> +##
> +# @query-monitors:
> +#
> +# Return information about all active monitors.
> +#
> +# Returns: a list of @MonitorInfo for each active monitor
> +#
> +# Since: 11.0
> +#
> +# .. qmp-example::
> +#
> +#     -> { "execute": "query-monitors" }
> +#     <- { "return": [ { "id": "mon0", "mode": "control",
> +#                         "chardev": "compat_monitor0",
> +#                         "dynamic": false } ] }
> +##
> +{ 'command': 'query-monitors',
> +  'returns': ['MonitorInfo'] }

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 :|



  reply	other threads:[~2026-04-07 19:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07  7:32 [PATCH v3 0/5] monitor: add dynamic QMP monitor hotplug support Christian Brauner
2026-04-07  7:32 ` [PATCH v3 1/5] monitor: store monitor id and dynamic flag in Monitor struct Christian Brauner
2026-04-07 10:39   ` Daniel P. Berrangé
2026-04-07 20:59     ` Christian Brauner
2026-04-07  7:32 ` [PATCH v3 2/5] monitor/qmp: add infrastructure for safe dynamic monitor removal Christian Brauner
2026-04-07  7:32 ` [PATCH v3 3/5] qapi: add monitor-add, monitor-remove, query-monitors commands Christian Brauner
2026-04-07 10:45   ` Daniel P. Berrangé [this message]
2026-04-07 20:59     ` Christian Brauner
2026-04-07  7:32 ` [PATCH v3 4/5] tests/qtest: add tests for dynamic monitor add/remove Christian Brauner
2026-04-07  7:32 ` [PATCH v3 5/5] tests/functional: add e2e test for dynamic QMP monitor hotplug Christian Brauner
2026-04-07 11:00 ` [PATCH v3 0/5] monitor: add dynamic QMP monitor hotplug support Daniel P. Berrangé
2026-04-07 20:57   ` Christian Brauner
2026-04-08  9:52     ` Daniel P. Berrangé
2026-04-08 20:27       ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adTgYYklczPVA40Q@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=brauner@kernel.org \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=th.huth+qemu@posteo.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.