All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Mirela Grujic <mirela.grujic@greensocs.com>
Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com,
	Eduardo Habkost <ehabkost@redhat.com>,
	mark.burton@greensocs.com, qemu-devel@nongnu.org,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [RFC PATCH 6/9] qapi: Implement 'advance-machine-phase' command
Date: Wed, 19 May 2021 17:37:22 +0200	[thread overview]
Message-ID: <YKUwstsbx4DS7pj3@merkur.fritz.box> (raw)
In-Reply-To: <20210513082549.114275-7-mirela.grujic@greensocs.com>

Am 13.05.2021 um 10:25 hat Mirela Grujic geschrieben:
> The command takes the target initialization phase as the argument
> and triggers QEMU to advance the machine to the target phase (i.e.
> execute all initialization steps required to enter the target phase).
> 
> This command would be used as an alternative to 'next-machine-phase'
> if it's more convenient to jump to a target initialization phase than
> to single-step through phases.
> 
> The command is used in combination with the -preconfig CLI option.
> 
> Note: advancing the machine to the 'ready' phase has the same effect as
> executing the 'x-exit-preconfig' command when the machine is in
> 'accel-created' phase.
> 
> Signed-off-by: Mirela Grujic <mirela.grujic@greensocs.com>

I think this command is preferable, not just because it is more
convenient if you don't have anything to do in some phase, but also
because it is more explicit and doesn't change its behaviour depending
on the current state.

We probably need to expect that this is a command that might often be
used in quickly hacked up shell scripts, which are error prone (Did I
really count the number of 'next-machine-phase' command right? Which
phase are we switching to again in this line?) and may lack proper error
handling, so the least amount of implicit magic will make sure that
users don't get more surprises than necessary.

> diff --git a/qapi/machine.json b/qapi/machine.json
> index 968d67dd95..31872aae72 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1352,3 +1352,29 @@
>  #
>  ##
>  { 'command': 'next-machine-phase', 'allow-preconfig': true }
> +
> +##
> +# @advance-machine-phase:
> +#
> +# Advance machine initialization phase to the target phase
> +#
> +# @phase: target machine initialization phase
> +#
> +# Since: #FIXME
> +#
> +# Returns: If successful, nothing
> +#
> +# Notes: This command will trigger QEMU to execute initialization steps
> +#        that are required to enter the target machine initialization phase.
> +#        If the target phase is the final initialization phase, the guest will
> +#        start running immediately unless the -S option is used. The command
> +#        is available only if the -preconfig command line option was passed.
> +#
> +# Example:
> +#
> +# -> { "execute": "advance-machine-phase", "arguments": { "phase": "ready" } }
> +# <- { "return": {} }
> +#
> +##
> +{ 'command': 'advance-machine-phase', 'data' : {'phase': 'MachineInitPhase'},
> +             'allow-preconfig': true }
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index 8aa743d59b..6b21a3fdd5 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -219,3 +219,13 @@ void qmp_next_machine_phase(Error **errp)
>  
>      qemu_machine_enter_phase(target_phase, errp);
>  }
> +
> +void qmp_advance_machine_phase(MachineInitPhase phase, Error **errp)
> +{
> +    if (phase_get() == phase) {
> +        error_setg(errp, "Machine is already in the target phase");
> +        return;
> +    }

Another option would be making it set-machine-phase, which doesn't fail
if you're setting the phase that you're already in. It would only fail
if you're trying to go backwards. But this is a minor detail.

> +    qemu_machine_enter_phase(phase, errp);
> +}

Kevin



  reply	other threads:[~2021-05-19 15:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13  8:25 [RFC PATCH 0/9] Initial support for machine creation via QMP Mirela Grujic
2021-05-13  8:25 ` [RFC PATCH 1/9] vl: Allow finer control in advancing machine through phases Mirela Grujic
2021-05-13  8:25 ` [RFC PATCH 2/9] replace machine phase_check with machine_is_initialized/ready calls Mirela Grujic
2021-05-13 17:46   ` Paolo Bonzini
2021-05-14 13:13     ` Mirela Grujic
2021-05-14 21:14       ` Paolo Bonzini
2021-06-07 16:03         ` Eric Blake
2021-05-13  8:25 ` [RFC PATCH 3/9] rename MachineInitPhase enumeration constants Mirela Grujic
2021-05-13  8:25 ` [RFC PATCH 4/9] qapi: Implement 'query-machine-phase' command Mirela Grujic
2021-05-13 17:44   ` Paolo Bonzini
2021-05-19 15:43     ` Daniel P. Berrangé
2021-05-13  8:25 ` [RFC PATCH 5/9] qapi: Implement 'next-machine-phase' command Mirela Grujic
2021-06-04 14:25   ` Eric Blake
2021-06-05 14:40     ` Paolo Bonzini
2021-05-13  8:25 ` [RFC PATCH 6/9] qapi: Implement 'advance-machine-phase' command Mirela Grujic
2021-05-19 15:37   ` Kevin Wolf [this message]
2021-05-13  8:25 ` [RFC PATCH 7/9] qdev-monitor: Restructure and fix the check for command availability Mirela Grujic
2021-05-13 17:43   ` Paolo Bonzini
2021-05-14 13:00     ` Mirela Grujic
2021-05-13  8:25 ` [RFC PATCH 8/9] qapi: Introduce 'allow-init-config' option Mirela Grujic
2021-05-13  8:25 ` [RFC PATCH 9/9] qapi: Allow some commands to be executed in machine 'initialized' phase Mirela Grujic
2021-05-13 17:52 ` [RFC PATCH 0/9] Initial support for machine creation via QMP Paolo Bonzini
2021-05-14 12:48   ` Mirela Grujic
2021-05-14 16:00     ` Paolo Bonzini
2021-05-14 16:20       ` Daniel P. Berrangé
2021-05-14 18:32         ` Paolo Bonzini
2021-05-24 17:20           ` Igor Mammedov
2021-05-24 19:05             ` Igor Mammedov
2021-05-21 11:32   ` Markus Armbruster
2021-05-21 17:02     ` Paolo Bonzini
2021-05-21 14:06   ` Mirela Grujic
2021-05-21 16:57     ` Paolo Bonzini
2021-05-24 18:27       ` Igor Mammedov

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=YKUwstsbx4DS7pj3@merkur.fritz.box \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=damien.hedde@greensocs.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=ehabkost@redhat.com \
    --cc=mark.burton@greensocs.com \
    --cc=mirela.grujic@greensocs.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.