All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix block migration bug
@ 2014-12-11 11:55 Vladimir Sementsov-Ogievskiy
  2014-12-11 11:55 ` [Qemu-devel] [PATCH] block-migration: fix pending() return value Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2014-12-11 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, den, stefanha

Because of wrong return value of .save_live_pending() in
block-migration, migration finishes before the whole disk
is transferred. Such situation occures when the migration
process is fast enouth, for example when source and dest 
are on the same host.

It's easy to test this with the following:

bug.sh
=====================================================================
#!/bin/sh

size=$1
addr=$2

rm /tmp/fifo-mig /tmp/a /tmp/b /tmp/sock-mig

./qemu-img create -f qcow2 /tmp/a $size
./qemu-img create -f qcow2 /tmp/b $size

./qemu-io -c "write -P 0x22 $addr 512" /tmp/a

mkfifo /tmp/fifo-mig

./x86_64-softmmu/qemu-system-x86_64 -drive file=/tmp/b,id=disk\
    -qmp unix:/tmp/sock-mig,server,nowait\
    -incoming "exec: cat /tmp/fifo-mig" &

echo 'migrate -b exec:cat>/tmp/fifo-mig\nquit\n' |\
./x86_64-softmmu/qemu-system-x86_64 -drive file=/tmp/a,id=disk\
    -monitor stdio

./scripts/qmp/qmp --path=/tmp/sock-mig quit
sleep 3

echo checking
./qemu-io -c "read -P 0x22 $addr 512" /tmp/b
=====================================================================

For './bug.sh 1G 1M' qemu-io check finishes successfully,
but for './bug.sh 1G 1022M' it finishes with 'Pattern verification
failed' status.

The following patch fixes this bug.

Vladimir Sementsov-Ogievskiy (1):
  block-migration: fix pending() return value

 block-migration.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] block-migration: fix pending() return value
  2014-12-11 11:55 [Qemu-devel] [PATCH] Fix block migration bug Vladimir Sementsov-Ogievskiy
@ 2014-12-11 11:55 ` Vladimir Sementsov-Ogievskiy
  2014-12-11 15:07   ` Eric Blake
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2014-12-11 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, den, stefanha

Because of wrong return value of .save_live_pending() in
block-migration, migration finishes before the whole disk
is transferred. Such situation occures when the migration
process is fast enouth, for example when source and dest
are on the same host.

If in the bulk phase we return something < max_size, we will skip
transferring the tail of the device. Currently we have "set pending to
BLOCK_SIZE if it is zero" for bulk phase, but there no guarantee, that
it will be < max_size.

True approach is to return, for example, max_size+1 when we are in the
bulk phase.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@parallels.com>
---
 block-migration.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block-migration.c b/block-migration.c
index 73cdd07..bf78bd8 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -756,8 +756,8 @@ static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
                        block_mig_state.read_done * BLOCK_SIZE;
 
     /* Report at least one block pending during bulk phase */
-    if (pending == 0 && !block_mig_state.bulk_completed) {
-        pending = BLOCK_SIZE;
+    if (pending <= max_size && !block_mig_state.bulk_completed) {
+        pending = max_size + BLOCK_SIZE;
     }
     blk_mig_unlock();
     qemu_mutex_unlock_iothread();
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] block-migration: fix pending() return value
  2014-12-11 11:55 ` [Qemu-devel] [PATCH] block-migration: fix pending() return value Vladimir Sementsov-Ogievskiy
@ 2014-12-11 15:07   ` Eric Blake
  2014-12-19 11:44     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2014-12-11 15:07 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: kwolf, den, stefanha

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

On 12/11/2014 04:55 AM, Vladimir Sementsov-Ogievskiy wrote:
> Because of wrong return value of .save_live_pending() in
> block-migration, migration finishes before the whole disk
> is transferred. Such situation occures when the migration

s/occures/occurs/

> process is fast enouth, for example when source and dest

s/enouth/enough/

> are on the same host.
> 
> If in the bulk phase we return something < max_size, we will skip
> transferring the tail of the device. Currently we have "set pending to
> BLOCK_SIZE if it is zero" for bulk phase, but there no guarantee, that
> it will be < max_size.
> 
> True approach is to return, for example, max_size+1 when we are in the
> bulk phase.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@parallels.com>
> ---
>  block-migration.c | 4 ++--

I'll let someone else review the code proper.

-- 
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: 539 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] block-migration: fix pending() return value
  2014-12-11 15:07   ` Eric Blake
@ 2014-12-19 11:44     ` Vladimir Sementsov-Ogievskiy
  2015-01-29  7:58       ` Markus Armbruster
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2014-12-19 11:44 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: kwolf, den, stefanha

Hi there.. Can someone review my bug fix? I'll surely fix typos in 
description after it.

Best regards,
Vladimir

On 11.12.2014 18:07, Eric Blake wrote:
> On 12/11/2014 04:55 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Because of wrong return value of .save_live_pending() in
>> block-migration, migration finishes before the whole disk
>> is transferred. Such situation occures when the migration
> s/occures/occurs/
>
>> process is fast enouth, for example when source and dest
> s/enouth/enough/
>
>> are on the same host.
>>
>> If in the bulk phase we return something < max_size, we will skip
>> transferring the tail of the device. Currently we have "set pending to
>> BLOCK_SIZE if it is zero" for bulk phase, but there no guarantee, that
>> it will be < max_size.
>>
>> True approach is to return, for example, max_size+1 when we are in the
>> bulk phase.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@parallels.com>
>> ---
>>   block-migration.c | 4 ++--
> I'll let someone else review the code proper.
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] block-migration: fix pending() return value
  2014-12-19 11:44     ` Vladimir Sementsov-Ogievskiy
@ 2015-01-29  7:58       ` Markus Armbruster
  2015-01-29  8:35         ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Armbruster @ 2015-01-29  7:58 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: kwolf, den, qemu-devel, stefanha

Vladimir Sementsov-Ogievskiy <vsementsov@parallels.com> writes:

> Hi there.. Can someone review my bug fix? I'll surely fix typos in
> description after it.

The file you patch has since moved.  Suggest a quick rebase.  Make sure
to cc: your v2 to migration maintainers.

$ scripts/get_maintainer.pl -f migration/block.c 
Kevin Wolf <kwolf@redhat.com> (supporter:Block)
Stefan Hajnoczi <stefanha@redhat.com> (supporter:Block)
Juan Quintela <quintela@redhat.com> (maintainer:Migration)
Amit Shah <amit.shah@redhat.com> (maintainer:Migration)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] block-migration: fix pending() return value
  2015-01-29  7:58       ` Markus Armbruster
@ 2015-01-29  8:35         ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2015-01-29  8:35 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, den, qemu-devel, stefanha

v2 is already pushed 
http://git.qemu.org/?p=qemu.git;a=commit;h=04636dc410b163c2243e66c3813dd4900a50a4ed

Best regards,
Vladimir

On 29.01.2015 10:58, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@parallels.com> writes:
>
>> Hi there.. Can someone review my bug fix? I'll surely fix typos in
>> description after it.
> The file you patch has since moved.  Suggest a quick rebase.  Make sure
> to cc: your v2 to migration maintainers.
>
> $ scripts/get_maintainer.pl -f migration/block.c
> Kevin Wolf <kwolf@redhat.com> (supporter:Block)
> Stefan Hajnoczi <stefanha@redhat.com> (supporter:Block)
> Juan Quintela <quintela@redhat.com> (maintainer:Migration)
> Amit Shah <amit.shah@redhat.com> (maintainer:Migration)
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-29  8:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 11:55 [Qemu-devel] [PATCH] Fix block migration bug Vladimir Sementsov-Ogievskiy
2014-12-11 11:55 ` [Qemu-devel] [PATCH] block-migration: fix pending() return value Vladimir Sementsov-Ogievskiy
2014-12-11 15:07   ` Eric Blake
2014-12-19 11:44     ` Vladimir Sementsov-Ogievskiy
2015-01-29  7:58       ` Markus Armbruster
2015-01-29  8:35         ` Vladimir Sementsov-Ogievskiy

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.