All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Shu <jim.shu@sifive.com>
To: Damien Hedde <damien.hedde@greensocs.com>
Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	mark.burton@greensocs.com, edgari@xilinx.com,
	"Mirela Grujic" <mirela.grujic@greensocs.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>
Subject: Re: [PATCH v5 6/6] qapi/device_add: Allow execution in machine initialized phase
Date: Wed, 25 May 2022 03:58:51 +0800	[thread overview]
Message-ID: <CALw707rknU=HTUMNk6Q4Bsa=sM+04VncE=zKspvhFtx6zJyyOg@mail.gmail.com> (raw)
In-Reply-To: <20220519153402.41540-7-damien.hedde@greensocs.com>

[-- Attachment #1: Type: text/plain, Size: 2987 bytes --]

Tested-by: Jim Shu <jim.shu@sifive.com>

On Thu, May 19, 2022 at 11:37 PM Damien Hedde <damien.hedde@greensocs.com>
wrote:

> From: Mirela Grujic <mirela.grujic@greensocs.com>
>
> This commit allows to use the QMP command to add a cold-plugged
> device like we can do with the CLI option -device.
>
> Note: for device_add command in qdev.json adding the 'allow-preconfig'
> option has no effect because the command appears to bypass QAPI (see
> TODO at qapi/qdev.json:61). The option is added there solely to
> document the intent.
> For the same reason, the flags have to be explicitly set in
> monitor_init_qmp_commands() when the device_add command is registered.
>
> Signed-off-by: Mirela Grujic <mirela.grujic@greensocs.com>
> Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
> ---
>
> v4:
>  + use phase_until()
>  + add missing flag in hmp-commands.hx
> ---
>  qapi/qdev.json         | 3 ++-
>  monitor/misc.c         | 2 +-
>  softmmu/qdev-monitor.c | 4 ++++
>  hmp-commands.hx        | 1 +
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/qapi/qdev.json b/qapi/qdev.json
> index 26cd10106b..2e2de41499 100644
> --- a/qapi/qdev.json
> +++ b/qapi/qdev.json
> @@ -77,7 +77,8 @@
>  { 'command': 'device_add',
>    'data': {'driver': 'str', '*bus': 'str', '*id': 'str'},
>    'gen': false, # so we can get the additional arguments
> -  'features': ['json-cli', 'json-cli-hotplug'] }
> +  'features': ['json-cli', 'json-cli-hotplug'],
> +  'allow-preconfig': true }
>
>  ##
>  # @device_del:
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 6c5bb82d3b..d3d413d70c 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -233,7 +233,7 @@ static void monitor_init_qmp_commands(void)
>      qmp_init_marshal(&qmp_commands);
>
>      qmp_register_command(&qmp_commands, "device_add",
> -                         qmp_device_add, 0, 0);
> +                         qmp_device_add, QCO_ALLOW_PRECONFIG, 0);
>
>      QTAILQ_INIT(&qmp_cap_negotiation_commands);
>      qmp_register_command(&qmp_cap_negotiation_commands,
> "qmp_capabilities",
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 7cbee2b0d8..c53f62be51 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -855,6 +855,10 @@ void qmp_device_add(QDict *qdict, QObject **ret_data,
> Error **errp)
>      QemuOpts *opts;
>      DeviceState *dev;
>
> +    if (!phase_until(PHASE_MACHINE_INITIALIZED, errp)) {
> +        return;
> +    }
> +
>      opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, errp);
>      if (!opts) {
>          return;
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 03e6a73d1f..0091b8e2dd 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -672,6 +672,7 @@ ERST
>          .help       = "add device, like -device on the command line",
>          .cmd        = hmp_device_add,
>          .command_completion = device_add_completion,
> +        .flags      = "p",
>      },
>
>  SRST
> --
> 2.36.1
>
>
>

[-- Attachment #2: Type: text/html, Size: 4148 bytes --]

      reply	other threads:[~2022-05-24 20:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 15:33 [PATCH v5 0/6] QAPI support for device cold-plug Damien Hedde
2022-05-19 15:33 ` [PATCH v5 1/6] machine: add phase_get() and document phase_check()/advance() Damien Hedde
2022-05-24 19:56   ` Jim Shu
2022-05-19 15:33 ` [PATCH v5 2/6] machine&vl: introduce phase_until() to handle phase transitions Damien Hedde
2022-05-24 19:56   ` Jim Shu
2022-05-19 15:33 ` [PATCH v5 3/6] vl: support machine-initialized target in phase_until() Damien Hedde
2022-05-24 19:56   ` Jim Shu
2022-05-19 15:34 ` [PATCH v5 4/6] qapi/device_add: compute is_hotplug flag Damien Hedde
2022-05-24 19:57   ` Jim Shu
2022-05-19 15:34 ` [PATCH v5 5/6] RFC qapi/device_add: handle the rom_order_override when cold-plugging Damien Hedde
2022-05-19 15:34 ` [PATCH v5 6/6] qapi/device_add: Allow execution in machine initialized phase Damien Hedde
2022-05-24 19:58   ` Jim Shu [this message]

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='CALw707rknU=HTUMNk6Q4Bsa=sM+04VncE=zKspvhFtx6zJyyOg@mail.gmail.com' \
    --to=jim.shu@sifive.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=damien.hedde@greensocs.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=edgari@xilinx.com \
    --cc=eduardo@habkost.net \
    --cc=mark.burton@greensocs.com \
    --cc=mirela.grujic@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.