qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Peter Maydell <peter.maydell@linaro.org>, Eric Blake <eblake@redhat.com>
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PULL 1/9] qapi: Add InetSocketAddress member keep-alive
Date: Tue, 10 Sep 2019 07:56:45 +0000	[thread overview]
Message-ID: <1722e8ab-1a2b-311e-63fb-d89387b72c2f@virtuozzo.com> (raw)
In-Reply-To: <CAFEAcA-ic=jdSvzOiNCEWmuhXythc2MQGYZYgV=3CBBT2RkEoQ@mail.gmail.com>

09.09.2019 20:32, Peter Maydell wrote:
> On Thu, 15 Aug 2019 at 19:34, Eric Blake <eblake@redhat.com> wrote:
>>
>> From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>
>> It's needed to provide keepalive for nbd client to track server
>> availability.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> Message-Id: <20190725094937.32454-1-vsementsov@virtuozzo.com>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>> Acked-by: Daniel P. Berrangé <berrange@redhat.com>
>> [eblake: Fix error message typo]
>> Signed-off-by: Eric Blake <eblake@redhat.com>
> 
> Hi; Coverity spots a bug in this change (CID 1405300):

Two coverity bugs on my patches, I'm sorry :(

How can I run this coverity locally?

> 
>> @@ -458,6 +464,19 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
>>       }
> 
> At this point in the function, we might be in one of
> two cases:
>   (1) sock >= 0 : the connect succeeded
>   (2) sock < 0 : connect failed, we have just called
>       error_propagate() and are using the same end-of-function
>       codepath to free 'res' before returning the error code.
> 
>>
>>       freeaddrinfo(res);
>> +
>> +    if (saddr->keep_alive) {
>> +        int val = 1;
>> +        int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
>> +                                  &val, sizeof(val));
> 
> ...but here we use 'sock' assuming it is valid.
> 
>> +
>> +        if (ret < 0) {
>> +            error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
>> +            close(sock);
>> +            return -1;
>> +        }
>> +    }
>> +
>>       return sock;
>>   }
> 
> If we want to add more "actual work" at this point in
> the function we should probably separate out the failed-case
> codepath, eg by changing
> 
> 
>      if (sock < 0) {
>          error_propagate(errp, local_err);
>      }
> 
>      freeaddrinfo(res);
> 
> into
> 
>      freeaddrinfo(res);
> 
>      if (sock < 0) {
>          error_propagate(errp, local_err);
>          return sock;
>      }
> 
> 
> 
> thanks
> -- PMM
> 

Thanks, this should work, I'll send a patch soon.

-- 
Best regards,
Vladimir

  reply	other threads:[~2019-09-10  7:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 18:30 [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 1/9] qapi: Add InetSocketAddress member keep-alive Eric Blake
2019-09-09 17:32   ` Peter Maydell
2019-09-10  7:56     ` Vladimir Sementsov-Ogievskiy [this message]
2019-09-10  8:10       ` Peter Maydell
2019-08-15 18:30 ` [Qemu-devel] [PULL 2/9] block: implement BDRV_REQ_PREFETCH Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 3/9] block/stream: use BDRV_REQ_PREFETCH Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 4/9] nbd: improve CMD_CACHE: " Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 5/9] block/nbd: split connection_co start out of nbd_client_connect Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 6/9] block/nbd: use non-blocking io channel for nbd negotiation Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 7/9] block/nbd: move from quit to state Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 8/9] block/nbd: add cmdline and qapi parameter reconnect-delay Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 9/9] block/nbd: refactor nbd connection parameters Eric Blake
2019-08-16 15:43 ` [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1722e8ab-1a2b-311e-63fb-d89387b72c2f@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).