From nobody Thu May 15 01:37:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1513751809485752.5296840849899; Tue, 19 Dec 2017 22:36:49 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67D597EA85; Wed, 20 Dec 2017 06:36:47 +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 9B9D462660; Wed, 20 Dec 2017 06:36:46 +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 107E81808873; Wed, 20 Dec 2017 06:36:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBK6adW3016315 for ; Wed, 20 Dec 2017 01:36:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E59618B17; Wed, 20 Dec 2017 06:36:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46E4318B16 for ; Wed, 20 Dec 2017 06:36:37 +0000 (UTC) Received: from relay.sw.ru (mailhub.sw.ru [195.214.232.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3CFE83F43 for ; Wed, 20 Dec 2017 06:36:34 +0000 (UTC) Received: from dim-vz7.qa.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id vBJ9IkWi001510 for ; Tue, 19 Dec 2017 12:18:47 +0300 (MSK) From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Wed, 20 Dec 2017 09:35:36 +0300 Message-Id: <1513751738-772066-5-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1513751738-772066-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1513751738-772066-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Dec 2017 06:36:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Dec 2017 06:36:35 +0000 (UTC) for IP:'195.214.232.25' DOMAIN:'mailhub.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 195.214.232.25 mailhub.sw.ru 195.214.232.25 mailhub.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] port allocator: drop skip flag 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Dec 2017 06:36:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This flag is only used for tests and tests overload socket and bind functions using virportallocatormock.c already in a suitable fashion so we don't need this flag at all. --- src/bhyve/bhyve_driver.c | 2 +- src/libxl/libxl_driver.c | 5 ++--- src/qemu/qemu_driver.c | 9 +++------ src/util/virportallocator.c | 14 ++++---------- src/util/virportallocator.h | 7 +------ tests/bhyvexml2argvtest.c | 3 +-- tests/libxlxml2domconfigtest.c | 3 +-- tests/virportallocatortest.c | 4 ++-- 8 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 43487f5..19c86e2 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1267,7 +1267,7 @@ bhyveStateInitialize(bool privileged, if (!(bhyve_driver->domainEventState =3D virObjectEventStateNew())) goto cleanup; =20 - if (!(bhyve_driver->remotePorts =3D virPortRangeNew(_("display"), 5900= , 65535, 0))) + if (!(bhyve_driver->remotePorts =3D virPortRangeNew(_("display"), 5900= , 65535))) goto cleanup; =20 bhyve_driver->hostsysinfo =3D virSysinfoRead(); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 5209ea7..18126e4 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -659,15 +659,14 @@ libxlStateInitialize(bool privileged, if (!(libxl_driver->reservedGraphicsPorts =3D virPortRangeNew(_("VNC"), LIBXL_VNC_PORT_MIN, - LIBXL_VNC_PORT_MAX, - 0))) + LIBXL_VNC_PORT_MAX))) goto error; =20 /* Allocate bitmap for migration port reservation */ if (!(libxl_driver->migrationPorts =3D virPortRangeNew(_("migration"), LIBXL_MIGRATION_PORT_MIN, - LIBXL_MIGRATION_PORT_MAX, 0))) + LIBXL_MIGRATION_PORT_MAX))) goto error; =20 if (!(libxl_driver->domains =3D virDomainObjListNew())) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 254ccd1..edde4e2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -748,22 +748,19 @@ qemuStateInitialize(bool privileged, if ((qemu_driver->remotePorts =3D virPortRangeNew(_("display"), cfg->remotePortMin, - cfg->remotePortMax, - 0)) =3D=3D NULL) + cfg->remotePortMax)) =3D=3D NULL) goto error; =20 if ((qemu_driver->webSocketPorts =3D virPortRangeNew(_("webSocket"), cfg->webSocketPortMin, - cfg->webSocketPortMax, - 0)) =3D=3D NULL) + cfg->webSocketPortMax)) =3D=3D NULL) goto error; =20 if ((qemu_driver->migrationPorts =3D virPortRangeNew(_("migration"), cfg->migrationPortMin, - cfg->migrationPortMax, - 0)) =3D=3D NULL) + cfg->migrationPortMax)) =3D=3D NULL) goto error; =20 if (qemuSecurityInit(qemu_driver) < 0) diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c index a154806..76fac49 100644 --- a/src/util/virportallocator.c +++ b/src/util/virportallocator.c @@ -47,8 +47,6 @@ struct _virPortRange { =20 unsigned short start; unsigned short end; - - unsigned int flags; }; =20 static virClassPtr virPortAllocatorClass; @@ -96,8 +94,7 @@ VIR_ONCE_GLOBAL_INIT(virPortAllocator) =20 virPortRangePtr virPortRangeNew(const char *name, unsigned short start, - unsigned short end, - unsigned int flags) + unsigned short end) { virPortRangePtr range; =20 @@ -110,7 +107,6 @@ virPortRangePtr virPortRangeNew(const char *name, if (VIR_ALLOC(range) < 0) return NULL; =20 - range->flags =3D flags; range->start =3D start; range->end =3D end; =20 @@ -231,11 +227,9 @@ int virPortAllocatorAcquire(virPortRangePtr range, if (virBitmapIsBitSet(pa->bitmap, i)) continue; =20 - if (!(range->flags & VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK)) { - if (virPortAllocatorBindToPort(&v6used, i, AF_INET6) < 0 || - virPortAllocatorBindToPort(&used, i, AF_INET) < 0) - goto cleanup; - } + if (virPortAllocatorBindToPort(&v6used, i, AF_INET6) < 0 || + virPortAllocatorBindToPort(&used, i, AF_INET) < 0) + goto cleanup; =20 if (!used && !v6used) { /* Add port to bitmap of reserved ports */ diff --git a/src/util/virportallocator.h b/src/util/virportallocator.h index ae00edc..bddeadd 100644 --- a/src/util/virportallocator.h +++ b/src/util/virportallocator.h @@ -28,14 +28,9 @@ typedef struct _virPortRange virPortRange; typedef virPortRange *virPortRangePtr; =20 -typedef enum { - VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK =3D (1 << 0), -} virPortAllocatorFlags; - virPortRangePtr virPortRangeNew(const char *name, unsigned short start, - unsigned short end, - unsigned int flags); + unsigned short end); =20 void virPortRangeFree(virPortRangePtr range); =20 diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 93c8026..4edf921 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -145,8 +145,7 @@ mymain(void) if ((driver.xmlopt =3D virBhyveDriverCreateXMLConf(&driver)) =3D=3D NU= LL) return EXIT_FAILURE; =20 - if (!(driver.remotePorts =3D virPortRangeNew("display", 5900, 65535, - VIR_PORT_ALLOCATOR_SKIP_BIN= D_CHECK))) + if (!(driver.remotePorts =3D virPortRangeNew("display", 5900, 65535))) return EXIT_FAILURE; =20 =20 diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index b3bdcaf..375fac3 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -74,8 +74,7 @@ testCompareXMLToDomConfig(const char *xmlfile, if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, log) < 0) goto cleanup; =20 - if (!(gports =3D virPortRangeNew("vnc", 5900, 6000, - VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK))) + if (!(gports =3D virPortRangeNew("vnc", 5900, 6000))) goto cleanup; =20 if (!(xmlopt =3D libxlCreateXMLConf())) diff --git a/tests/virportallocatortest.c b/tests/virportallocatortest.c index cd792ad..25641d1 100644 --- a/tests/virportallocatortest.c +++ b/tests/virportallocatortest.c @@ -42,7 +42,7 @@ VIR_LOG_INIT("tests.portallocatortest"); =20 static int testAllocAll(const void *args ATTRIBUTE_UNUSED) { - virPortRangePtr ports =3D virPortRangeNew("test", 5900, 5909, 0); + virPortRangePtr ports =3D virPortRangeNew("test", 5900, 5909); int ret =3D -1; unsigned short p1, p2, p3, p4, p5, p6, p7; =20 @@ -114,7 +114,7 @@ static int testAllocAll(const void *args ATTRIBUTE_UNUS= ED) =20 static int testAllocReuse(const void *args ATTRIBUTE_UNUSED) { - virPortRangePtr ports =3D virPortRangeNew("test", 5900, 5910, 0); + virPortRangePtr ports =3D virPortRangeNew("test", 5900, 5910); int ret =3D -1; unsigned short p1, p2, p3, p4; =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list