qemu-iotests: Test streaming with missing job ID
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
@@ -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
@@ -1,5 +1,5 @@ -...................... +....................... ---------------------------------------------------------------------- -Ran 22 tests +Ran 23 tests OK
Signature · 1 line
1.8.3.1
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 commita170a91f.Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/030 | 4 ++++ tests/qemu-iotests/030.out | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)tests/qemu-iotests/030 +0
-0
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
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 commita170a91f.Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/030 | 4 ++++ tests/qemu-iotests/030.out | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)tests/qemu-iotests/030 +0
-0tests/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
Alberto Garcia
Reviewed-byQuoted 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
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 commita170a91f.Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/030 | 4 ++++ tests/qemu-iotests/030.out | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)tests/qemu-iotests/030 +0
-0
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
Quoted 9 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 commita170a91f.Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/030 | 4 ++++ tests/qemu-iotests/030.out | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
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 commita170a91f.Signed-off-by Kevin Wolf <[email protected]>---
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@@ -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 operationstests/qemu-iotests/030.out +2
-2@@ -1,5 +1,5 @@ -...................... +....................... ---------------------------------------------------------------------- -Ran 22 tests +Ran 23 tests OKSignature · 1 line
1.8.3.1