[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] qmp: introduce 'writeconfig' command
From: |
Eduardo Otubo |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] qmp: introduce 'writeconfig' command |
Date: |
Wed, 25 Oct 2017 14:02:45 +0200 |
User-agent: |
Mutt/1.8.3+47 (5f034395e53d) (2017-05-23) |
On Mon, Oct 23, 2017 at 05:13:07PM +0200, Vadim Galitsyn wrote:
> Add support for `writeconfig' command for QMP monitor.
> This is a simple way to keep track of current state of VM
> after series of hotplugs and/or hotunplugs of different devices.
>
> Signed-off-by: Vadim Galitsyn <address@hidden>
> Signed-off-by: Eduardo Otubo <address@hidden>
> Cc: Markus Armbruster <address@hidden>
> Cc: Eric Blake <address@hidden>
> Cc: address@hidden
> ---
> qapi-schema.json | 18 ++++++++++++++++++
> qmp.c | 21 +++++++++++++++++++++
> 2 files changed, 39 insertions(+)
>
> diff --git a/qapi-schema.json b/qapi-schema.json
> index a9dd043f65..083f8f3258 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3200,3 +3200,21 @@
> # Since: 2.11
> ##
> { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} }
> +
> +##
> +# @writeconfig:
> +#
> +# Dump current configuration into specified file
> +#
> +# @file: pathname of a file to store current configuration
> +#
> +# Since: 2.11
> +#
> +# Example:
> +#
> +# -> { "execute": "writeconfig",
> +# "arguments": { "file": "/tmp/qemu.conf" } }
> +# <- { "return": {} }
> +#
> +##
> +{ 'command': 'writeconfig', 'data': {'file': 'str'} }
> diff --git a/qmp.c b/qmp.c
> index e8c303116a..fcb911cabb 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -722,3 +722,24 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
>
> return mem_info;
> }
> +
> +void qmp_writeconfig(const char *file, Error **errp)
> +{
> + int fd;
> + FILE *fp;
> +
> + fd = qemu_open(file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
> + if (fd != -1) {
> +
> + fp = fdopen(fd, "wb");
> + if (fp) {
> + qemu_config_write(fp);
> + fclose(fp);
> + return;
> + }
> +
> + qemu_close(fd);
> + }
> +
> + error_setg(errp, "cannot write configuration file: '%s'", file);
> +}
> --
> 2.13.1.394.g41dd433
>
>
Reviewed-by: Eduardo Otubo <address@hidden>
--
Eduardo Otubo
- [Qemu-devel] QMP, HMP: introduce 'writeconfig' command, Vadim Galitsyn, 2017/10/23
- [Qemu-devel] [PATCH 1/4] qmp: introduce 'writeconfig' command, Vadim Galitsyn, 2017/10/23
- [Qemu-devel] [PATCH 2/4] hmp: introduce 'writeconfig' command, Vadim Galitsyn, 2017/10/23
- [Qemu-devel] [PATCH 3/4] tests: test-hmp: extend with 'writeconfig' command, Vadim Galitsyn, 2017/10/23
- [Qemu-devel] [PATCH 4/4] tests: test-hmp: print command execution result, Vadim Galitsyn, 2017/10/23
- Re: [Qemu-devel] QMP, HMP: introduce 'writeconfig' command, Dr. David Alan Gilbert, 2017/10/24