diff mbox series

[v4,06/18] migration/rdma: export MultiFDSendParams/MultiFDRecvParams

Message ID 1612339311-114805-7-git-send-email-zhengchuan@huawei.com (mailing list archive)
State New, archived
Headers show
Series Support Multifd for RDMA migration | expand

Commit Message

Zheng Chuan Feb. 3, 2021, 8:01 a.m. UTC
MultiFDSendParams and MultiFDRecvParams is need for rdma, export it

Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
---
 migration/multifd.c | 26 ++++++++++++++++++++++++++
 migration/multifd.h |  2 ++
 2 files changed, 28 insertions(+)

Comments

Dr. David Alan Gilbert Feb. 3, 2021, 6:23 p.m. UTC | #1
* Chuan Zheng (zhengchuan@huawei.com) wrote:
> MultiFDSendParams and MultiFDRecvParams is need for rdma, export it
> 
> Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>

I think these become simpler if you just return a NULL on error,
also I think you can make 'id' unsigned and then you don't have
to worry about it being negative.

Also, please make it start with multifd_ so we know where it's coming
from; so:

MultiFDSendParams *multifd_send_param_get(unsigned channel);

Dave

> ---
>  migration/multifd.c | 26 ++++++++++++++++++++++++++
>  migration/multifd.h |  2 ++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/migration/multifd.c b/migration/multifd.c
> index 5d34950..ae0b7f0 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -390,6 +390,19 @@ struct {
>      MultiFDSetup *setup_ops;
>  } *multifd_send_state;
>  
> +int get_multifd_send_param(int id, MultiFDSendParams **param)
> +{
> +    int ret = 0;
> +
> +    if (id < 0 || id >= migrate_multifd_channels()) {
> +        ret = -1;
> +    } else {
> +        *param = &(multifd_send_state->params[id]);
> +    }
> +
> +    return ret;
> +}
> +
>  /*
>   * How we use multifd_send_state->pages and channel->pages?
>   *
> @@ -934,6 +947,19 @@ struct {
>      MultiFDSetup *setup_ops;
>  } *multifd_recv_state;
>  
> +int get_multifd_recv_param(int id, MultiFDRecvParams **param)
> +{
> +    int ret = 0;
> +
> +    if (id < 0 || id >= migrate_multifd_channels()) {
> +        ret = -1;
> +    } else {
> +        *param = &(multifd_recv_state->params[id]);
> +    }
> +
> +    return ret;
> +}
> +
>  static void multifd_recv_terminate_threads(Error *err)
>  {
>      int i;
> diff --git a/migration/multifd.h b/migration/multifd.h
> index e3ab4b0..d57756c 100644
> --- a/migration/multifd.h
> +++ b/migration/multifd.h
> @@ -176,6 +176,8 @@ typedef struct {
>  #ifdef CONFIG_RDMA
>  extern MultiFDSetup multifd_rdma_ops;
>  #endif
> +int get_multifd_send_param(int id, MultiFDSendParams **param);
> +int get_multifd_recv_param(int id, MultiFDRecvParams **param);
>  MultiFDSetup *multifd_setup_ops_init(void);
>  
>  void multifd_register_ops(int method, MultiFDMethods *ops);
> -- 
> 1.8.3.1
>
Zheng Chuan March 1, 2021, 12:26 p.m. UTC | #2
On 2021/2/4 2:23, Dr. David Alan Gilbert wrote:
> * Chuan Zheng (zhengchuan@huawei.com) wrote:
>> MultiFDSendParams and MultiFDRecvParams is need for rdma, export it
>>
>> Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
>> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
> 
> I think these become simpler if you just return a NULL on error,
> also I think you can make 'id' unsigned and then you don't have
> to worry about it being negative.
> 
Yes, that's a good point, I will do that in v5.

> Also, please make it start with multifd_ so we know where it's coming
> from; so:
> 
> MultiFDSendParams *multifd_send_param_get(unsigned channel);
> 
> Dave

OK, will do that in next version.

>> ---
>>  migration/multifd.c | 26 ++++++++++++++++++++++++++
>>  migration/multifd.h |  2 ++
>>  2 files changed, 28 insertions(+)
>>
>> diff --git a/migration/multifd.c b/migration/multifd.c
>> index 5d34950..ae0b7f0 100644
>> --- a/migration/multifd.c
>> +++ b/migration/multifd.c
>> @@ -390,6 +390,19 @@ struct {
>>      MultiFDSetup *setup_ops;
>>  } *multifd_send_state;
>>  
>> +int get_multifd_send_param(int id, MultiFDSendParams **param)
>> +{
>> +    int ret = 0;
>> +
>> +    if (id < 0 || id >= migrate_multifd_channels()) {
>> +        ret = -1;
>> +    } else {
>> +        *param = &(multifd_send_state->params[id]);
>> +    }
>> +
>> +    return ret;
>> +}
>> +
>>  /*
>>   * How we use multifd_send_state->pages and channel->pages?
>>   *
>> @@ -934,6 +947,19 @@ struct {
>>      MultiFDSetup *setup_ops;
>>  } *multifd_recv_state;
>>  
>> +int get_multifd_recv_param(int id, MultiFDRecvParams **param)
>> +{
>> +    int ret = 0;
>> +
>> +    if (id < 0 || id >= migrate_multifd_channels()) {
>> +        ret = -1;
>> +    } else {
>> +        *param = &(multifd_recv_state->params[id]);
>> +    }
>> +
>> +    return ret;
>> +}
>> +
>>  static void multifd_recv_terminate_threads(Error *err)
>>  {
>>      int i;
>> diff --git a/migration/multifd.h b/migration/multifd.h
>> index e3ab4b0..d57756c 100644
>> --- a/migration/multifd.h
>> +++ b/migration/multifd.h
>> @@ -176,6 +176,8 @@ typedef struct {
>>  #ifdef CONFIG_RDMA
>>  extern MultiFDSetup multifd_rdma_ops;
>>  #endif
>> +int get_multifd_send_param(int id, MultiFDSendParams **param);
>> +int get_multifd_recv_param(int id, MultiFDRecvParams **param);
>>  MultiFDSetup *multifd_setup_ops_init(void);
>>  
>>  void multifd_register_ops(int method, MultiFDMethods *ops);
>> -- 
>> 1.8.3.1
>>
diff mbox series

Patch

diff --git a/migration/multifd.c b/migration/multifd.c
index 5d34950..ae0b7f0 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -390,6 +390,19 @@  struct {
     MultiFDSetup *setup_ops;
 } *multifd_send_state;
 
+int get_multifd_send_param(int id, MultiFDSendParams **param)
+{
+    int ret = 0;
+
+    if (id < 0 || id >= migrate_multifd_channels()) {
+        ret = -1;
+    } else {
+        *param = &(multifd_send_state->params[id]);
+    }
+
+    return ret;
+}
+
 /*
  * How we use multifd_send_state->pages and channel->pages?
  *
@@ -934,6 +947,19 @@  struct {
     MultiFDSetup *setup_ops;
 } *multifd_recv_state;
 
+int get_multifd_recv_param(int id, MultiFDRecvParams **param)
+{
+    int ret = 0;
+
+    if (id < 0 || id >= migrate_multifd_channels()) {
+        ret = -1;
+    } else {
+        *param = &(multifd_recv_state->params[id]);
+    }
+
+    return ret;
+}
+
 static void multifd_recv_terminate_threads(Error *err)
 {
     int i;
diff --git a/migration/multifd.h b/migration/multifd.h
index e3ab4b0..d57756c 100644
--- a/migration/multifd.h
+++ b/migration/multifd.h
@@ -176,6 +176,8 @@  typedef struct {
 #ifdef CONFIG_RDMA
 extern MultiFDSetup multifd_rdma_ops;
 #endif
+int get_multifd_send_param(int id, MultiFDSendParams **param);
+int get_multifd_recv_param(int id, MultiFDRecvParams **param);
 MultiFDSetup *multifd_setup_ops_init(void);
 
 void multifd_register_ops(int method, MultiFDMethods *ops);