From: Stefan Hajnoczi <stefanha@gmail.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org,
quintela@redhat.com, dgilbert@redhat.com, amit.shah@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2] migration: re-active images while migration been canceled after inactive them
Date: Tue, 24 Jan 2017 12:53:03 +0000 [thread overview]
Message-ID: <20170124125303.GJ17221@stefanha-x1.localdomain> (raw)
In-Reply-To: <1485244792-11248-1-git-send-email-zhang.zhanghailiang@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 2325 bytes --]
On Tue, Jan 24, 2017 at 03:59:52PM +0800, zhanghailiang wrote:
> commit fe904ea8242cbae2d7e69c052c754b8f5f1ba1d6 fixed a case
> which migration aborted QEMU because it didn't regain the control
> of images while some errors happened.
>
> Actually, there are another two cases can trigger the same error reports:
> " bdrv_co_do_pwritev: Assertion `!(bs->open_flags & 0x0800)' failed",
>
> Case 1, codes path:
> migration_thread()
> migration_completion()
> bdrv_inactivate_all() ----------------> inactivate images
> qemu_savevm_state_complete_precopy()
> socket_writev_buffer() --------> error because destination fails
> qemu_fflush() ----------------> set error on migration stream
> -> qmp_migrate_cancel() ----------------> user cancelled migration concurrently
> -> migrate_set_state() ------------------> set migrate CANCELLIN
> migration_completion() -----------------> go on to fail_invalidate
> if (s->state == MIGRATION_STATUS_ACTIVE) -> Jump this branch
>
> Case 2, codes path:
> migration_thread()
> migration_completion()
> bdrv_inactivate_all() ----------------> inactivate images
> migreation_completion() finished
> -> qmp_migrate_cancel() ---------------> user cancelled migration concurrently
> qemu_mutex_lock_iothread();
> qemu_bh_schedule (s->cleanup_bh);
>
> As we can see from above, qmp_migrate_cancel can slip in whenever
> migration_thread does not hold the global lock. If this happens after
> bdrv_inactive_all() been called, the above error reports will appear.
>
> To prevent this, we can call bdrv_invalidate_cache_all() in qmp_migrate_cancel()
> directly if we find images become inactive.
>
> Besides, bdrv_invalidate_cache_all() in migration_completion() doesn't have the
> protection of big lock, fix it by add the missing qemu_mutex_lock_iothread();
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
> v2:
> - Fix a bug introduced by commit fe904 which didn't get big lock
> before call bdrv_invalidate_cache_all. (Suggested by Dave)
> ---
> include/migration/migration.h | 3 +++
> migration/migration.c | 15 +++++++++++++++
> 2 files changed, 18 insertions(+)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2017-01-24 12:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 7:59 [Qemu-devel] [PATCH v2] migration: re-active images while migration been canceled after inactive them zhanghailiang
2017-01-24 10:47 ` Dr. David Alan Gilbert
2017-01-24 11:52 ` Dr. David Alan Gilbert
2017-01-24 12:53 ` Stefan Hajnoczi [this message]
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=20170124125303.GJ17221@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=amit.shah@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhang.zhanghailiang@huawei.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).