qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH V8 36/39] chardev: cpr for sockets


From: Steven Sistare
Subject: Re: [PATCH V8 36/39] chardev: cpr for sockets
Date: Tue, 5 Jul 2022 14:29:53 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 7/3/2022 4:19 AM, Peng Liang wrote:
> On 6/15/2022 10:52 PM, Steve Sistare wrote:
>> Save accepted socket fds before cpr-save, and look for them after cpr-load.
>> Block cpr-exec if a socket enables the TLS or websocket option.  Allow a
>> monitor socket by closing it on exec.
>>
>> Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
>>  chardev/char-socket.c         | 45 
>> +++++++++++++++++++++++++++++++++++++++++++
>>  include/chardev/char-socket.h |  1 +
>>  monitor/hmp.c                 |  3 +++
>>  monitor/qmp.c                 |  3 +++
>>  4 files changed, 52 insertions(+)
>>
>> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
>> index dc4e218..3a1e36b 100644
>> --- a/chardev/char-socket.c
>> +++ b/chardev/char-socket.c
>> @@ -26,6 +26,7 @@
>>  #include "chardev/char.h"
>>  #include "io/channel-socket.h"
>>  #include "io/channel-websock.h"
>> +#include "migration/cpr.h"
>>  #include "qemu/error-report.h"
>>  #include "qemu/module.h"
>>  #include "qemu/option.h"
>> @@ -33,6 +34,7 @@
>>  #include "qapi/clone-visitor.h"
>>  #include "qapi/qapi-visit-sockets.h"
>>  #include "qemu/yank.h"
>> +#include "sysemu/sysemu.h"
>>  
>>  #include "chardev/char-io.h"
>>  #include "chardev/char-socket.h"
>> @@ -358,6 +360,11 @@ static void tcp_chr_free_connection(Chardev *chr)
>>      SocketChardev *s = SOCKET_CHARDEV(chr);
>>      int i;
>>  
>> +    if (chr->cpr_enabled) {
>> +        cpr_delete_fd(chr->label, 0);
>> +    }
>> +    cpr_del_blocker(&s->cpr_blocker);
>> +
>>      if (s->read_msgfds_num) {
>>          for (i = 0; i < s->read_msgfds_num; i++) {
>>              close(s->read_msgfds[i]);
>> @@ -923,6 +930,10 @@ static void tcp_chr_accept(QIONetListener *listener,
>>                                 QIO_CHANNEL(cioc));
>>      }
>>      tcp_chr_new_client(chr, cioc);
>> +
>> +    if (s->sioc && chr->cpr_enabled) {
>> +        cpr_resave_fd(chr->label, 0, s->sioc->fd, NULL);
>> +    }
>>  }
>>  
>>  
>> @@ -1178,6 +1189,26 @@ static gboolean socket_reconnect_timeout(gpointer 
>> opaque)
>>      return false;
>>  }
>>  
>> +static int load_char_socket_fd(Chardev *chr, Error **errp)
>> +{
>> +    SocketChardev *sockchar = SOCKET_CHARDEV(chr);
>> +    QIOChannelSocket *sioc;
>> +    const char *label = chr->label;
>> +    int fd = cpr_find_fd(label, 0);
>> +
>> +    if (fd != -1) {
>> +        sockchar = SOCKET_CHARDEV(chr);
>> +        sioc = qio_channel_socket_new_fd(fd, errp);
>> +        if (sioc) {
>> +            tcp_chr_accept(sockchar->listener, sioc, chr);
>> +            object_unref(OBJECT(sioc));
>> +        } else {
>> +            error_setg(errp, "could not restore socket for %s", label);
> 
> If we go here, then qio_channel_socket_new_fd fails and errp should be set. 
> So I think
> error_prepend is more appropriate here.

Good suggestion, will do, thanks - Steve

[...]



reply via email to

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