qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm co


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command
Date: Wed, 23 Dec 2015 16:15:34 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 12/04/2015 07:44 AM, Denis V. Lunev wrote:
> Unfortunately load_vmstate has a return code (int) and this code is checked
> in the other places. Thus we could not just rename it to qmp_loadvm as
> returns void.
> 
> Signed-off-by: Denis V. Lunev <address@hidden>
> CC: Juan Quintela <address@hidden>
> CC: Amit Shah <address@hidden>
> CC: Markus Armbruster <address@hidden>
> CC: Eric Blake <address@hidden>
> ---
>  migration/savevm.c | 12 ++++++++++++
>  monitor.c          | 12 ++++++------
>  qapi-schema.json   | 13 +++++++++++++
>  qmp-commands.hx    | 23 +++++++++++++++++++++++
>  4 files changed, 54 insertions(+), 6 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 7846437..07b0bf4 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2103,6 +2103,18 @@ int load_vmstate(const char *name, Error **errp)
>      return 0;
>  }
>  
> +void qmp_loadvm(const char *name, Error **errp)
> +{
> +    int saved_vm_running  = runstate_is_running();
> +    vm_stop(RUN_STATE_RESTORE_VM);
> +
> +    load_vmstate(name, errp);
> +
> +    if (saved_vm_running) {
> +        vm_start();

Do you really mean to be calling vm_start() even if an error was
reported?  But to properly short-circuit, you need a local 'Error *err =
NULL; load_vmstate(name, &err);', rather than reusing errp (since the
caller may pass in NULL).

> +++ b/monitor.c
> @@ -1737,18 +1737,18 @@ void qmp_closefd(const char *fdname, Error **errp)
>  
>  static void hmp_loadvm(Monitor *mon, const QDict *qdict)
>  {
> -    int saved_vm_running  = runstate_is_running();
>      const char *name = qdict_get_str(qdict, "name");
>      Error *local_err = NULL;
>  
> -    vm_stop(RUN_STATE_RESTORE_VM);
> +    if (name == NULL) {

Dead code.  qdict_get_str() crashes rather than returning NULL, if
"name" is not present.

> +++ b/qmp-commands.hx
> @@ -4787,3 +4787,26 @@ EQMP
>          .args_type  = "name:s",
>          .mhandler.cmd_new = qmp_marshal_delvm,
>      },
> +
> +SQMP
> +loadvm
> +------------------

Line too long.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]