qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix
@ 2018-12-15 12:03 Li Qiang
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read Li Qiang
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Li Qiang @ 2018-12-15 12:03 UTC (permalink / raw)
  To: thuth, lvivier, pbonzini, mst, peter.maydell, marcandre.lureau,
	berrange, jasowang
  Cc: liq3ea, qemu-devel, Li Qiang

Currently, the vhost-user-test is not correct.
When in qtest mode, the accel is qtest, not kvm.
So when the client side of vhost-user-test send
'VHOST_USER_SET_VRING_CALL' msg, the 'fd' will
no be added in 'fds' in 'vhost_set_vring_file'.
In 'chr_read' of the server side in the 
vhost-user-test, it calls 'qemu_chr_fe_get_msgfds'
to get the fd in 'VHOST_USER_SET_VRING_CALL'. Though
there is no fd returned, but as the 'fd' is not initialized
so 'fd' maybe valid, and 'qemu_set_nonblock' will be success.
Even worse, 'qemu_set_nonblock' doesn't check the return value
of fcntl.

So this cause the interesting bug here: there are three issues,
but they combined and will bypass the qtest.

This patchset tries to address these issue.

v2: Change the second patch per Paolo's review

Li Qiang (3):
  tests: vhost-user-test: initialize 'fd' in chr_read
  vhost-user: fix ioeventfd_enabled
  util: check the return value of fcntl in qemu_set_{block,nonblock}

 hw/virtio/vhost-user.c  | 2 +-
 tests/vhost-user-test.c | 2 +-
 util/oslib-posix.c      | 8 ++++++--
 3 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read
  2018-12-15 12:03 [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
@ 2018-12-15 12:03 ` Li Qiang
  2019-01-02 13:50   ` Thomas Huth
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 2/3] vhost-user: fix ioeventfd_enabled Li Qiang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Li Qiang @ 2018-12-15 12:03 UTC (permalink / raw)
  To: thuth, lvivier, pbonzini, mst, peter.maydell, marcandre.lureau,
	berrange, jasowang
  Cc: liq3ea, qemu-devel, Li Qiang

Currently when processing VHOST_USER_SET_VRING_CALL
if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will
be a stack uninitialized value.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 tests/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 45d58d8ea2..86039e61e0 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     CharBackend *chr = &s->chr;
     VhostUserMsg msg;
     uint8_t *p = (uint8_t *) &msg;
-    int fd;
+    int fd = -1;
 
     if (s->test_fail) {
         qemu_chr_fe_disconnect(chr);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH v2 2/3] vhost-user: fix ioeventfd_enabled
  2018-12-15 12:03 [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read Li Qiang
@ 2018-12-15 12:03 ` Li Qiang
  2019-01-14 23:22   ` Michael S. Tsirkin
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock} Li Qiang
  2018-12-24  1:08 ` [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
  3 siblings, 1 reply; 12+ messages in thread
From: Li Qiang @ 2018-12-15 12:03 UTC (permalink / raw)
  To: thuth, lvivier, pbonzini, mst, peter.maydell, marcandre.lureau,
	berrange, jasowang
  Cc: liq3ea, qemu-devel, Li Qiang

Currently, the vhost-user-test assumes the eventfd is available.
However it's not true because the accel is qtest. So the
'vhost_set_vring_file' will not add fds to the msg and the server
side of vhost-user-test will be broken. The bug is in 'ioeventfd_enabled'.
We should make this function return true if not using kvm accel.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
v2: change the fix in 'ioeventfd_enabled' per Paolo's review

 hw/virtio/vhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index e09bed0e4a..564a31d12c 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -207,7 +207,7 @@ struct vhost_user {
 
 static bool ioeventfd_enabled(void)
 {
-    return kvm_enabled() && kvm_eventfds_enabled();
+    return !kvm_enabled() || kvm_eventfds_enabled();
 }
 
 static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock}
  2018-12-15 12:03 [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read Li Qiang
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 2/3] vhost-user: fix ioeventfd_enabled Li Qiang
@ 2018-12-15 12:03 ` Li Qiang
  2019-01-02 14:07   ` Thomas Huth
  2018-12-24  1:08 ` [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
  3 siblings, 1 reply; 12+ messages in thread
From: Li Qiang @ 2018-12-15 12:03 UTC (permalink / raw)
  To: thuth, lvivier, pbonzini, mst, peter.maydell, marcandre.lureau,
	berrange, jasowang
  Cc: liq3ea, qemu-devel, Li Qiang

Assert that the return value is not an error. This is like commit
7e6478e7d4f for qemu_set_cloexec.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 util/oslib-posix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index c1bee2a581..4ce1ba9ca4 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -233,14 +233,18 @@ void qemu_set_block(int fd)
 {
     int f;
     f = fcntl(fd, F_GETFL);
-    fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
+    assert(f != -1);
+    f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
+    assert(f != -1);
 }
 
 void qemu_set_nonblock(int fd)
 {
     int f;
     f = fcntl(fd, F_GETFL);
-    fcntl(fd, F_SETFL, f | O_NONBLOCK);
+    assert(f != -1);
+    f = fcntl(fd, F_SETFL, f | O_NONBLOCK);
+    assert(f != -1);
 }
 
 int socket_set_fast_reuse(int fd)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix
  2018-12-15 12:03 [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
                   ` (2 preceding siblings ...)
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock} Li Qiang
@ 2018-12-24  1:08 ` Li Qiang
  3 siblings, 0 replies; 12+ messages in thread
From: Li Qiang @ 2018-12-24  1:08 UTC (permalink / raw)
  To: Li Qiang
  Cc: Thomas Huth, lvivier, Paolo Bonzini, mst, Peter Maydell,
	marcandre lureau, Daniel P. Berrange, Jason Wang, Qemu Developers

Ping..

Li Qiang <liq3ea@163.com> 于2018年12月15日周六 下午8:06写道:

> Currently, the vhost-user-test is not correct.
> When in qtest mode, the accel is qtest, not kvm.
> So when the client side of vhost-user-test send
> 'VHOST_USER_SET_VRING_CALL' msg, the 'fd' will
> no be added in 'fds' in 'vhost_set_vring_file'.
> In 'chr_read' of the server side in the
> vhost-user-test, it calls 'qemu_chr_fe_get_msgfds'
> to get the fd in 'VHOST_USER_SET_VRING_CALL'. Though
> there is no fd returned, but as the 'fd' is not initialized
> so 'fd' maybe valid, and 'qemu_set_nonblock' will be success.
> Even worse, 'qemu_set_nonblock' doesn't check the return value
> of fcntl.
>
> So this cause the interesting bug here: there are three issues,
> but they combined and will bypass the qtest.
>
> This patchset tries to address these issue.
>
> v2: Change the second patch per Paolo's review
>
> Li Qiang (3):
>   tests: vhost-user-test: initialize 'fd' in chr_read
>   vhost-user: fix ioeventfd_enabled
>   util: check the return value of fcntl in qemu_set_{block,nonblock}
>
>  hw/virtio/vhost-user.c  | 2 +-
>  tests/vhost-user-test.c | 2 +-
>  util/oslib-posix.c      | 8 ++++++--
>  3 files changed, 8 insertions(+), 4 deletions(-)
>
> --
> 2.17.1
>
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read Li Qiang
@ 2019-01-02 13:50   ` Thomas Huth
  2019-01-02 14:55     ` Michael S. Tsirkin
  2019-01-03  4:23     ` Li Qiang
  0 siblings, 2 replies; 12+ messages in thread
From: Thomas Huth @ 2019-01-02 13:50 UTC (permalink / raw)
  To: Li Qiang, lvivier, pbonzini, mst, peter.maydell, marcandre.lureau,
	berrange, jasowang
  Cc: liq3ea, qemu-devel

On 2018-12-15 13:03, Li Qiang wrote:
> Currently when processing VHOST_USER_SET_VRING_CALL
> if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will
> be a stack uninitialized value.
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  tests/vhost-user-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index 45d58d8ea2..86039e61e0 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
>      CharBackend *chr = &s->chr;
>      VhostUserMsg msg;
>      uint8_t *p = (uint8_t *) &msg;
> -    int fd;
> +    int fd = -1;
>  
>      if (s->test_fail) {
>          qemu_chr_fe_disconnect(chr);
> 

Shouldn't we also rather check the return code of
qemu_chr_fe_get_msgfds() ? Anyway, initializing fd to -1 here sounds
like a good idea, so:

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock}
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock} Li Qiang
@ 2019-01-02 14:07   ` Thomas Huth
  2019-01-02 14:55     ` Michael S. Tsirkin
  2019-01-14 23:24     ` Michael S. Tsirkin
  0 siblings, 2 replies; 12+ messages in thread
From: Thomas Huth @ 2019-01-02 14:07 UTC (permalink / raw)
  To: Li Qiang, mst
  Cc: lvivier, pbonzini, peter.maydell, marcandre.lureau, berrange,
	jasowang, liq3ea, qemu-devel

On 2018-12-15 13:03, Li Qiang wrote:
> Assert that the return value is not an error. This is like commit
> 7e6478e7d4f for qemu_set_cloexec.
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  util/oslib-posix.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index c1bee2a581..4ce1ba9ca4 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -233,14 +233,18 @@ void qemu_set_block(int fd)
>  {
>      int f;
>      f = fcntl(fd, F_GETFL);
> -    fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> +    assert(f != -1);
> +    f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> +    assert(f != -1);
>  }
>  
>  void qemu_set_nonblock(int fd)
>  {
>      int f;
>      f = fcntl(fd, F_GETFL);
> -    fcntl(fd, F_SETFL, f | O_NONBLOCK);
> +    assert(f != -1);
> +    f = fcntl(fd, F_SETFL, f | O_NONBLOCK);
> +    assert(f != -1);
>  }

Reviewed-by: Thomas Huth <thuth@redhat.com>

Michael, could you take this patch series through your vhost tree? Or
shall I pick them up for the qtests tree? In the latter case, please
provide an ACK for the second patch.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read
  2019-01-02 13:50   ` Thomas Huth
@ 2019-01-02 14:55     ` Michael S. Tsirkin
  2019-01-03  4:23     ` Li Qiang
  1 sibling, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-01-02 14:55 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Li Qiang, lvivier, pbonzini, peter.maydell, marcandre.lureau,
	berrange, jasowang, liq3ea, qemu-devel

On Wed, Jan 02, 2019 at 02:50:50PM +0100, Thomas Huth wrote:
> On 2018-12-15 13:03, Li Qiang wrote:
> > Currently when processing VHOST_USER_SET_VRING_CALL
> > if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will
> > be a stack uninitialized value.
> > 
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  tests/vhost-user-test.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> > index 45d58d8ea2..86039e61e0 100644
> > --- a/tests/vhost-user-test.c
> > +++ b/tests/vhost-user-test.c
> > @@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
> >      CharBackend *chr = &s->chr;
> >      VhostUserMsg msg;
> >      uint8_t *p = (uint8_t *) &msg;
> > -    int fd;
> > +    int fd = -1;
> >  
> >      if (s->test_fail) {
> >          qemu_chr_fe_disconnect(chr);
> > 
> 
> Shouldn't we also rather check the return code of
> qemu_chr_fe_get_msgfds() ? Anyway, initializing fd to -1 here sounds
> like a good idea, so:
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock}
  2019-01-02 14:07   ` Thomas Huth
@ 2019-01-02 14:55     ` Michael S. Tsirkin
  2019-01-14 23:24     ` Michael S. Tsirkin
  1 sibling, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-01-02 14:55 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Li Qiang, lvivier, pbonzini, peter.maydell, marcandre.lureau,
	berrange, jasowang, liq3ea, qemu-devel

On Wed, Jan 02, 2019 at 03:07:24PM +0100, Thomas Huth wrote:
> On 2018-12-15 13:03, Li Qiang wrote:
> > Assert that the return value is not an error. This is like commit
> > 7e6478e7d4f for qemu_set_cloexec.
> > 
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  util/oslib-posix.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> > index c1bee2a581..4ce1ba9ca4 100644
> > --- a/util/oslib-posix.c
> > +++ b/util/oslib-posix.c
> > @@ -233,14 +233,18 @@ void qemu_set_block(int fd)
> >  {
> >      int f;
> >      f = fcntl(fd, F_GETFL);
> > -    fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> > +    assert(f != -1);
> > +    f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> > +    assert(f != -1);
> >  }
> >  
> >  void qemu_set_nonblock(int fd)
> >  {
> >      int f;
> >      f = fcntl(fd, F_GETFL);
> > -    fcntl(fd, F_SETFL, f | O_NONBLOCK);
> > +    assert(f != -1);
> > +    f = fcntl(fd, F_SETFL, f | O_NONBLOCK);
> > +    assert(f != -1);
> >  }
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
> Michael, could you take this patch series through your vhost tree? Or
> shall I pick them up for the qtests tree? In the latter case, please
> provide an ACK for the second patch.

Pls go ahead and merge it.

-- 
MST

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read
  2019-01-02 13:50   ` Thomas Huth
  2019-01-02 14:55     ` Michael S. Tsirkin
@ 2019-01-03  4:23     ` Li Qiang
  1 sibling, 0 replies; 12+ messages in thread
From: Li Qiang @ 2019-01-03  4:23 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Li Qiang, lvivier, Paolo Bonzini, mst, Peter Maydell,
	marcandre lureau, Daniel P. Berrange, Jason Wang, Qemu Developers

Thomas Huth <thuth@redhat.com> 于2019年1月2日周三 下午9:50写道:

> On 2018-12-15 13:03, Li Qiang wrote:
> > Currently when processing VHOST_USER_SET_VRING_CALL
> > if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will
> > be a stack uninitialized value.
> >
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  tests/vhost-user-test.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> > index 45d58d8ea2..86039e61e0 100644
> > --- a/tests/vhost-user-test.c
> > +++ b/tests/vhost-user-test.c
> > @@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t
> *buf, int size)
> >      CharBackend *chr = &s->chr;
> >      VhostUserMsg msg;
> >      uint8_t *p = (uint8_t *) &msg;
> > -    int fd;
> > +    int fd = -1;
> >
> >      if (s->test_fail) {
> >          qemu_chr_fe_disconnect(chr);
> >
>
> Shouldn't we also rather check the return code of
> qemu_chr_fe_get_msgfds() ?


Agree, there are several places need to do this. I will send out a patch
later.

Thanks,
Li Qiang


> Anyway, initializing fd to -1 here sounds
> like a good idea, so:
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/3] vhost-user: fix ioeventfd_enabled
  2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 2/3] vhost-user: fix ioeventfd_enabled Li Qiang
@ 2019-01-14 23:22   ` Michael S. Tsirkin
  0 siblings, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-01-14 23:22 UTC (permalink / raw)
  To: Li Qiang
  Cc: thuth, lvivier, pbonzini, peter.maydell, marcandre.lureau,
	berrange, jasowang, liq3ea, qemu-devel

On Sat, Dec 15, 2018 at 04:03:52AM -0800, Li Qiang wrote:
> Currently, the vhost-user-test assumes the eventfd is available.
> However it's not true because the accel is qtest. So the
> 'vhost_set_vring_file' will not add fds to the msg and the server
> side of vhost-user-test will be broken. The bug is in 'ioeventfd_enabled'.
> We should make this function return true if not using kvm accel.
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> v2: change the fix in 'ioeventfd_enabled' per Paolo's review
> 
>  hw/virtio/vhost-user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index e09bed0e4a..564a31d12c 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -207,7 +207,7 @@ struct vhost_user {
>  
>  static bool ioeventfd_enabled(void)
>  {
> -    return kvm_enabled() && kvm_eventfds_enabled();
> +    return !kvm_enabled() || kvm_eventfds_enabled();
>  }
>  
>  static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
> -- 
> 2.17.1
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock}
  2019-01-02 14:07   ` Thomas Huth
  2019-01-02 14:55     ` Michael S. Tsirkin
@ 2019-01-14 23:24     ` Michael S. Tsirkin
  1 sibling, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-01-14 23:24 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Li Qiang, lvivier, peter.maydell, jasowang, liq3ea, qemu-devel,
	marcandre.lureau, pbonzini

On Wed, Jan 02, 2019 at 03:07:24PM +0100, Thomas Huth wrote:
> On 2018-12-15 13:03, Li Qiang wrote:
> > Assert that the return value is not an error. This is like commit
> > 7e6478e7d4f for qemu_set_cloexec.
> > 
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  util/oslib-posix.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> > index c1bee2a581..4ce1ba9ca4 100644
> > --- a/util/oslib-posix.c
> > +++ b/util/oslib-posix.c
> > @@ -233,14 +233,18 @@ void qemu_set_block(int fd)
> >  {
> >      int f;
> >      f = fcntl(fd, F_GETFL);
> > -    fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> > +    assert(f != -1);
> > +    f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> > +    assert(f != -1);
> >  }
> >  
> >  void qemu_set_nonblock(int fd)
> >  {
> >      int f;
> >      f = fcntl(fd, F_GETFL);
> > -    fcntl(fd, F_SETFL, f | O_NONBLOCK);
> > +    assert(f != -1);
> > +    f = fcntl(fd, F_SETFL, f | O_NONBLOCK);
> > +    assert(f != -1);
> >  }
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
> Michael, could you take this patch series through your vhost tree? Or
> shall I pick them up for the qtests tree? In the latter case, please
> provide an ACK for the second patch.

Did not see it merged so I merged it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-01-14 23:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-15 12:03 [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang
2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 1/3] tests: vhost-user-test: initialize 'fd' in chr_read Li Qiang
2019-01-02 13:50   ` Thomas Huth
2019-01-02 14:55     ` Michael S. Tsirkin
2019-01-03  4:23     ` Li Qiang
2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 2/3] vhost-user: fix ioeventfd_enabled Li Qiang
2019-01-14 23:22   ` Michael S. Tsirkin
2018-12-15 12:03 ` [Qemu-devel] [PATCH v2 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock} Li Qiang
2019-01-02 14:07   ` Thomas Huth
2019-01-02 14:55     ` Michael S. Tsirkin
2019-01-14 23:24     ` Michael S. Tsirkin
2018-12-24  1:08 ` [Qemu-devel] [PATCH v2 0/3] vhost-user-test fix Li Qiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).