diff mbox series

[v2,5/8] softmmu: refactor use of is_daemonized() method

Message ID 20220304185620.3272401-6-berrange@redhat.com (mailing list archive)
State New, archived
Headers show
Series softmmu: move and refactor -runas, -chroot and -daemonize | expand

Commit Message

Daniel P. Berrangé March 4, 2022, 6:56 p.m. UTC
Use of the is_daemonized() method is isolated to allow it to be
more easily eliminated in a future change.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 softmmu/vl.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Eric Blake March 4, 2022, 10:02 p.m. UTC | #1
On Fri, Mar 04, 2022 at 06:56:17PM +0000, Daniel P. Berrangé wrote:
> Use of the is_daemonized() method is isolated to allow it to be
> more easily eliminated in a future change.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  softmmu/vl.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/softmmu/vl.c b/softmmu/vl.c
index f6f33e15e4..30342b9df2 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1371,11 +1371,11 @@  static void qemu_disable_default_devices(void)
     }
 }
 
-static void qemu_create_default_devices(void)
+static void qemu_create_default_devices(bool daemonize)
 {
     MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
 
-    if (is_daemonized()) {
+    if (daemonize) {
         /* According to documentation and historically, -nographic redirects
          * serial port, parallel port and monitor to stdio, which does not work
          * with -daemonize.  We can redirect these to null instead, but since
@@ -2455,7 +2455,8 @@  static void create_default_memdev(MachineState *ms, const char *path)
                             &error_fatal);
 }
 
-static void qemu_validate_options(const QDict *machine_opts)
+static void qemu_validate_options(const QDict *machine_opts,
+                                  bool daemonize)
 {
     const char *kernel_filename = qdict_get_try_str(machine_opts, "kernel");
     const char *initrd_filename = qdict_get_try_str(machine_opts, "initrd");
@@ -2484,7 +2485,7 @@  static void qemu_validate_options(const QDict *machine_opts)
     }
 
 #ifdef CONFIG_CURSES
-    if (is_daemonized() && dpy.type == DISPLAY_TYPE_CURSES) {
+    if (daemonize && dpy.type == DISPLAY_TYPE_CURSES) {
         error_report("curses display cannot be used with -daemonize");
         exit(1);
     }
@@ -3676,7 +3677,7 @@  void qemu_init(int argc, char **argv, char **envp)
      */
     loc_set_none();
 
-    qemu_validate_options(machine_opts_dict);
+    qemu_validate_options(machine_opts_dict, is_daemonized());
     qemu_process_sugar_options();
 
     /*
@@ -3714,7 +3715,7 @@  void qemu_init(int argc, char **argv, char **envp)
     suspend_mux_open();
 
     qemu_disable_default_devices();
-    qemu_create_default_devices();
+    qemu_create_default_devices(is_daemonized());
     qemu_create_early_backends();
 
     qemu_apply_legacy_machine_options(machine_opts_dict);