qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH V2 18/22] chardev: cpr for sockets


From: Steven Sistare
Subject: Re: [PATCH V2 18/22] chardev: cpr for sockets
Date: Tue, 5 Jan 2021 11:35:10 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 1/5/2021 11:22 AM, Daniel P. Berrangé wrote:
> On Tue, Jan 05, 2021 at 07:42:06AM -0800, Steve Sistare wrote:
>> Define qio_channel_socket_reuse to initialize a channel based on an existing
>> socket fd.  Save accepted socket fds in the environment before cprsave, and
>> look for fds in the environment after cprload.  Reject cprsave if a socket
>> enables the TLS or websocket option.
>>
>> Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
>>  chardev/char-socket.c       | 30 ++++++++++++++++++++++++++++++
>>  include/io/channel-socket.h | 12 ++++++++++++
>>  io/channel-socket.c         |  9 +++++++++
>>  stubs/Makefile.objs         |  1 +
>>  stubs/cpr.c                 |  3 +++
>>  5 files changed, 55 insertions(+)
>>  create mode 100644 stubs/cpr.c
>>
> 
>> diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h
>> index 777ff59..e425a01 100644
>> --- a/include/io/channel-socket.h
>> +++ b/include/io/channel-socket.h
>> @@ -260,5 +260,17 @@ QIOChannelSocket *
>>  qio_channel_socket_accept(QIOChannelSocket *ioc,
>>                            Error **errp);
>>  
>> +/**
>> + * qio_channel_socket_reuse:
>> + * @fd: existing client socket descriptor
>> + * @errp: pointer to a NULL-initialized error object
>> + *
>> + * Construct a client channel using @fd.
>> + *
>> + * Returns: the new client channel, or NULL on error
>> + */
>> +QIOChannelSocket *
>> +qio_channel_socket_reuse(int fd,
>> +                         Error **errp);
>>  
>>  #endif /* QIO_CHANNEL_SOCKET_H */
>> diff --git a/io/channel-socket.c b/io/channel-socket.c
>> index de49880..07981be 100644
>> --- a/io/channel-socket.c
>> +++ b/io/channel-socket.c
>> @@ -400,6 +400,15 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
>>      return NULL;
>>  }
>>  
>> +QIOChannelSocket *
>> +qio_channel_socket_reuse(int fd,
>> +                         Error **errp)
>> +{
>> +    QIOChannelSocket *cioc = qio_channel_socket_new();
>> +    cioc->fd = fd;
>> +    return qio_channel_socket_post_accept(cioc, errp) ? 0 : cioc;
>> +}
> 
> Why do we need to add this new API when we already have
> 
>  qio_channel_socket_new_fd(int fd, Error **errp)
> 
> which accepts a pre-opened socket FD ?

That was fast!
Good call, thanks.  I missed that qio_channel_socket_new_fd calls 
qio_channel_socket_set_fd and
the latter performs the necessary post-accept actions.  I will also delete 
patch 17.

- Steve



reply via email to

[Prev in Thread] Current Thread [Next in Thread]