Skip to contentSkip to conversation

qemu-iotests: Test streaming with missing job ID

PATCH In review Kevin Wolf 5 participants 7 messages May 15, 2017 – May 17, 2017

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qemu-iotests: Test streaming with missing job ID

This adds a small test for the image streaming error path for failing block_job_create(), which would have found the null pointer dereference in commit a170a91f.

---
 tests/qemu-iotests/030     | 4 ++++
 tests/qemu-iotests/030.out | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/qemu-iotests/030 +4 -0
index e00c11b..feee861 100755
@@ -147,6 +147,10 @@ class TestSingleDrive(iotests.QMPTestCase):
         result = self.vm.qmp('block-stream', device='nonexistent')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
+    def test_job_id_missing(self):
+        result = self.vm.qmp('block-stream', device='mid')
+        self.assert_qmp(result, 'error/class', 'GenericError')
+
 
 class TestParallelOps(iotests.QMPTestCase):
     num_ops = 4 # Number of parallel block-stream operations
tests/qemu-iotests/030.out +2 -2
index 84bfd63..391c857 100644
@@ -1,5 +1,5 @@
-......................
+.......................
 ----------------------------------------------------------------------
-Ran 22 tests
+Ran 23 tests
 
 OK
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 15 lines · Kevin Wolf

This adds a small test for the image streaming error path for failing block_job_create(), which would have found the null pointer dereference in commit a170a91f.

---
 tests/qemu-iotests/030     | 4 ++++
 tests/qemu-iotests/030.out | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/qemu-iotests/030 +0 -0
index e00c11b..feee861 100755

tests/qemu-iotests/030 class TestSingleDrive(iotests.QMPTestCase): · line 152

Quoted 6 lines
tests/qemu-iotests/030 +3 -0
@@ -147,6 +147,10 @@ class TestSingleDrive(iotests.QMPTestCase):
         result = self.vm.qmp('block-stream', device='nonexistent')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
+    def test_job_id_missing(self):
+        result = self.vm.qmp('block-stream', device='mid')
+        self.assert_qmp(result, 'error/class', 'GenericError')

Mmm... but does that trigger the bug?

The bug happens if the user tries to create a stream job on a BDS that:

a) exists
b) is not the active node (i.e. needs reopening in read-write mode)
c) its node name is not valid for a block job (e.g. it contains a '#')

Berto

author
#2 lore raw

Am 15.05.2017 um 14:46 hat Alberto Garcia geschrieben:

Quoted 25 lines · Kevin Wolf
Quoted 15 lines

This adds a small test for the image streaming error path for failing block_job_create(), which would have found the null pointer dereference in commit a170a91f.

---
 tests/qemu-iotests/030     | 4 ++++
 tests/qemu-iotests/030.out | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/qemu-iotests/030 +0 -0
index e00c11b..feee861 100755

tests/qemu-iotests/030 class TestSingleDrive(iotests.QMPTestCase): · line 152

Quoted 6 lines
tests/qemu-iotests/030 +3 -0
@@ -147,6 +147,10 @@ class TestSingleDrive(iotests.QMPTestCase):
         result = self.vm.qmp('block-stream', device='nonexistent')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
+    def test_job_id_missing(self):
+        result = self.vm.qmp('block-stream', device='mid')
+        self.assert_qmp(result, 'error/class', 'GenericError')

Mmm... but does that trigger the bug?

Quoted 5 lines

The bug happens if the user tries to create a stream job on a BDS that:

a) exists
b) is not the active node (i.e. needs reopening in read-write mode)
c) its node name is not valid for a block job (e.g. it contains a '#')

I don't think c) is necessary, block jobs that are owned by a BDS identified by a node name always require an explicit job ID. And yes, I did test that it actually breaks before your fix.

Kevin

Reviewed-by
#3 lore raw
Quoted 10 lines · Kevin Wolf
Quoted 7 lines

Mmm... but does that trigger the bug?

The bug happens if the user tries to create a stream job on a BDS that:

a) exists
b) is not the active node (i.e. needs reopening in read-write mode)
c) its node name is not valid for a block job (e.g. it contains a '#')

I don't think c) is necessary, block jobs that are owned by a BDS identified by a node name always require an explicit job ID.

It defaults to bdrv_get_device_name() if the job ID is not set, but in your case there's indeed none, so

Berto

Reviewed-by on v1 1/1
#4 lore raw
In reply to Kevin Wolf
Quoted 15 lines · Kevin Wolf

This adds a small test for the image streaming error path for failing block_job_create(), which would have found the null pointer dereference in commit a170a91f.

---
 tests/qemu-iotests/030     | 4 ++++
 tests/qemu-iotests/030.out | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/qemu-iotests/030 +0 -0
index e00c11b..feee861 100755

tests/qemu-iotests/030 class TestSingleDrive(iotests.QMPTestCase): · line 153

Quoted 7 lines
tests/qemu-iotests/030 +4 -0
@@ -147,6 +147,10 @@ class TestSingleDrive(iotests.QMPTestCase):
         result = self.vm.qmp('block-stream', device='nonexistent')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
+    def test_job_id_missing(self):
+        result = self.vm.qmp('block-stream', device='mid')
+        self.assert_qmp(result, 'error/class', 'GenericError')
+

Thanks.

FWIW:

[...]

Signature · 1 line
/kashyap
Reviewed-by on v1 1/1
#6 lore raw
In reply to Kevin Wolf
Quoted 6 lines · Kevin Wolf

This adds a small test for the image streaming error path for failing block_job_create(), which would have found the null pointer dereference in commit a170a91f.

---

Quoted 35 lines
 tests/qemu-iotests/030     | 4 ++++
 tests/qemu-iotests/030.out | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/qemu-iotests/030 +4 -0
index e00c11b..feee861 100755
@@ -147,6 +147,10 @@ class TestSingleDrive(iotests.QMPTestCase):
         result = self.vm.qmp('block-stream', device='nonexistent')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
+    def test_job_id_missing(self):
+        result = self.vm.qmp('block-stream', device='mid')
+        self.assert_qmp(result, 'error/class', 'GenericError')
+
 
 class TestParallelOps(iotests.QMPTestCase):
     num_ops = 4 # Number of parallel block-stream operations
tests/qemu-iotests/030.out +2 -2
index 84bfd63..391c857 100644
@@ -1,5 +1,5 @@
-......................
+.......................
 ----------------------------------------------------------------------
-Ran 22 tests
+Ran 23 tests
 
 OK
Signature · 1 line
1.8.3.1