All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 02/15] vl: remove separate preconfig main_loop
Date: Mon, 7 Dec 2020 15:02:18 +0100	[thread overview]
Message-ID: <20201207150218.2df0dc3b@redhat.com> (raw)
In-Reply-To: <20201202081854.4126071-3-pbonzini@redhat.com>

On Wed,  2 Dec 2020 03:18:41 -0500
Paolo Bonzini <pbonzini@redhat.com> wrote:

> Move post-preconfig initialization to the x-exit-preconfig.  If preconfig
> is not requested, just exit preconfig mode immediately with the QMP
> command.
> 
> As a result, the preconfig loop will run with accel_setup_post
> and os_setup_post restrictions (xen_restrict, chroot, etc.)
> already done.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/sysemu/runstate.h |  1 -
>  monitor/qmp-cmds.c        |  9 ----
>  softmmu/vl.c              | 95 +++++++++++++++++----------------------
>  3 files changed, 41 insertions(+), 64 deletions(-)
> 
> diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h
> index f760094858..e557f470d4 100644
> --- a/include/sysemu/runstate.h
> +++ b/include/sysemu/runstate.h
> @@ -41,7 +41,6 @@ typedef enum WakeupReason {
>      QEMU_WAKEUP_REASON_OTHER,
>  } WakeupReason;
>  
> -void qemu_exit_preconfig_request(void);
>  void qemu_system_reset_request(ShutdownCause reason);
>  void qemu_system_suspend_request(void);
>  void qemu_register_suspend_notifier(Notifier *notifier);
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index 501a3024c7..7ced7eb3e8 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -102,15 +102,6 @@ void qmp_system_powerdown(Error **errp)
>      qemu_system_powerdown_request();
>  }
>  
> -void qmp_x_exit_preconfig(Error **errp)
> -{
> -    if (qdev_hotplug) {
> -        error_setg(errp, "The command is permitted only before machine initialization");
> -        return;
> -    }
> -    qemu_exit_preconfig_request();
> -}
> -
>  void qmp_cont(Error **errp)
>  {
>      BlockBackend *blk;
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index ab2210bc79..abbbb83e1a 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -1151,7 +1151,6 @@ static pid_t shutdown_pid;
>  static int powerdown_requested;
>  static int debug_requested;
>  static int suspend_requested;
> -static bool preconfig_exit_requested = true;
>  static WakeupReason wakeup_reason;
>  static NotifierList powerdown_notifiers =
>      NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
> @@ -1238,11 +1237,6 @@ static int qemu_debug_requested(void)
>      return r;
>  }
>  
> -void qemu_exit_preconfig_request(void)
> -{
> -    preconfig_exit_requested = true;
> -}
> -
>  /*
>   * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE.
>   */
> @@ -1464,10 +1458,6 @@ static bool main_loop_should_exit(void)
>      RunState r;
>      ShutdownCause request;
>  
> -    if (preconfig_exit_requested) {
> -        preconfig_exit_requested = false;
> -        return true;
> -    }
>      if (qemu_debug_requested()) {
>          vm_stop(RUN_STATE_DEBUG);
>      }
> @@ -3283,6 +3273,43 @@ static void qemu_machine_creation_done(void)
>      register_global_state();
>  }
>  
> +void qmp_x_exit_preconfig(Error **errp)
> +{
> +    if (qdev_hotplug) {
> +        error_setg(errp, "The command is permitted only before machine initialization");
> +        return;
> +    }
> +
> +    qemu_init_board();
> +    qemu_create_cli_devices();
> +    qemu_machine_creation_done();
> +
> +    if (loadvm) {
> +        Error *local_err = NULL;
> +        if (load_snapshot(loadvm, &local_err) < 0) {
> +            error_report_err(local_err);
> +            autostart = 0;
> +            exit(1);
> +        }
> +    }
> +    if (replay_mode != REPLAY_MODE_NONE) {
> +        replay_vmstate_init();
> +    }
> +
> +    if (incoming) {
> +        Error *local_err = NULL;
> +        if (strcmp(incoming, "defer") != 0) {
> +            qmp_migrate_incoming(incoming, &local_err);
> +            if (local_err) {
> +                error_reportf_err(local_err, "-incoming %s: ", incoming);
> +                exit(1);
> +            }
> +        }
> +    } else if (autostart) {
> +        qmp_cont(NULL);
> +    }
> +}
> +
>  void qemu_init(int argc, char **argv, char **envp)
>  {
>      QemuOpts *opts;
> @@ -3847,7 +3874,6 @@ void qemu_init(int argc, char **argv, char **envp)
>                  }
>                  break;
>              case QEMU_OPTION_preconfig:
> -                preconfig_exit_requested = false;
>                  preconfig_requested = true;
>                  break;
>              case QEMU_OPTION_enable_kvm:
> @@ -4272,57 +4298,18 @@ void qemu_init(int argc, char **argv, char **envp)
>      qemu_resolve_machine_memdev();
>      parse_numa_opts(current_machine);
>  
> -    if (preconfig_requested) {
> -        qemu_init_displays();
> -    }
> -
> -    /* do monitor/qmp handling at preconfig state if requested */
> -    qemu_main_loop();
> -
> -    qemu_init_board();
> -
> -    qemu_create_cli_devices();
> -
> -    /* initialize displays after all errors have been reported */
> -    if (!preconfig_requested) {
> -        qemu_init_displays();
> -    }
> -    qemu_machine_creation_done();
> -
> -    if (loadvm) {
> -        Error *local_err = NULL;
> -        if (load_snapshot(loadvm, &local_err) < 0) {
> -            error_report_err(local_err);
> -            autostart = 0;
> -            exit(1);
> -        }
> -    }
> -    if (replay_mode != REPLAY_MODE_NONE) {
> -        replay_vmstate_init();
> -    }
> -
>      if (vmstate_dump_file) {
>          /* dump and exit */
>          dump_vmstate_json_to_file(vmstate_dump_file);
>          exit(0);
>      }
> -    if (incoming) {
> -        Error *local_err = NULL;
> -        if (strcmp(incoming, "defer") != 0) {
> -            qmp_migrate_incoming(incoming, &local_err);
> -            if (local_err) {
> -                error_reportf_err(local_err, "-incoming %s: ", incoming);
> -                exit(1);
> -            }
> -        }
> -    } else if (autostart) {
> -        qmp_cont(NULL);
> -    }
>  
> +    qemu_init_displays();
> +    if (!preconfig_requested) {
> +        qmp_x_exit_preconfig(&error_fatal);
> +    }
>      accel_setup_post(current_machine);
>      os_setup_post();
> -
> -    return;
>  }
>  
>  void qemu_cleanup(void)



  reply	other threads:[~2020-12-07 14:03 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  8:18 [PATCH 00/15] Finish cleaning up qemu_init Paolo Bonzini
2020-12-02  8:18 ` [PATCH 01/15] remove preconfig state Paolo Bonzini
2020-12-07 13:57   ` Igor Mammedov
2020-12-07 14:11     ` Paolo Bonzini
2020-12-07 15:14       ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 02/15] vl: remove separate preconfig main_loop Paolo Bonzini
2020-12-07 14:02   ` Igor Mammedov [this message]
2020-12-02  8:18 ` [PATCH 03/15] vl: allow -incoming defer with -preconfig Paolo Bonzini
2020-12-02  8:18 ` [PATCH 04/15] vl: extract softmmu/runstate.c Paolo Bonzini
2020-12-02  8:18 ` [PATCH 05/15] vl: extract softmmu/globals.c Paolo Bonzini
2020-12-02  8:18 ` [PATCH 06/15] vl: move all generic initialization out of vl.c Paolo Bonzini
2020-12-07 14:19   ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 07/15] chardev: do not use machine_init_done Paolo Bonzini
2020-12-07 15:15   ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 08/15] machine: introduce MachineInitPhase Paolo Bonzini
2020-12-07 15:28   ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 09/15] machine: record whether nvdimm= was set Paolo Bonzini
2020-12-07 15:40   ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 10/15] vl: make qemu_get_machine_opts static Paolo Bonzini
2020-12-07 16:07   ` Igor Mammedov
2020-12-07 16:38     ` Paolo Bonzini
2020-12-08  2:32     ` Daniel Henrique Barboza
2020-12-08 10:55       ` Igor Mammedov
2020-12-08 11:05       ` [PATCH] ppc/spapr: cleanup -machine pseries,nvdimm=X handling Igor Mammedov
2020-12-08 16:46         ` [PATCH v2] " Igor Mammedov
2020-12-08 17:24           ` Daniel Henrique Barboza
2020-12-08 18:35             ` Igor Mammedov
2020-12-08  2:16   ` [PATCH 10/15] vl: make qemu_get_machine_opts static Daniel Henrique Barboza
2020-12-08  8:13     ` Paolo Bonzini
2020-12-02  8:18 ` [PATCH 11/15] qtest: add a QOM object for qtest Paolo Bonzini
2020-12-07 16:24   ` Igor Mammedov
2020-12-07 16:43     ` Paolo Bonzini
2020-12-07 16:57       ` Igor Mammedov
2020-12-07 17:22         ` Paolo Bonzini
2020-12-08 11:11           ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 12/15] plugin: propagate errors Paolo Bonzini
2020-12-02 11:33   ` Alex Bennée
2020-12-07 16:53   ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 13/15] memory: allow creating MemoryRegions before accelerators Paolo Bonzini
2020-12-07 16:38   ` Igor Mammedov
2020-12-07 16:40     ` Paolo Bonzini
2020-12-07 17:06   ` Igor Mammedov
2020-12-02  8:18 ` [PATCH 14/15] null-machine: do not create a default memdev Paolo Bonzini
2020-12-07 16:43   ` Igor Mammedov
2020-12-11 23:24     ` Paolo Bonzini
2020-12-14 11:53       ` Igor Mammedov
2020-12-14 13:24         ` Paolo Bonzini
2020-12-02  8:18 ` [PATCH 15/15] monitor: allow quitting while in preconfig state Paolo Bonzini
2020-12-07 16:45   ` Igor Mammedov
2020-12-07 14:12 ` [PATCH 00/15] Finish cleaning up qemu_init no-reply

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=20201207150218.2df0dc3b@redhat.com \
    --to=imammedo@redhat.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.