From nobody Thu May 9 01:12:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594758803; cv=none; d=zohomail.com; s=zohoarc; b=SBX+psmH0sz1LdkRH06nnr7HLs6hoU/ftFjvyHqjhev9SyMecjn1PtR2xoOTuhVHiy1/vEkFrhTwB0xMPaYV+fBc8DQnlnHXCH5+QIAHqJ4BsT7SywbSBpbE8H+7Tk0/wSIYiNh4YN3vJ11uzc2veRAGMmk0/d0lAJIzwNj+t8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594758803; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g6emAdWZabThoTYjhjPmOWCtgNA9yn3NYiGPcDA81mc=; b=m6kt/kcAb4oqpOO+VvaDaI4h8IAj6gbdHZYkh1iEWmzHpKJ+4K5j/5hZT9d9PbvAw74eFiUB3+KNt895WAxdaefnzQFhnAVIGvgV8ww8zqQb7RLgNN2Jv/Vy9qD9U0NxzG5Ay3PtozcODNkFmXKjsHgvp0dW/H7yAXppTWJpfUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594758803253998.3289568567627; Tue, 14 Jul 2020 13:33:23 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-h7uCTqm8OViBmB7xao-tXQ-1; Tue, 14 Jul 2020 16:33:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DEAE107ACCA; Tue, 14 Jul 2020 20:33:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DF835FC31; Tue, 14 Jul 2020 20:33:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E342372F54; Tue, 14 Jul 2020 20:33:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06EKX8h7007918 for ; Tue, 14 Jul 2020 16:33:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43E98710BE; Tue, 14 Jul 2020 20:33:08 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.95]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A0771710D2 for ; Tue, 14 Jul 2020 20:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594758802; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=g6emAdWZabThoTYjhjPmOWCtgNA9yn3NYiGPcDA81mc=; b=Kju7a7glZA8KrnXre1kFWoYn3MlnYlWegl/xV5bVuMI1De4+OE6esKRuXbFnFeIeb0ZCxd A3Gb1jIQ8wtcN3J9qJEmF/1CsQdocm7Abs61YdLvfV3P6b1YCLM/5xiHjNsUv6cUtmBudb 4wPgZqcje0ScZXddSwJ56XcNrFQHNB8= X-MC-Unique: h7uCTqm8OViBmB7xao-tXQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] tests: Don't assume IPv4 connectivity is available Date: Tue, 14 Jul 2020 22:32:59 +0200 Message-Id: <20200714203300.657891-2-abologna@redhat.com> In-Reply-To: <20200714203300.657891-1-abologna@redhat.com> References: <20200714203300.657891-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If the host doesn't have a single IPv4 address assigned to any of its interfaces, not even the loopback one, then virnetsockettest will fail with Cannot identify IPv4/6 availability because, while the IPv6 bind attempt is conditional, the IPv4 one is not, and in this case it will always fail. This commit is better viewed with 'git show -w'. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 78fb9cbffd..f56e623cb3 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -56,8 +56,10 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6, =20 for (i =3D 0; i < 50; i++) { int only =3D 1; - if ((s4 =3D socket(AF_INET, SOCK_STREAM, 0)) < 0) - goto cleanup; + if (*hasIPv4) { + if ((s4 =3D socket(AF_INET, SOCK_STREAM, 0)) < 0) + goto cleanup; + } =20 if (*hasIPv6) { if ((s6 =3D socket(AF_INET6, SOCK_STREAM, 0)) < 0) @@ -77,13 +79,15 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6, in6.sin6_port =3D htons(BASE_PORT + i); in6.sin6_addr =3D in6addr_loopback; =20 - if (bind(s4, (struct sockaddr *)&in4, sizeof(in4)) < 0) { - if (errno =3D=3D EADDRINUSE) { - VIR_FORCE_CLOSE(s4); - VIR_FORCE_CLOSE(s6); - continue; + if (*hasIPv4) { + if (bind(s4, (struct sockaddr *)&in4, sizeof(in4)) < 0) { + if (errno =3D=3D EADDRINUSE) { + VIR_FORCE_CLOSE(s4); + VIR_FORCE_CLOSE(s6); + continue; + } + goto cleanup; } - goto cleanup; } =20 if (*hasIPv6) { --=20 2.25.4 From nobody Thu May 9 01:12:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594758816; cv=none; d=zohomail.com; s=zohoarc; b=GOvIfUCdim0j5f8TijAQCtvrIL1YuP2lqyfp3TuxsyODkXZu5Q/Kh7kL/gxB/28P1wBSuAOygyiNU2szBpfsjaO9f+Cs6DZH2ghkS33cFbbwgdnIZjkOPqKiZmuAWpeocl200J9zBZzR5COhvHeRIqq3JCjT03xZoO1JDtrw0O8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594758816; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gl1BCyoGj7ZzUHOSWtqrIgYStcygvys8fm37SVwW15w=; b=g+/ti+1+aX2NnsQpKpOlhNbEtSzBccM3kH10tts9Si3RuHBLBIePOR5RROPlryvqj1Eghkf22vAb/cbKJDFRG1d4n0UEeyp6FOjh/W6VKoFfroFkGhR046uc1rOf8CVLLig9LYoqGKKGlx29cF1aDbLVD84EpesjoT459vOcG7g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594758816558957.9480969804941; Tue, 14 Jul 2020 13:33:36 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-smYbdtt_Oea8eB7pM_6Trg-1; Tue, 14 Jul 2020 16:33:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB5791B2C996; Tue, 14 Jul 2020 20:33:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB01B78A4D; Tue, 14 Jul 2020 20:33:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8867A1809557; Tue, 14 Jul 2020 20:33:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06EKX9sX007926 for ; Tue, 14 Jul 2020 16:33:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 49E2B710C3; Tue, 14 Jul 2020 20:33:09 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.95]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A20DE710BE for ; Tue, 14 Jul 2020 20:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594758815; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Gl1BCyoGj7ZzUHOSWtqrIgYStcygvys8fm37SVwW15w=; b=fzLe43Dgf8YAHEJ1oi8t4IsTGp0cC2rnbZNKeT3rvcL5jQCgklwYY9/zxHgxpe1ue8qZYO nAHkQpOY6YT8zPk0Tq3bJzuoHOaIWUUFTh0es97HTD4MzzXvbLegw4ehqlFp0RfZHpRLYV JaAZ7m0TjNZM1uTikIcdkRa9ekDl6tw= X-MC-Unique: smYbdtt_Oea8eB7pM_6Trg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] tests: Minimize variable scope Date: Tue, 14 Jul 2020 22:33:00 +0200 Message-Id: <20200714203300.657891-3-abologna@redhat.com> In-Reply-To: <20200714203300.657891-1-abologna@redhat.com> References: <20200714203300.657891-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index f56e623cb3..96c582216c 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -55,13 +55,14 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6, return -1; =20 for (i =3D 0; i < 50; i++) { - int only =3D 1; if (*hasIPv4) { if ((s4 =3D socket(AF_INET, SOCK_STREAM, 0)) < 0) goto cleanup; } =20 if (*hasIPv6) { + int only =3D 1; + if ((s6 =3D socket(AF_INET6, SOCK_STREAM, 0)) < 0) goto cleanup; =20 --=20 2.25.4