qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: Amit Shah <amit.shah@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/5] migration: improve error reporting for load_vmstate
Date: Wed, 23 Dec 2015 14:56:27 -0700	[thread overview]
Message-ID: <567B188B.40108@redhat.com> (raw)
In-Reply-To: <1449240275-26196-5-git-send-email-den@openvz.org>

[-- Attachment #1: Type: text/plain, Size: 4198 bytes --]

On 12/04/2015 07:44 AM, Denis V. Lunev wrote:
> The patch adds Error ** parameter to load_vmstate call and fills error
> inside. The caller after that properly reports error either through
> monitor or via local stderr facility during VM start.
> 
> This helper will be useful too for qmp_loadvm implementation.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Juan Quintela <quintela@redhat.com>
> CC: Amit Shah <amit.shah@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Eric Blake <eblake@redhat.com>
> ---
>  include/sysemu/sysemu.h |  2 +-
>  migration/savevm.c      | 28 ++++++++++++++++------------
>  monitor.c               |  6 +++++-
>  vl.c                    |  4 +++-
>  4 files changed, 25 insertions(+), 15 deletions(-)
> 

> -int load_vmstate(const char *name)
> +int load_vmstate(const char *name, Error **errp)
>  {
>      BlockDriverState *bs, *bs_vm_state;
>      QEMUSnapshotInfo sn;
> @@ -2035,20 +2035,22 @@ int load_vmstate(const char *name)
>      AioContext *aio_context;
>  
>      if (!bdrv_all_can_snapshot(&bs)) {
> -        error_report("Device '%s' is writable but does not support snapshots.",
> -                     bdrv_get_device_name(bs));
> +        error_setg(errp,
> +                   "Device '%s' is writable but does not support snapshots.",

No trailing '.'

> @@ -2058,10 +2060,11 @@ int load_vmstate(const char *name)
>      ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
>      aio_context_release(aio_context);
>      if (ret < 0) {
> +        error_setg_errno(errp, ret, "Snapshot '%s' not found", name);

You need '-ret', since error_setg_errno() expects positive errno values.

[maybe, for convenience, we should teach error_setg_errno() to handle
both -EINVAL and EINVAL identically - but it would need good
justification and would touch a lot of the tree, so if we do it, it
would be a separate series]

>          return ret;
>      } else if (sn.vm_state_size == 0) {
> -        error_report("This is a disk-only snapshot. Revert to it offline "
> -            "using qemu-img.");
> +        error_setg(errp, "This is a disk-only snapshot. Revert to it offline "
> +                   "using qemu-img.");

According to Markus' recent cleanups, error_setg() should be a single
phrase, not two sentences.  You'll want the second sentence to be added
with error_append_hint():
https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03508.html

>          return -EINVAL;
>      }
>  
> @@ -2070,15 +2073,16 @@ int load_vmstate(const char *name)
>  
>      ret = bdrv_all_goto_snapshot(name, &bs);
>      if (ret < 0) {
> -        error_report("Error %d while activating snapshot '%s' on '%s'",
> -                     ret, name, bdrv_get_device_name(bs));
> +        error_setg_errno(errp, ret,

-ret again

> +                         "Error while activating snapshot '%s' on '%s'",
> +                         name, bdrv_get_device_name(bs));

but thanks for getting rid of the weird 'error -5 while...' in the
message :)

> @@ -2092,7 +2096,7 @@ int load_vmstate(const char *name)
>  
>      migration_incoming_state_destroy();
>      if (ret < 0) {
> -        error_report("Error %d while loading VM state", ret);
> +        error_setg_errno(errp, ret, "Error while loading VM state");

-ret again

> +++ b/monitor.c
> @@ -1739,10 +1739,14 @@ 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 (load_vmstate(name) == 0 && saved_vm_running) {
> +    if (load_vmstate(name, &local_err) < 0) {
> +        error_report_err(local_err);
> +    }
> +    if (saved_vm_running) {
>          vm_start();

Logic bug.  You blindly fall through, and could end up attempting
vm_start() even after an error, where previously it was not possible.
You probably meant '} else if (saved_vm_running) {'.

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-12-23 21:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 14:44 [Qemu-devel] [PATCH v2 for 2.6 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
2015-12-04 14:44 ` [Qemu-devel] [PATCH 1/5] migration: split hmp_savevm to do_savevm and hmp_savevm wrapper Denis V. Lunev
2015-12-23 21:27   ` Eric Blake
2016-01-08 11:27     ` Denis V. Lunev
2016-01-08 16:14       ` Eric Blake
2016-01-08 16:40         ` Denis V. Lunev
2016-01-08 17:54           ` Eric Blake
2016-01-08 17:59             ` Denis V. Lunev
2015-12-04 14:44 ` [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command Denis V. Lunev
2015-12-23 21:40   ` Eric Blake
2015-12-23 21:45     ` Denis V. Lunev
2016-01-08 13:19     ` Denis V. Lunev
2015-12-04 14:44 ` [Qemu-devel] [PATCH 3/5] qmp: create qmp_delvm command Denis V. Lunev
2015-12-23 21:48   ` Eric Blake
2015-12-04 14:44 ` [Qemu-devel] [PATCH 4/5] migration: improve error reporting for load_vmstate Denis V. Lunev
2015-12-23 21:56   ` Eric Blake [this message]
2015-12-04 14:44 ` [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command Denis V. Lunev
2015-12-23 23:15   ` Eric Blake
2015-12-11  9:33 ` [Qemu-devel] [PATCH v2 for 2.6 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
2015-12-18  6:10   ` Denis V. Lunev
2015-12-23 21:10     ` Denis V. Lunev
  -- strict thread matches above, loose matches on Subject: below --
2016-01-08 14:00 [Qemu-devel] [PATCH v3 " Denis V. Lunev
2016-01-08 14:00 ` [Qemu-devel] [PATCH 4/5] migration: improve error reporting for load_vmstate Denis V. Lunev
2016-01-08 14:10 [Qemu-devel] [PATCH v4 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
2016-01-08 14:10 ` [Qemu-devel] [PATCH 4/5] migration: improve error reporting for load_vmstate Denis V. Lunev

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=567B188B.40108@redhat.com \
    --to=eblake@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).