[PATCH v2 1/2] migration/tls: fix inverted semantics in multifd_channel_connect

Hao Wang posted 2 patches 5 years ago
Maintainers: Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>
[PATCH v2 1/2] migration/tls: fix inverted semantics in multifd_channel_connect
Posted by Hao Wang 5 years ago
Function multifd_channel_connect() return "true" to indicate failure,
which is rather confusing. Fix that.

Signed-off-by: Hao Wang <wanghao232@huawei.com>
---
 migration/multifd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/migration/multifd.c b/migration/multifd.c
index 1a1e589064..2a1ea85ade 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -798,9 +798,9 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
                  * function after the TLS handshake,
                  * so we mustn't call multifd_send_thread until then
                  */
-                return false;
-            } else {
                 return true;
+            } else {
+                return false;
             }
         } else {
             /* update for tls qio channel */
@@ -808,10 +808,10 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
             qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
                                    QEMU_THREAD_JOINABLE);
        }
-       return false;
+       return true;
     }
 
-    return true;
+    return false;
 }
 
 static void multifd_new_send_channel_cleanup(MultiFDSendParams *p,
@@ -844,7 +844,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque)
         p->c = QIO_CHANNEL(sioc);
         qio_channel_set_delay(p->c, false);
         p->running = true;
-        if (multifd_channel_connect(p, sioc, local_err)) {
+        if (!multifd_channel_connect(p, sioc, local_err)) {
             goto cleanup;
         }
         return;
-- 
2.23.0


Re: [PATCH v2 1/2] migration/tls: fix inverted semantics in multifd_channel_connect
Posted by Daniel P. Berrangé 5 years ago
On Tue, Feb 09, 2021 at 06:42:36PM +0800, Hao Wang wrote:
> Function multifd_channel_connect() return "true" to indicate failure,
> which is rather confusing. Fix that.
> 
> Signed-off-by: Hao Wang <wanghao232@huawei.com>
> ---
>  migration/multifd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH v2 1/2] migration/tls: fix inverted semantics in multifd_channel_connect
Posted by Zheng Chuan 4 years, 11 months ago
Reviewed-by: Chuan Zheng <zhengchuan@huawei.com>

On 2021/2/9 18:42, Hao Wang wrote:
> Function multifd_channel_connect() return "true" to indicate failure,
> which is rather confusing. Fix that.
> 
> Signed-off-by: Hao Wang <wanghao232@huawei.com>
> ---
>  migration/multifd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/multifd.c b/migration/multifd.c
> index 1a1e589064..2a1ea85ade 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -798,9 +798,9 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
>                   * function after the TLS handshake,
>                   * so we mustn't call multifd_send_thread until then
>                   */
> -                return false;
> -            } else {
>                  return true;
> +            } else {
> +                return false;
>              }
>          } else {
>              /* update for tls qio channel */
> @@ -808,10 +808,10 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
>              qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
>                                     QEMU_THREAD_JOINABLE);
>         }
> -       return false;
> +       return true;
>      }
>  
> -    return true;
> +    return false;
>  }
>  
>  static void multifd_new_send_channel_cleanup(MultiFDSendParams *p,
> @@ -844,7 +844,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque)
>          p->c = QIO_CHANNEL(sioc);
>          qio_channel_set_delay(p->c, false);
>          p->running = true;
> -        if (multifd_channel_connect(p, sioc, local_err)) {
> +        if (!multifd_channel_connect(p, sioc, local_err)) {
>              goto cleanup;
>          }
>          return;
> 

-- 
Regards.
Chuan