From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1My91k-00015x-Kr for qemu-devel@nongnu.org; Wed, 14 Oct 2009 14:56:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1My91g-00014W-94 for qemu-devel@nongnu.org; Wed, 14 Oct 2009 14:56:48 -0400 Received: from [199.232.76.173] (port=46870 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My91g-00014T-21 for qemu-devel@nongnu.org; Wed, 14 Oct 2009 14:56:44 -0400 Received: from fg-out-1718.google.com ([72.14.220.152]:1919) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1My91f-0006nT-Ig for qemu-devel@nongnu.org; Wed, 14 Oct 2009 14:56:43 -0400 Received: by fg-out-1718.google.com with SMTP id d23so71650fga.10 for ; Wed, 14 Oct 2009 11:56:39 -0700 (PDT) Message-ID: <4AD61EE2.1030700@codemonkey.ws> Date: Wed, 14 Oct 2009 13:56:34 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/4] QemuOpts: dump config. References: <1255509568-10635-1-git-send-email-kraxel@redhat.com> <1255509568-10635-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1255509568-10635-3-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Gerd Hoffmann wrote: > Add a function to write the QemuOpts configuration to a git-style > config file. > > Signed-off-by: Gerd Hoffmann > --- > qemu-config.c | 39 +++++++++++++++++++++++++++++++++++++++ > qemu-config.h | 2 ++ > 2 files changed, 41 insertions(+), 0 deletions(-) > > diff --git a/qemu-config.c b/qemu-config.c > index f02dd42..fa236e9 100644 > --- a/qemu-config.c > +++ b/qemu-config.c > @@ -238,3 +238,42 @@ int qemu_set_option(const char *str) > return 0; > } > > +struct ConfigWriteData { > + QemuOptsList *list; > + FILE *fp; > +}; > + > +static int config_write_opt(const char *name, const char *value, void *opaque) > +{ > + struct ConfigWriteData *data = opaque; > + > + fprintf(data->fp, " %s = \"%s\"\n", name, value); > + return 0; > +} > + > +static int config_write_opts(QemuOpts *opts, void *opaque) > +{ > + struct ConfigWriteData *data = opaque; > + const char *id = qemu_opts_id(opts); > + > + if (id) { > + fprintf(data->fp, "[%s \"%s\"]\n", data->list->name, id); > This id syntax is a good idea. Regards, Anthony Liguori