From patchwork Fri Oct 16 18:39:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Baum X-Patchwork-Id: 36267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6C6F0B7C15 for ; Sat, 17 Oct 2009 05:40:41 +1100 (EST) Received: from localhost ([127.0.0.1]:46935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyrjB-00061h-TK for incoming@patchwork.ozlabs.org; Fri, 16 Oct 2009 14:40:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Myrhd-0004d5-Ft for qemu-devel@nongnu.org; Fri, 16 Oct 2009 14:39:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MyrhY-0004VB-Ed for qemu-devel@nongnu.org; Fri, 16 Oct 2009 14:39:00 -0400 Received: from [199.232.76.173] (port=50157 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyrhY-0004Ux-9d for qemu-devel@nongnu.org; Fri, 16 Oct 2009 14:38:56 -0400 Received: from smarthost.c4l.co.uk ([82.197.83.77]:51289) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MyrhX-0006RE-Rr for qemu-devel@nongnu.org; Fri, 16 Oct 2009 14:38:56 -0400 Received: from [93.97.162.229] (helo=mx.parenthephobia.org.uk) by smarthost.c4l.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1MyrhV-0001kJ-A5; Fri, 16 Oct 2009 19:38:53 +0100 Received: from [192.168.1.59] (office.c4l.co.uk [84.45.45.84]) (Authenticated sender: nathan) by mx.parenthephobia.org.uk (Postfix) with ESMTPA id E94DC534CF; Fri, 16 Oct 2009 19:38:50 +0100 (BST) Subject: Re: [Qemu-devel] [PATCH 4/4] QemuOpts: command line switches for the config file. From: Nathan Baum To: Gerd Hoffmann In-Reply-To: <1255509568-10635-5-git-send-email-kraxel@redhat.com> References: <1255509568-10635-1-git-send-email-kraxel@redhat.com> <1255509568-10635-5-git-send-email-kraxel@redhat.com> Date: Fri, 16 Oct 2009 19:39:09 +0100 Message-Id: <1255718349.25855.58.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.28.0 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 > --- > 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 \n") > +DEF("writeconfig", HAS_ARG, QEMU_OPTION_writeconfig, > + "-writeconfig \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 --- 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); } } }