All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Baum <nathan@parenthephobia.org.uk>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/4] QemuOpts: command line switches for the config file.
Date: Fri, 16 Oct 2009 19:39:09 +0100	[thread overview]
Message-ID: <1255718349.25855.58.camel@localhost.localdomain> (raw)
In-Reply-To: <1255509568-10635-5-git-send-email-kraxel@redhat.com>

On Wed, 2009-10-14 at 10:39 +0200, Gerd Hoffmann wrote:
> Adds -readconfig and -writeconfig command line switches to read/write
> QemuOpts from config file.
> 
> In theory you should be able to do:
> 
>   qemu < machine config cmd line switches here > -writeconfig vm.cfg
>   qemu -readconfig vm.cfg
> 
> In practice it will not work.  Not all command line switches are
> converted to QemuOpts, so you'll have to keep the not-yet converted ones
> on the second line.  Also there might be bugs lurking which prevent even
> the converted ones from working correctly.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  qemu-options.hx |    5 +++++
>  vl.c            |   30 ++++++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+), 0 deletions(-)
> 
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 3dd76b3..6cbf9e2 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -1682,3 +1682,8 @@ DEF("semihosting", 0, QEMU_OPTION_semihosting,
>  DEF("old-param", 0, QEMU_OPTION_old_param,
>      "-old-param      old param mode\n")
>  #endif
> +DEF("readconfig", HAS_ARG, QEMU_OPTION_readconfig,
> +    "-readconfig <file>\n")
> +DEF("writeconfig", HAS_ARG, QEMU_OPTION_writeconfig,
> +    "-writeconfig <file>\n"
> +    "                read/write config file")
> diff --git a/vl.c b/vl.c
> index afe01af..ad902fe 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -5513,6 +5513,36 @@ int main(int argc, char **argv, char **envp)
>                  xen_mode = XEN_ATTACH;
>                  break;
>  #endif
> +            case QEMU_OPTION_readconfig:
> +                {
> +                    FILE *fp;
> +                    fp = fopen(optarg, "r");
> +                    if (fp == NULL) {
> +                        fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
> +                        exit(1);
> +                    }
> +                    if (qemu_config_parse(fp) != 0) {
> +                        exit(1);
> +                    }
> +                    fclose(fp);
> +                    break;
> +                }
> +            case QEMU_OPTION_writeconfig:
> +                {
> +                    FILE *fp;
> +                    if (strcmp(optarg, "-") == 0) {
> +                        fp = stdout;
> +                    } else {
> +                        fp = fopen(optarg, "w");
> +                        if (fp == NULL) {
> +                            fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
> +                            exit(1);
> +                        }
> +                    }
> +                    qemu_config_write(fp);
> +                    fclose(fp);
> +                    break;
> +                }
>              }
>          }
>      }


It seems like the typical use-case for -writeconfig will be for
"upgrading" to the config file system. Might it be more useful for qemu
to exit after writing the config?

Signed-off-by: Nathan Baum <nathan@parenthephobia.org.uk>
--- a/vl.c
+++ b/vl.c
@@ -5546,7 +5546,7 @@ int main(int argc, char **argv, char **envp)
                     }
                     qemu_config_write(fp);
                     fclose(fp);
-                    break;
+                    exit(0);
                 }
             }
         }

  reply	other threads:[~2009-10-16 18:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14  8:39 [Qemu-devel] [PATCH 0/4] QemuOpts: config file support Gerd Hoffmann
2009-10-14  8:39 ` [Qemu-devel] [PATCH 1/4] QemuOpts: add find_list() Gerd Hoffmann
2009-10-14  8:39 ` [Qemu-devel] [PATCH 2/4] QemuOpts: dump config Gerd Hoffmann
2009-10-14 18:56   ` Anthony Liguori
2009-10-14  8:39 ` [Qemu-devel] [PATCH 3/4] QemuOpts: parse config from file Gerd Hoffmann
2009-10-14 18:55   ` Anthony Liguori
2009-10-14  8:39 ` [Qemu-devel] [PATCH 4/4] QemuOpts: command line switches for the config file Gerd Hoffmann
2009-10-16 18:39   ` Nathan Baum [this message]
2009-10-16 19:29     ` Gerd Hoffmann
2009-10-16 18:48   ` Nathan Baum
2009-10-16 19:33     ` Gerd Hoffmann
2009-10-14 18:53 ` [Qemu-devel] [PATCH 0/4] QemuOpts: config file support Anthony Liguori
2009-10-14 19:01 ` Anthony Liguori
2009-10-16 10:16   ` Gerd Hoffmann

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=1255718349.25855.58.camel@localhost.localdomain \
    --to=nathan@parenthephobia.org.uk \
    --cc=kraxel@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.