[Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID

Kevin Wolf posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1494851980-6831-1-git-send-email-kwolf@redhat.com
Test checkpatch passed
Test docker passed
Test s390x passed
tests/qemu-iotests/030     | 4 ++++
tests/qemu-iotests/030.out | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Kevin Wolf 6 years, 11 months ago
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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/030     | 4 ++++
 tests/qemu-iotests/030.out | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index e00c11b..feee861 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -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
diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out
index 84bfd63..391c857 100644
--- a/tests/qemu-iotests/030.out
+++ b/tests/qemu-iotests/030.out
@@ -1,5 +1,5 @@
-......................
+.......................
 ----------------------------------------------------------------------
-Ran 22 tests
+Ran 23 tests
 
 OK
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Alberto Garcia 6 years, 11 months ago
On Mon 15 May 2017 02:39:40 PM CEST, Kevin Wolf wrote:
> 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.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  tests/qemu-iotests/030     | 4 ++++
>  tests/qemu-iotests/030.out | 4 ++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> index e00c11b..feee861 100755
> --- a/tests/qemu-iotests/030
> +++ b/tests/qemu-iotests/030
> @@ -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

Re: [Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Kevin Wolf 6 years, 11 months ago
Am 15.05.2017 um 14:46 hat Alberto Garcia geschrieben:
> On Mon 15 May 2017 02:39:40 PM CEST, Kevin Wolf wrote:
> > 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.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  tests/qemu-iotests/030     | 4 ++++
> >  tests/qemu-iotests/030.out | 4 ++--
> >  2 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> > index e00c11b..feee861 100755
> > --- a/tests/qemu-iotests/030
> > +++ b/tests/qemu-iotests/030
> > @@ -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 '#')

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

Re: [Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Alberto Garcia 6 years, 11 months ago
On Mon 15 May 2017 03:05:00 PM CEST, Kevin Wolf wrote:
>> 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

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

Re: [Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Kashyap Chamarthy 6 years, 11 months ago
On Mon, May 15, 2017 at 02:39:40PM +0200, Kevin Wolf wrote:
> 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  tests/qemu-iotests/030     | 4 ++++
>  tests/qemu-iotests/030.out | 4 ++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> index e00c11b..feee861 100755
> --- a/tests/qemu-iotests/030
> +++ b/tests/qemu-iotests/030
> @@ -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:

Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>

[...]

-- 
/kashyap

Re: [Qemu-devel] [Qemu-block] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Stefan Hajnoczi 6 years, 11 months ago
On Mon, May 15, 2017 at 02:39:40PM +0200, Kevin Wolf wrote:
> 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  tests/qemu-iotests/030     | 4 ++++
>  tests/qemu-iotests/030.out | 4 ++--
>  2 files changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Re: [Qemu-devel] [PATCH] qemu-iotests: Test streaming with missing job ID
Posted by Jeff Cody 6 years, 11 months ago
On Mon, May 15, 2017 at 02:39:40PM +0200, Kevin Wolf wrote:
> 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---

Reviewed-by: Jeff Cody <jcody@redhat.com>


>  tests/qemu-iotests/030     | 4 ++++
>  tests/qemu-iotests/030.out | 4 ++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> index e00c11b..feee861 100755
> --- a/tests/qemu-iotests/030
> +++ b/tests/qemu-iotests/030
> @@ -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
> diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out
> index 84bfd63..391c857 100644
> --- a/tests/qemu-iotests/030.out
> +++ b/tests/qemu-iotests/030.out
> @@ -1,5 +1,5 @@
> -......................
> +.......................
>  ----------------------------------------------------------------------
> -Ran 22 tests
> +Ran 23 tests
>  
>  OK
> -- 
> 1.8.3.1
> 
>