From: Juan Quintela <quintela@redhat.com>
To: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: amit.shah@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] migration: extend migration_bitmap
Date: Wed, 01 Jul 2015 12:27:36 +0200 [thread overview]
Message-ID: <87616418br.fsf@neno.neno> (raw)
In-Reply-To: <1435313380-12857-3-git-send-email-lizhijian@cn.fujitsu.com> (Li Zhijian's message of "Fri, 26 Jun 2015 18:09:40 +0800")
Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
> Prevously, if we hotplug a device(e.g. device_add e1000) during
> migration is processing in source side, qemu will add a new ram
> block but migration_bitmap is not extended.
> In this case, migration_bitmap will overflow and lead qemu abort
> unexpectedly.
>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
> exec.c | 5 +++++
> include/exec/exec-all.h | 1 +
> migration/ram.c | 15 +++++++++++++++
> 3 files changed, 21 insertions(+)
>
> diff --git a/exec.c b/exec.c
> index f7883d2..1702544 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1401,6 +1401,11 @@ static ram_addr_t ram_block_add(RAMBlock *new_block, Error **errp)
> }
> }
>
> + new_ram_size = MAX(old_ram_size,
> + (new_block->offset + new_block->max_length) >> TARGET_PAGE_BITS);
> + if (new_ram_size > old_ram_size) {
> + migration_bitmap_extend(old_ram_size, new_ram_size);
> + }
> /* Keep the list sorted from biggest to smallest block. Unlike QTAILQ,
> * QLIST (which has an RCU-friendly variant) does not have insertion at
> * tail, so save the last element in last_block.
> diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
> index 2573e8c..dd9be44 100644
> --- a/include/exec/exec-all.h
> +++ b/include/exec/exec-all.h
> @@ -385,4 +385,5 @@ static inline bool cpu_can_do_io(CPUState *cpu)
> return cpu->can_do_io != 0;
> }
>
> +void migration_bitmap_extend(ram_addr_t old, ram_addr_t new);
Had to protect this one with
#if !defined(CONFIG_USER_ONLY)
void migration_bitmap_extend(ram_addr_t old, ram_addr_t new);
#endif
> #endif
> diff --git a/migration/ram.c b/migration/ram.c
> index 4754aa9..3e16ef8 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1063,6 +1063,21 @@ static void reset_ram_globals(void)
>
> #define MAX_WAIT 50 /* ms, half buffered_file limit */
>
> +void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)
> +{
> + qemu_mutex_lock(&migration_bitmap_mutex);
> + if (migration_bitmap) {
> + unsigned long *old_bitmap = migration_bitmap, *bitmap;
> + bitmap = bitmap_new(new);
> + bitmap_copy(bitmap, old_bitmap, old);
> + bitmap_set(bitmap, old, new - old);
> + atomic_rcu_set(&migration_bitmap, bitmap);
> + migration_dirty_pages += new - old;
> + synchronize_rcu();
> + g_free(old_bitmap);
> + }
> + qemu_mutex_unlock(&migration_bitmap_mutex);
> +}
>
> /* Each of ram_save_setup, ram_save_iterate and ram_save_complete has
> * long-running RCU critical section. When rcu-reclaims in the code
next prev parent reply other threads:[~2015-07-01 10:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 10:09 [Qemu-devel] [PATCH v2 0/2] avoid a hotplug operation leading migration's source side abort Li Zhijian
2015-06-26 10:09 ` [Qemu-devel] [PATCH v2 1/2] migration: protect migration_bitmap Li Zhijian
2015-06-26 10:09 ` [Qemu-devel] [PATCH v2 2/2] migration: extend migration_bitmap Li Zhijian
2015-07-01 10:27 ` Juan Quintela [this message]
2015-07-01 8:34 ` [Qemu-devel] [PATCH v2 0/2] avoid a hotplug operation leading migration's source side abort Juan Quintela
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=87616418br.fsf@neno.neno \
--to=quintela@redhat.com \
--cc=amit.shah@redhat.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.