Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-21 Thread Vladimir Sementsov-Ogievskiy

21.08.2020 03:44, Eric Blake wrote:

On 8/20/20 10:49 AM, Vladimir Sementsov-Ogievskiy wrote:

# MYPYPATH=../../python/ mypy 300
300:154: error: Item "None" of "Optional[Match[Any]]" has no attribute "group"
Found 1 error in 1 file (checked 1 source file)

- the only complain. Suggest a fix:

diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
index c6d86b1dbc..0241903743 100755
--- a/tests/qemu-iotests/300
+++ b/tests/qemu-iotests/300
@@ -148,11 +148,11 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
  result = vm.qmp('human-monitor-command',
  command_line='info migrate_parameters')

-    hmp_mapping = re.search(r'^block-bitmap-mapping:\r?(\n .*)*\n',
-    result['return'], flags=re.MULTILINE)
+    m = re.search(r'^block-bitmap-mapping:\r?(\n  .*)*\n',
+  result['return'], flags=re.MULTILINE)
+    hmp_mapping = m.group(0).replace('\r', '') if m else None

-    self.assertEqual(hmp_mapping.group(0).replace('\r', ''),
- self.to_hmp_mapping(mapping))
+    self.assertEqual(hmp_mapping, self.to_hmp_mapping(mapping))
  else:
  self.assert_qmp(result, 'error/desc', error)


Thanks; I'll fold that in to v5.



===

# flake8 300
300:24:1: F401 'time' imported but unused
300:34:1: E302 expected 2 blank lines, found 1
300:42:67: E502 the backslash is redundant between brackets
300:47:67: E502 the backslash is redundant between brackets
300:67:53: E502 the backslash is redundant between brackets
300:122:9: E125 continuation line with same indent as next logical line
300:134:9: E125 continuation line with same indent as next logical line
300:185:52: E502 the backslash is redundant between brackets
300:186:72: E502 the backslash is redundant between brackets
300:285:77: E502 the backslash is redundant between brackets
300:305:77: E502 the backslash is redundant between brackets
300:306:78: E502 the backslash is redundant between brackets
300:330:77: E502 the backslash is redundant between brackets
300:350:77: E502 the backslash is redundant between brackets
300:385:57: E502 the backslash is redundant between brackets
300:386:59: E502 the backslash is redundant between brackets
300:387:67: E502 the backslash is redundant between brackets
300:412:78: E502 the backslash is redundant between brackets
300:425:78: E502 the backslash is redundant between brackets
300:435:78: E502 the backslash is redundant between brackets
300:436:76: E502 the backslash is redundant between brackets
300:451:66: E502 the backslash is redundant between brackets
300:473:78: E502 the backslash is redundant between brackets
300:474:79: E502 the backslash is redundant between brackets
300:488:78: E502 the backslash is redundant between brackets
300:489:77: E502 the backslash is redundant between brackets

- I post it just because ALE plugin in vim highlights all these things for me. 
Up to you, I don't ask you to fix it.


Seems like an easy enough touchup to make.



+    def test_alias_on_both_migration(self) -> None:
+    src_map = self.mapping(self.src_node_name, 'node-alias',
+   self.src_bmap_name, 'bmap-alias')
+
+    dst_map = self.mapping(self.dst_node_name, 'node-alias',
+   self.dst_bmap_name, 'bmap-alias')
+
+    self.set_mapping(self.vm_a, src_map)
+    self.set_mapping(self.vm_b, dst_map)
+    self.migrate()
+    self.verify_dest_error(None)


Hmm, probably verify_dest_error() should be called from migrate(), as you call 
it (almost) always after migrate()


This one I did not touch; it can be a followup patch if desired.




+
+


[..]


+    def test_unused_mapping_on_dst(self) -> None:
+    # Let the source not send any bitmaps
+    self.set_mapping(self.vm_a, [])
+
+    # Establish some mapping on the destination
+    self.set_mapping(self.vm_b, [])


Seems, you wanted to specify non-empty mapping for vm_b, yes?
With any non-empty mapping here, just to better correspond to the comments:
Reviewed-by: Vladimir Sementsov-Ogievskiy 

(or keep this case with both mappings empty, and add one similar with empty 
mapping only on src)


Adding another case will now have to be a separate patch.  At any rate, I've 
taken the liberty of including your R-b in my staging tree for the pending pull 
request, let me know if I should drop it.



OK, thanks, no objections.

--
Best regards,
Vladimir



Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-21 Thread Max Reitz
On 20.08.20 17:49, Vladimir Sementsov-Ogievskiy wrote:
> # MYPYPATH=../../python/ mypy 300
> 300:154: error: Item "None" of "Optional[Match[Any]]" has no attribute
> "group"
> Found 1 error in 1 file (checked 1 source file)

:(

> - the only complain. Suggest a fix:
> 
> diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
> index c6d86b1dbc..0241903743 100755
> --- a/tests/qemu-iotests/300
> +++ b/tests/qemu-iotests/300
> @@ -148,11 +148,11 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
>  result = vm.qmp('human-monitor-command',
>  command_line='info migrate_parameters')
>  
> -    hmp_mapping = re.search(r'^block-bitmap-mapping:\r?(\n 
> .*)*\n',
> -    result['return'], flags=re.MULTILINE)
> +    m = re.search(r'^block-bitmap-mapping:\r?(\n  .*)*\n',
> +  result['return'], flags=re.MULTILINE)
> +    hmp_mapping = m.group(0).replace('\r', '') if m else None
>  
> -    self.assertEqual(hmp_mapping.group(0).replace('\r', ''),
> - self.to_hmp_mapping(mapping))
> +    self.assertEqual(hmp_mapping, self.to_hmp_mapping(mapping))

Looks good, thanks.

>  else:
>  self.assert_qmp(result, 'error/desc', error)
>  
> ===
> 
> # flake8 300
[...]
> - I post it just because ALE plugin in vim highlights all these things
> for me. Up to you, I don't ask you to fix it.

Thanks, I’ll run it from now on (unless I forget, like mypy above...).

> 18.08.2020 16:32, Max Reitz wrote:
>> Signed-off-by: Max Reitz 
>> ---
>>   tests/qemu-iotests/300 | 595 +
>>   tests/qemu-iotests/300.out |   5 +
>>   tests/qemu-iotests/group   |   1 +
>>   3 files changed, 601 insertions(+)
>>   create mode 100755 tests/qemu-iotests/300
>>   create mode 100644 tests/qemu-iotests/300.out
>>
> 
> [..]
> 
>> +    def test_alias_on_both_migration(self) -> None:
>> +    src_map = self.mapping(self.src_node_name, 'node-alias',
>> +   self.src_bmap_name, 'bmap-alias')
>> +
>> +    dst_map = self.mapping(self.dst_node_name, 'node-alias',
>> +   self.dst_bmap_name, 'bmap-alias')
>> +
>> +    self.set_mapping(self.vm_a, src_map)
>> +    self.set_mapping(self.vm_b, dst_map)
>> +    self.migrate()
>> +    self.verify_dest_error(None)
> 
> Hmm, probably verify_dest_error() should be called from migrate(), as
> you call it (almost) always after migrate()

I don’t know, it shuts down the destination VM, so it would seem a bit
strange to do that as part of migrate().

>> +    def test_unused_mapping_on_dst(self) -> None:
>> +    # Let the source not send any bitmaps
>> +    self.set_mapping(self.vm_a, [])
>> +
>> +    # Establish some mapping on the destination
>> +    self.set_mapping(self.vm_b, [])
> 
> Seems, you wanted to specify non-empty mapping for vm_b, yes?

Oops.  I don’t know how it could have happened that I forgot that.

> With any non-empty mapping here, just to better correspond to the comments:
> Reviewed-by: Vladimir Sementsov-Ogievskiy 
> 
> (or keep this case with both mappings empty, and add one similar with
> empty mapping only on src)

I’ll see in what shape this patch lands in master, and then I’ll
probably add that other case, yes.

Max



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-20 Thread Eric Blake

On 8/20/20 10:49 AM, Vladimir Sementsov-Ogievskiy wrote:

# MYPYPATH=../../python/ mypy 300
300:154: error: Item "None" of "Optional[Match[Any]]" has no attribute 
"group"

Found 1 error in 1 file (checked 1 source file)

- the only complain. Suggest a fix:

diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
index c6d86b1dbc..0241903743 100755
--- a/tests/qemu-iotests/300
+++ b/tests/qemu-iotests/300
@@ -148,11 +148,11 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
  result = vm.qmp('human-monitor-command',
  command_line='info migrate_parameters')

-    hmp_mapping = re.search(r'^block-bitmap-mapping:\r?(\n  
.*)*\n',

-    result['return'], flags=re.MULTILINE)
+    m = re.search(r'^block-bitmap-mapping:\r?(\n  .*)*\n',
+  result['return'], flags=re.MULTILINE)
+    hmp_mapping = m.group(0).replace('\r', '') if m else None

-    self.assertEqual(hmp_mapping.group(0).replace('\r', ''),
- self.to_hmp_mapping(mapping))
+    self.assertEqual(hmp_mapping, self.to_hmp_mapping(mapping))
  else:
  self.assert_qmp(result, 'error/desc', error)


Thanks; I'll fold that in to v5.



===

# flake8 300
300:24:1: F401 'time' imported but unused
300:34:1: E302 expected 2 blank lines, found 1
300:42:67: E502 the backslash is redundant between brackets
300:47:67: E502 the backslash is redundant between brackets
300:67:53: E502 the backslash is redundant between brackets
300:122:9: E125 continuation line with same indent as next logical line
300:134:9: E125 continuation line with same indent as next logical line
300:185:52: E502 the backslash is redundant between brackets
300:186:72: E502 the backslash is redundant between brackets
300:285:77: E502 the backslash is redundant between brackets
300:305:77: E502 the backslash is redundant between brackets
300:306:78: E502 the backslash is redundant between brackets
300:330:77: E502 the backslash is redundant between brackets
300:350:77: E502 the backslash is redundant between brackets
300:385:57: E502 the backslash is redundant between brackets
300:386:59: E502 the backslash is redundant between brackets
300:387:67: E502 the backslash is redundant between brackets
300:412:78: E502 the backslash is redundant between brackets
300:425:78: E502 the backslash is redundant between brackets
300:435:78: E502 the backslash is redundant between brackets
300:436:76: E502 the backslash is redundant between brackets
300:451:66: E502 the backslash is redundant between brackets
300:473:78: E502 the backslash is redundant between brackets
300:474:79: E502 the backslash is redundant between brackets
300:488:78: E502 the backslash is redundant between brackets
300:489:77: E502 the backslash is redundant between brackets

- I post it just because ALE plugin in vim highlights all these things 
for me. Up to you, I don't ask you to fix it.


Seems like an easy enough touchup to make.



+    def test_alias_on_both_migration(self) -> None:
+    src_map = self.mapping(self.src_node_name, 'node-alias',
+   self.src_bmap_name, 'bmap-alias')
+
+    dst_map = self.mapping(self.dst_node_name, 'node-alias',
+   self.dst_bmap_name, 'bmap-alias')
+
+    self.set_mapping(self.vm_a, src_map)
+    self.set_mapping(self.vm_b, dst_map)
+    self.migrate()
+    self.verify_dest_error(None)


Hmm, probably verify_dest_error() should be called from migrate(), as 
you call it (almost) always after migrate()


This one I did not touch; it can be a followup patch if desired.




+
+


[..]


+    def test_unused_mapping_on_dst(self) -> None:
+    # Let the source not send any bitmaps
+    self.set_mapping(self.vm_a, [])
+
+    # Establish some mapping on the destination
+    self.set_mapping(self.vm_b, [])


Seems, you wanted to specify non-empty mapping for vm_b, yes?
With any non-empty mapping here, just to better correspond to the comments:
Reviewed-by: Vladimir Sementsov-Ogievskiy 

(or keep this case with both mappings empty, and add one similar with 
empty mapping only on src)


Adding another case will now have to be a separate patch.  At any rate, 
I've taken the liberty of including your R-b in my staging tree for the 
pending pull request, let me know if I should drop it.


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-20 Thread Vladimir Sementsov-Ogievskiy

# MYPYPATH=../../python/ mypy 300
300:154: error: Item "None" of "Optional[Match[Any]]" has no attribute "group"
Found 1 error in 1 file (checked 1 source file)

- the only complain. Suggest a fix:

diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
index c6d86b1dbc..0241903743 100755
--- a/tests/qemu-iotests/300
+++ b/tests/qemu-iotests/300
@@ -148,11 +148,11 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
 result = vm.qmp('human-monitor-command',
 command_line='info migrate_parameters')
 
-hmp_mapping = re.search(r'^block-bitmap-mapping:\r?(\n  .*)*\n',

-result['return'], flags=re.MULTILINE)
+m = re.search(r'^block-bitmap-mapping:\r?(\n  .*)*\n',
+  result['return'], flags=re.MULTILINE)
+hmp_mapping = m.group(0).replace('\r', '') if m else None
 
-self.assertEqual(hmp_mapping.group(0).replace('\r', ''),

- self.to_hmp_mapping(mapping))
+self.assertEqual(hmp_mapping, self.to_hmp_mapping(mapping))
 else:
 self.assert_qmp(result, 'error/desc', error)
 
===


# flake8 300
300:24:1: F401 'time' imported but unused
300:34:1: E302 expected 2 blank lines, found 1
300:42:67: E502 the backslash is redundant between brackets
300:47:67: E502 the backslash is redundant between brackets
300:67:53: E502 the backslash is redundant between brackets
300:122:9: E125 continuation line with same indent as next logical line
300:134:9: E125 continuation line with same indent as next logical line
300:185:52: E502 the backslash is redundant between brackets
300:186:72: E502 the backslash is redundant between brackets
300:285:77: E502 the backslash is redundant between brackets
300:305:77: E502 the backslash is redundant between brackets
300:306:78: E502 the backslash is redundant between brackets
300:330:77: E502 the backslash is redundant between brackets
300:350:77: E502 the backslash is redundant between brackets
300:385:57: E502 the backslash is redundant between brackets
300:386:59: E502 the backslash is redundant between brackets
300:387:67: E502 the backslash is redundant between brackets
300:412:78: E502 the backslash is redundant between brackets
300:425:78: E502 the backslash is redundant between brackets
300:435:78: E502 the backslash is redundant between brackets
300:436:76: E502 the backslash is redundant between brackets
300:451:66: E502 the backslash is redundant between brackets
300:473:78: E502 the backslash is redundant between brackets
300:474:79: E502 the backslash is redundant between brackets
300:488:78: E502 the backslash is redundant between brackets
300:489:77: E502 the backslash is redundant between brackets

- I post it just because ALE plugin in vim highlights all these things for me. 
Up to you, I don't ask you to fix it.

18.08.2020 16:32, Max Reitz wrote:

Signed-off-by: Max Reitz 
---
  tests/qemu-iotests/300 | 595 +
  tests/qemu-iotests/300.out |   5 +
  tests/qemu-iotests/group   |   1 +
  3 files changed, 601 insertions(+)
  create mode 100755 tests/qemu-iotests/300
  create mode 100644 tests/qemu-iotests/300.out



[..]


+def test_alias_on_both_migration(self) -> None:
+src_map = self.mapping(self.src_node_name, 'node-alias',
+   self.src_bmap_name, 'bmap-alias')
+
+dst_map = self.mapping(self.dst_node_name, 'node-alias',
+   self.dst_bmap_name, 'bmap-alias')
+
+self.set_mapping(self.vm_a, src_map)
+self.set_mapping(self.vm_b, dst_map)
+self.migrate()
+self.verify_dest_error(None)


Hmm, probably verify_dest_error() should be called from migrate(), as you call 
it (almost) always after migrate()


+
+


[..]


+def test_unused_mapping_on_dst(self) -> None:
+# Let the source not send any bitmaps
+self.set_mapping(self.vm_a, [])
+
+# Establish some mapping on the destination
+self.set_mapping(self.vm_b, [])


Seems, you wanted to specify non-empty mapping for vm_b, yes?
With any non-empty mapping here, just to better correspond to the comments:
Reviewed-by: Vladimir Sementsov-Ogievskiy 

(or keep this case with both mappings empty, and add one similar with empty 
mapping only on src)



--
Best regards,
Vladimir



Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-20 Thread Vladimir Sementsov-Ogievskiy

20.08.2020 16:17, Max Reitz wrote:

On 20.08.20 03:58, Eric Blake wrote:

On 8/18/20 8:32 AM, Max Reitz wrote:

Signed-off-by: Max Reitz 
---
   tests/qemu-iotests/300 | 595 +
   tests/qemu-iotests/300.out |   5 +


Rather sparse output (I hate debugging those sorts of outputs when the
test is failing).


Hm.  I don’t know, the stack trace usually gives a good idea and
./check -d gives QMP context.

The advantage of a sparse output is that we don’t need to adjust the
reference output every time some optional field is added somewhere.


   tests/qemu-iotests/group   |   1 +
   3 files changed, 601 insertions(+)
   create mode 100755 tests/qemu-iotests/300
   create mode 100644 tests/qemu-iotests/300.out




+    # Dirty some random megabytes
+    for _ in range(9):
+    mb_ofs = random.randrange(1024)
+    self.vm_a.hmp_qemu_io(self.src_node_name, f'write
{mb_ofs}M 1M')


It turns out that the discard operation likewise dirties the bitmap, but
slightly faster (see edb90bbd).  We could optimize it on top, but I'm
not going to require a micro-optimizing to get it in.  The test takes
about 12 seconds to run for me, but you didn't mark it as such in
'group', so that's good; but it turns up a problem:

300  fail   [20:55:54] [20:56:06]    output
mismatch (see 300.out.bad)
--- /home/eblake/qemu-tmp2/tests/qemu-iotests/300.out    2020-08-19
20:53:11.087791988 -0500
+++ /home/eblake/qemu-tmp2/tests/qemu-iotests/300.out.bad    2020-08-19
20:56:06.092428756 -0500
@@ -1,5 +1,41 @@
-.
+WARNING:qemu.machine:qemu received signal 11; command:
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../x86_64-softmmu/qemu-system-x86_64
-display none -vga none -chardev
socket,id=mon,path=/tmp/tmp.qT831UThme/qemu-b-798452-monitor.sock -mon
chardev=mon,mode=control -qtest
unix:path=/tmp/tmp.qT831UThme/qemu-b-798452-qtest.sock -accel qtest
-nodefaults -display none -accel qtest -blockdev
node-name=node0,driver=null-co -incoming unix:/tmp/tmp.qT831UThme/mig_sock"
+.FE...
+==
+ERROR: test_migratee_bitmap_is_not_mapped_on_dst
(__main__.TestBlockBitmapMappingErrors)
+--
+Traceback (most recent call last):
+  File
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
435, in _do_shutdown
+    self._soft_shutdown(timeout, has_quit)
+  File
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
415, in _soft_shutdown
+    self._qmp.cmd('quit')
+  File
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/qmp.py",
line 266, in cmd
+    return self.cmd_obj(qmp_cmd)
+  File
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/qmp.py",
line 246, in cmd_obj
+    self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8'))
+BrokenPipeError: [Errno 32] Broken pipe
+
+The above exception was the direct cause of the following exception:
+
+Traceback (most recent call last):
+  File "300", line 76, in tearDown
+    self.vm_b.shutdown()
+  File
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
465, in shutdown
+    self._do_shutdown(timeout, has_quit)
+  File
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
438, in _do_shutdown
+    raise AbnormalShutdown("Could not perform graceful shutdown") \
+qemu.machine.AbnormalShutdown: Could not perform graceful shutdown
+
+==
+FAIL: test_migratee_bitmap_is_not_mapped_on_dst
(__main__.TestBlockBitmapMappingErrors)
+--
+Traceback (most recent call last):
+  File "300", line 384, in test_migratee_bitmap_is_not_mapped_on_dst
+    self.migrate(False)
+  File "300", line 99, in migrate
+    self.assertEqual(self.vm_a.wait_migration('postmigrate'),
+AssertionError: False != True
+
  --
  Ran 37 tests

-OK
+FAILED (failures=1, errors=1)

I'm not sure why I'm seeing that, but it looks like you've got a bad
deref somewhere in the alias code.


Ah, crap.

This should fix it:

diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index 89cb16b12c..d407dfefea 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -1091,7 +1091,9 @@ static int dirty_bitmap_load_header(QEMUFile *f,
DBMLoadState *s,
  } else {
  bitmap_name = s->bitmap_alias;
  }
+}

+if (!s->cancelled) {
  g_strlcpy(s->bitmap_name, bitmap_name, sizeof(s->bitmap_name));
  s->bitmap = bdrv_find_dirty_bitmap(s->bs, s->bitmap_name);




That's correct thing to do


I had this originally, and then I decided to drop that hunk just be

Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-20 Thread Max Reitz
On 20.08.20 03:58, Eric Blake wrote:
> On 8/18/20 8:32 AM, Max Reitz wrote:
>> Signed-off-by: Max Reitz 
>> ---
>>   tests/qemu-iotests/300 | 595 +
>>   tests/qemu-iotests/300.out |   5 +
> 
> Rather sparse output (I hate debugging those sorts of outputs when the
> test is failing).

Hm.  I don’t know, the stack trace usually gives a good idea and
./check -d gives QMP context.

The advantage of a sparse output is that we don’t need to adjust the
reference output every time some optional field is added somewhere.

>>   tests/qemu-iotests/group   |   1 +
>>   3 files changed, 601 insertions(+)
>>   create mode 100755 tests/qemu-iotests/300
>>   create mode 100644 tests/qemu-iotests/300.out
>>
> 
>> +    # Dirty some random megabytes
>> +    for _ in range(9):
>> +    mb_ofs = random.randrange(1024)
>> +    self.vm_a.hmp_qemu_io(self.src_node_name, f'write
>> {mb_ofs}M 1M')
> 
> It turns out that the discard operation likewise dirties the bitmap, but
> slightly faster (see edb90bbd).  We could optimize it on top, but I'm
> not going to require a micro-optimizing to get it in.  The test takes
> about 12 seconds to run for me, but you didn't mark it as such in
> 'group', so that's good; but it turns up a problem:
> 
> 300  fail   [20:55:54] [20:56:06]    output
> mismatch (see 300.out.bad)
> --- /home/eblake/qemu-tmp2/tests/qemu-iotests/300.out    2020-08-19
> 20:53:11.087791988 -0500
> +++ /home/eblake/qemu-tmp2/tests/qemu-iotests/300.out.bad    2020-08-19
> 20:56:06.092428756 -0500
> @@ -1,5 +1,41 @@
> -.
> +WARNING:qemu.machine:qemu received signal 11; command:
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../x86_64-softmmu/qemu-system-x86_64
> -display none -vga none -chardev
> socket,id=mon,path=/tmp/tmp.qT831UThme/qemu-b-798452-monitor.sock -mon
> chardev=mon,mode=control -qtest
> unix:path=/tmp/tmp.qT831UThme/qemu-b-798452-qtest.sock -accel qtest
> -nodefaults -display none -accel qtest -blockdev
> node-name=node0,driver=null-co -incoming unix:/tmp/tmp.qT831UThme/mig_sock"
> +.FE...
> +==
> +ERROR: test_migratee_bitmap_is_not_mapped_on_dst
> (__main__.TestBlockBitmapMappingErrors)
> +--
> +Traceback (most recent call last):
> +  File
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
> 435, in _do_shutdown
> +    self._soft_shutdown(timeout, has_quit)
> +  File
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
> 415, in _soft_shutdown
> +    self._qmp.cmd('quit')
> +  File
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/qmp.py",
> line 266, in cmd
> +    return self.cmd_obj(qmp_cmd)
> +  File
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/qmp.py",
> line 246, in cmd_obj
> +    self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8'))
> +BrokenPipeError: [Errno 32] Broken pipe
> +
> +The above exception was the direct cause of the following exception:
> +
> +Traceback (most recent call last):
> +  File "300", line 76, in tearDown
> +    self.vm_b.shutdown()
> +  File
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
> 465, in shutdown
> +    self._do_shutdown(timeout, has_quit)
> +  File
> "/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", line
> 438, in _do_shutdown
> +    raise AbnormalShutdown("Could not perform graceful shutdown") \
> +qemu.machine.AbnormalShutdown: Could not perform graceful shutdown
> +
> +==
> +FAIL: test_migratee_bitmap_is_not_mapped_on_dst
> (__main__.TestBlockBitmapMappingErrors)
> +--
> +Traceback (most recent call last):
> +  File "300", line 384, in test_migratee_bitmap_is_not_mapped_on_dst
> +    self.migrate(False)
> +  File "300", line 99, in migrate
> +    self.assertEqual(self.vm_a.wait_migration('postmigrate'),
> +AssertionError: False != True
> +
>  --
>  Ran 37 tests
> 
> -OK
> +FAILED (failures=1, errors=1)
> 
> I'm not sure why I'm seeing that, but it looks like you've got a bad
> deref somewhere in the alias code.

Ah, crap.

This should fix it:

diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index 89cb16b12c..d407dfefea 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -1091,7 +1091,9 @@ static int dirty_bitmap_load_header(QEMUFile *f,
DBMLoadState *s,
 } else {
 bitmap_name = s->bitmap_alias;
 }
+}

+if (!s->cancelled) {
 g_strlcpy(s->bitmap_name, bitmap_name, sizeof(s->bitmap_name));
 s->bi

Re: [PATCH v4 4/4] iotests: Test node/bitmap aliases during migration

2020-08-19 Thread Eric Blake

On 8/18/20 8:32 AM, Max Reitz wrote:

Signed-off-by: Max Reitz 
---
  tests/qemu-iotests/300 | 595 +
  tests/qemu-iotests/300.out |   5 +


Rather sparse output (I hate debugging those sorts of outputs when the 
test is failing).



  tests/qemu-iotests/group   |   1 +
  3 files changed, 601 insertions(+)
  create mode 100755 tests/qemu-iotests/300
  create mode 100644 tests/qemu-iotests/300.out




+# Dirty some random megabytes
+for _ in range(9):
+mb_ofs = random.randrange(1024)
+self.vm_a.hmp_qemu_io(self.src_node_name, f'write {mb_ofs}M 1M')


It turns out that the discard operation likewise dirties the bitmap, but 
slightly faster (see edb90bbd).  We could optimize it on top, but I'm 
not going to require a micro-optimizing to get it in.  The test takes 
about 12 seconds to run for me, but you didn't mark it as such in 
'group', so that's good; but it turns up a problem:


300  fail   [20:55:54] [20:56:06]output 
mismatch (see 300.out.bad)
--- /home/eblake/qemu-tmp2/tests/qemu-iotests/300.out	2020-08-19 
20:53:11.087791988 -0500
+++ /home/eblake/qemu-tmp2/tests/qemu-iotests/300.out.bad	2020-08-19 
20:56:06.092428756 -0500

@@ -1,5 +1,41 @@
-.
+WARNING:qemu.machine:qemu received signal 11; command: 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../x86_64-softmmu/qemu-system-x86_64 
-display none -vga none -chardev 
socket,id=mon,path=/tmp/tmp.qT831UThme/qemu-b-798452-monitor.sock -mon 
chardev=mon,mode=control -qtest 
unix:path=/tmp/tmp.qT831UThme/qemu-b-798452-qtest.sock -accel qtest 
-nodefaults -display none -accel qtest -blockdev 
node-name=node0,driver=null-co -incoming unix:/tmp/tmp.qT831UThme/mig_sock"

+.FE...
+==
+ERROR: test_migratee_bitmap_is_not_mapped_on_dst 
(__main__.TestBlockBitmapMappingErrors)

+--
+Traceback (most recent call last):
+  File 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", 
line 435, in _do_shutdown

+self._soft_shutdown(timeout, has_quit)
+  File 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", 
line 415, in _soft_shutdown

+self._qmp.cmd('quit')
+  File 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/qmp.py", 
line 266, in cmd

+return self.cmd_obj(qmp_cmd)
+  File 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/qmp.py", 
line 246, in cmd_obj

+self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8'))
+BrokenPipeError: [Errno 32] Broken pipe
+
+The above exception was the direct cause of the following exception:
+
+Traceback (most recent call last):
+  File "300", line 76, in tearDown
+self.vm_b.shutdown()
+  File 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", 
line 465, in shutdown

+self._do_shutdown(timeout, has_quit)
+  File 
"/home/eblake/qemu-tmp2/tests/qemu-iotests/../../python/qemu/machine.py", 
line 438, in _do_shutdown

+raise AbnormalShutdown("Could not perform graceful shutdown") \
+qemu.machine.AbnormalShutdown: Could not perform graceful shutdown
+
+==
+FAIL: test_migratee_bitmap_is_not_mapped_on_dst 
(__main__.TestBlockBitmapMappingErrors)

+--
+Traceback (most recent call last):
+  File "300", line 384, in test_migratee_bitmap_is_not_mapped_on_dst
+self.migrate(False)
+  File "300", line 99, in migrate
+self.assertEqual(self.vm_a.wait_migration('postmigrate'),
+AssertionError: False != True
+
 --
 Ran 37 tests

-OK
+FAILED (failures=1, errors=1)

I'm not sure why I'm seeing that, but it looks like you've got a bad 
deref somewhere in the alias code.



+class TestLongBitmapNames(TestAliasMigration):
+# Giving long bitmap names is OK, as long as there is a short alias for
+# migration
+src_bmap_name = 'a' * 512
+dst_bmap_name = 'b' * 512


This part's new compared to v3 ;)  Looks like you've made several 
enhancements.


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org