Skip to contentSkip to conversation

qemu-iotests: prefill some data to test image

PATCH In review Fam Zheng 4 participants 11 messages Oct 30, 2013 – Nov 7, 2013

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v2 1/1 qemu-iotests: prefill some data to test image

Case 030 occasionally fails because of block job compltes too fast to be captured by script, and 'unexpected qmp event' of job completion causes the test failure.

Simply fill in some data to the test image to make this false alarm less likely to happen.

(For other benefits to prefill data to test image, see also commit ab68cdfaa).

---
v2: subsequent to "qemu-iotests: fix 030 for faster machines".

---
 tests/qemu-iotests/030 | 4 ++++
 1 file changed, 4 insertions(+)
tests/qemu-iotests/030 +4 -0
index ae56f3b..d0f96ea 100755
@@ -388,7 +388,9 @@ class TestStreamStop(iotests.QMPTestCase):
 
     def setUp(self):
         qemu_img('create', backing_img, str(TestStreamStop.image_len))
+        qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
+        qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
 
@@ -414,7 +416,9 @@ class TestSetSpeed(iotests.QMPTestCase):
 
     def setUp(self):
         qemu_img('create', backing_img, str(TestSetSpeed.image_len))
+        qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
+        qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
 
Signature · 1 line
1.8.3.1
#1 lore raw

Am 30.10.2013 um 10:42 hat Fam Zheng geschrieben:

Quoted 10 lines

Case 030 occasionally fails because of block job compltes too fast to be captured by script, and 'unexpected qmp event' of job completion causes the test failure.

Simply fill in some data to the test image to make this false alarm less likely to happen.

(For other benefits to prefill data to test image, see also commit ab68cdfaa).

Quoted 6 lines

---
v2: subsequent to "qemu-iotests: fix 030 for faster machines".

Did you try using blkdebug to make it deterministic instead of just making failure less likely?

Kevin

author
#2 lore raw
Quoted 13 lines · Kevin Wolf

Am 30.10.2013 um 10:42 hat Fam Zheng geschrieben:

Quoted 12 lines

Case 030 occasionally fails because of block job compltes too fast to be captured by script, and 'unexpected qmp event' of job completion causes the test failure.

Simply fill in some data to the test image to make this false alarm less likely to happen.

(For other benefits to prefill data to test image, see also commit ab68cdfaa).

Quoted 7 lines
Quoted 4 lines

---
v2: subsequent to "qemu-iotests: fix 030 for faster machines".

Did you try using blkdebug to make it deterministic instead of just making failure less likely?

Yes. blkdebug relies on actual IO, but using images with no data doesn't trigger any IO and just completes. Prefilling is the prerequisite to use that. This alone already works very well for me, but blkdebug is good to have, too.

Suspending before starting the block job is obviously the way to do, but resuming before cancel_and_wait is not deterministic, either, in the same way. We'll need to add cancel_and_resume_and_wait().

Do you like me to respin or use a follow up patch?

Fam

#3 lore raw

Am 30.10.2013 um 12:31 hat Fam Zheng geschrieben:

Quoted 17 lines · Kevin Wolf
Quoted 16 lines

Am 30.10.2013 um 10:42 hat Fam Zheng geschrieben:

Quoted 15 lines

Case 030 occasionally fails because of block job compltes too fast to be captured by script, and 'unexpected qmp event' of job completion causes the test failure.

Simply fill in some data to the test image to make this false alarm less likely to happen.

(For other benefits to prefill data to test image, see also commit ab68cdfaa).

---
v2: subsequent to "qemu-iotests: fix 030 for faster machines".

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Did you try using blkdebug to make it deterministic instead of just making failure less likely?

Yes. blkdebug relies on actual IO, but using images with no data doesn't trigger any IO and just completes. Prefilling is the prerequisite to use that. This alone already works very well for me, but blkdebug is good to have, too.

That's actually a good point.

Quoted 5 lines

Suspending before starting the block job is obviously the way to do, but resuming before cancel_and_wait is not deterministic, either, in the same way. We'll need to add cancel_and_resume_and_wait().

Do you like me to respin or use a follow up patch?

A follow-up patch works for me.

Kevin

author
#4 lore raw

PATCH v3 1/1 qemu-iotests: use blkdebug to make test deterministic

In reply to Fam Zheng

This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status.

---
 tests/qemu-iotests/030        | 10 ++++++----
 tests/qemu-iotests/iotests.py |  5 ++++-
 2 files changed, 10 insertions(+), 5 deletions(-)
tests/qemu-iotests/030 +6 -4
index d0f96ea..bc66e6f 100755
@@ -391,7 +391,7 @@ class TestStreamStop(iotests.QMPTestCase):
         qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive("blkdebug::" + test_img)
         self.vm.launch()
 
     def tearDown(self):
@@ -402,6 +402,7 @@ class TestStreamStop(iotests.QMPTestCase):
     def test_stream_stop(self):
         self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
         result = self.vm.qmp('block-stream', device='drive0')
         self.assert_qmp(result, 'return', {})
 
@@ -409,7 +410,7 @@ class TestStreamStop(iotests.QMPTestCase):
         events = self.vm.get_qmp_events(wait=False)
         self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
 class TestSetSpeed(iotests.QMPTestCase):
     image_len = 80 * 1024 * 1024 # MB
@@ -419,7 +420,7 @@ class TestSetSpeed(iotests.QMPTestCase):
         qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
         self.vm.launch()
 
     def tearDown(self):
@@ -453,6 +454,7 @@ class TestSetSpeed(iotests.QMPTestCase):
     def test_set_speed(self):
         self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
         result = self.vm.qmp('block-stream', device='drive0')
         self.assert_qmp(result, 'return', {})
 
@@ -469,7 +471,7 @@ class TestSetSpeed(iotests.QMPTestCase):
         self.assert_qmp(result, 'return[0]/device', 'drive0')
         self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
         # Check setting speed in block-stream works
         result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024)
tests/qemu-iotests/iotests.py +4 -1
index fb10ff4..de45079 100644
@@ -222,11 +222,14 @@ class QMPTestCase(unittest.TestCase):
         result = self.vm.qmp('query-block-jobs')
         self.assert_qmp(result, 'return', [])
 
-    def cancel_and_wait(self, drive='drive0', force=False):
+    def cancel_and_wait(self, drive='drive0', force=False, resume=""):
         '''Cancel a block job and wait for it to finish, returning the event'''
         result = self.vm.qmp('block-job-cancel', device=drive, force=force)
         self.assert_qmp(result, 'return', {})
 
+        if resume:
+            self.vm.qmp('human-monitor-command', command_line='qemu-io %s "resume %s"' % (drive, resume))
+
         cancelled = False
         result = None
         while not cancelled:
Signature · 1 line
1.8.3.1
#5 lore raw

Re: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic

Quoted 8 lines · Fam Zheng

This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status.

---
 tests/qemu-iotests/030        | 10 ++++++----
 tests/qemu-iotests/iotests.py |  5 ++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

./check -qcow2 030 hangs with this patch applied.

Can you reproduce it or am I missing something?

Stefan

author
#6 lore raw

Re: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic

Quoted 10 lines · Stefan Hajnoczi
Quoted 8 lines · Fam Zheng

This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status.

---
  tests/qemu-iotests/030        | 10 ++++++----
  tests/qemu-iotests/iotests.py |  5 ++++-
  2 files changed, 10 insertions(+), 5 deletions(-)
Quoted 4 lines

./check -qcow2 030 hangs with this patch applied.

Can you reproduce it or am I missing something?

Yes, Occasionally. I'll look into it.

Fam

#7 lore raw

Re: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic

In reply to Fam Zheng

Il 31/10/2013 03:18, Fam Zheng ha scritto:

Quoted 76 lines

This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status.

---
 tests/qemu-iotests/030        | 10 ++++++----
 tests/qemu-iotests/iotests.py |  5 ++++-
 2 files changed, 10 insertions(+), 5 deletions(-)
tests/qemu-iotests/030 +6 -4
index d0f96ea..bc66e6f 100755
@@ -391,7 +391,7 @@ class TestStreamStop(iotests.QMPTestCase):
         qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive("blkdebug::" + test_img)
         self.vm.launch()
 
     def tearDown(self):
@@ -402,6 +402,7 @@ class TestStreamStop(iotests.QMPTestCase):
     def test_stream_stop(self):
         self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
         result = self.vm.qmp('block-stream', device='drive0')
         self.assert_qmp(result, 'return', {})
 
@@ -409,7 +410,7 @@ class TestStreamStop(iotests.QMPTestCase):
         events = self.vm.get_qmp_events(wait=False)
         self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
 class TestSetSpeed(iotests.QMPTestCase):
     image_len = 80 * 1024 * 1024 # MB
@@ -419,7 +420,7 @@ class TestSetSpeed(iotests.QMPTestCase):
         qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
         self.vm.launch()
 
     def tearDown(self):
@@ -453,6 +454,7 @@ class TestSetSpeed(iotests.QMPTestCase):
     def test_set_speed(self):
         self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
         result = self.vm.qmp('block-stream', device='drive0')
         self.assert_qmp(result, 'return', {})
 
@@ -469,7 +471,7 @@ class TestSetSpeed(iotests.QMPTestCase):
         self.assert_qmp(result, 'return[0]/device', 'drive0')
         self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
         # Check setting speed in block-stream works
         result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024)
tests/qemu-iotests/iotests.py +1 -1
index fb10ff4..de45079 100644
@@ -222,11 +222,14 @@ class QMPTestCase(unittest.TestCase):
         result = self.vm.qmp('query-block-jobs')
         self.assert_qmp(result, 'return', [])
 
-    def cancel_and_wait(self, drive='drive0', force=False):
+    def cancel_and_wait(self, drive='drive0', force=False, resume=""):

tests/qemu-iotests/iotests.py class QMPTestCase(unittest.TestCase): · line 235

Quoted 10 lines
tests/qemu-iotests/iotests.py +3 -0
         '''Cancel a block job and wait for it to finish, returning the event'''
         result = self.vm.qmp('block-job-cancel', device=drive, force=force)
         self.assert_qmp(result, 'return', {})
 
+        if resume:
+            self.vm.qmp('human-monitor-command', command_line='qemu-io %s "resume %s"' % (drive, resume))
+
         cancelled = False
         result = None
         while not cancelled:

Can you do the same for the mirror test too?

Paolo

author
#8 lore raw

Re: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic

Quoted 80 lines · Paolo Bonzini

Il 31/10/2013 03:18, Fam Zheng ha scritto:

Quoted 79 lines

This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status.

---
  tests/qemu-iotests/030        | 10 ++++++----
  tests/qemu-iotests/iotests.py |  5 ++++-
  2 files changed, 10 insertions(+), 5 deletions(-)
tests/qemu-iotests/030 +6 -4
index d0f96ea..bc66e6f 100755
@@ -391,7 +391,7 @@ class TestStreamStop(iotests.QMPTestCase):
          qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
          qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
          qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive("blkdebug::" + test_img)
          self.vm.launch()
 
      def tearDown(self):
@@ -402,6 +402,7 @@ class TestStreamStop(iotests.QMPTestCase):
      def test_stream_stop(self):
          self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
          result = self.vm.qmp('block-stream', device='drive0')
          self.assert_qmp(result, 'return', {})
 
@@ -409,7 +410,7 @@ class TestStreamStop(iotests.QMPTestCase):
          events = self.vm.get_qmp_events(wait=False)
          self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
  class TestSetSpeed(iotests.QMPTestCase):
      image_len = 80 * 1024 * 1024 # MB
@@ -419,7 +420,7 @@ class TestSetSpeed(iotests.QMPTestCase):
          qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
          qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
          qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
          self.vm.launch()
 
      def tearDown(self):
@@ -453,6 +454,7 @@ class TestSetSpeed(iotests.QMPTestCase):
      def test_set_speed(self):
          self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
          result = self.vm.qmp('block-stream', device='drive0')
          self.assert_qmp(result, 'return', {})
 
@@ -469,7 +471,7 @@ class TestSetSpeed(iotests.QMPTestCase):
          self.assert_qmp(result, 'return[0]/device', 'drive0')
          self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
          # Check setting speed in block-stream works
          result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024)
tests/qemu-iotests/iotests.py +1 -1
index fb10ff4..de45079 100644
@@ -222,11 +222,14 @@ class QMPTestCase(unittest.TestCase):
          result = self.vm.qmp('query-block-jobs')
          self.assert_qmp(result, 'return', [])
 
-    def cancel_and_wait(self, drive='drive0', force=False):
+    def cancel_and_wait(self, drive='drive0', force=False, resume=""):
          '''Cancel a block job and wait for it to finish, returning the event'''
          result = self.vm.qmp('block-job-cancel', device=drive, force=force)
          self.assert_qmp(result, 'return', {})
 
Quoted 9 lines

tests/qemu-iotests/iotests.py class QMPTestCase(unittest.TestCase): · line 235

Quoted 7 lines
tests/qemu-iotests/iotests.py +3 -0
+        if resume:
+            self.vm.qmp('human-monitor-command', command_line='qemu-io %s "resume %s"' % (drive, resume))
+
          cancelled = False
          result = None
          while not cancelled:

Can you do the same for the mirror test too?

Yes, of course.

Fam

author
#9 lore raw

Re: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic

In reply to Paolo Bonzini
Quoted 80 lines · Paolo Bonzini

Il 31/10/2013 03:18, Fam Zheng ha scritto:

Quoted 79 lines

This patch suspends the test image IO before starting block stream job so that it doesn't complete before we could check the status.

---
  tests/qemu-iotests/030        | 10 ++++++----
  tests/qemu-iotests/iotests.py |  5 ++++-
  2 files changed, 10 insertions(+), 5 deletions(-)
tests/qemu-iotests/030 +6 -4
index d0f96ea..bc66e6f 100755
@@ -391,7 +391,7 @@ class TestStreamStop(iotests.QMPTestCase):
          qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
          qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
          qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive("blkdebug::" + test_img)
          self.vm.launch()
 
      def tearDown(self):
@@ -402,6 +402,7 @@ class TestStreamStop(iotests.QMPTestCase):
      def test_stream_stop(self):
          self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
          result = self.vm.qmp('block-stream', device='drive0')
          self.assert_qmp(result, 'return', {})
 
@@ -409,7 +410,7 @@ class TestStreamStop(iotests.QMPTestCase):
          events = self.vm.get_qmp_events(wait=False)
          self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
  class TestSetSpeed(iotests.QMPTestCase):
      image_len = 80 * 1024 * 1024 # MB
@@ -419,7 +420,7 @@ class TestSetSpeed(iotests.QMPTestCase):
          qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
          qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
          qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
-        self.vm = iotests.VM().add_drive(test_img)
+        self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
          self.vm.launch()
 
      def tearDown(self):
@@ -453,6 +454,7 @@ class TestSetSpeed(iotests.QMPTestCase):
      def test_set_speed(self):
          self.assert_no_active_block_jobs()
 
+        self.vm.qmp('human-monitor-command', command_line='qemu-io drive0 "break write_aio a"')
          result = self.vm.qmp('block-stream', device='drive0')
          self.assert_qmp(result, 'return', {})
 
@@ -469,7 +471,7 @@ class TestSetSpeed(iotests.QMPTestCase):
          self.assert_qmp(result, 'return[0]/device', 'drive0')
          self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024)
 
-        self.cancel_and_wait()
+        self.cancel_and_wait(resume='a')
 
          # Check setting speed in block-stream works
          result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024)
tests/qemu-iotests/iotests.py +1 -1
index fb10ff4..de45079 100644
@@ -222,11 +222,14 @@ class QMPTestCase(unittest.TestCase):
          result = self.vm.qmp('query-block-jobs')
          self.assert_qmp(result, 'return', [])
 
-    def cancel_and_wait(self, drive='drive0', force=False):
+    def cancel_and_wait(self, drive='drive0', force=False, resume=""):
          '''Cancel a block job and wait for it to finish, returning the event'''
          result = self.vm.qmp('block-job-cancel', device=drive, force=force)
          self.assert_qmp(result, 'return', {})
 
Quoted 10 lines

tests/qemu-iotests/iotests.py class QMPTestCase(unittest.TestCase): · line 235

Quoted 7 lines
tests/qemu-iotests/iotests.py +3 -0
+        if resume:
+            self.vm.qmp('human-monitor-command', command_line='qemu-io %s "resume %s"' % (drive, resume))
+
          cancelled = False
          result = None
          while not cancelled:

Can you do the same for the mirror test too?

Paolo,

Mirror doesn't complete automatically, so we don't need the sequence:

1) Pause IO on device.
2) Start job.
3) Send block job cancel/complete command to wire.
4) Resume IO.

Block stream/commit/backup need because without step 1) the job could complete after 2) but before 3), so the block-job-complete may get an error return (no job no device).

Is it?

So I'll review commit and backup cases then.

Fam

#10 lore raw

Re: [Qemu-devel] [PATCH v3] qemu-iotests: use blkdebug to make test deterministic

Il 07/11/2013 12:25, Fam Zheng ha scritto:

Quoted 7 lines

Mirror doesn't complete automatically, so we don't need the sequence:

1) Pause IO on device.
2) Start job.
3) Send block job cancel/complete command to wire.
4) Resume IO.

Quoted 5 lines

Block stream/commit/backup need because without step 1) the job could complete after 2) but before 3), so the block-job-complete may get an error return (no job no device).

Is it?

Yes.

Quoted 1 line

So I'll review commit and backup cases then.

Yes.

Paolo