From nobody Mon Dec 15 01:51:47 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517908545940608.4267448829681; Tue, 6 Feb 2018 01:15:45 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id DA34428210; Tue, 6 Feb 2018 09:15:44 +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 958F32A2CC; Tue, 6 Feb 2018 09:15:44 +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 525134A472; Tue, 6 Feb 2018 09:15:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w169Dr5u023611 for ; Tue, 6 Feb 2018 04:13:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3B51C2D33A; Tue, 6 Feb 2018 09:13:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3016B608F0 for ; Tue, 6 Feb 2018 09:13:50 +0000 (UTC) Received: from new-relay.sw.ru (new-relay.sw.ru [195.214.232.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 876B44ACAD for ; Tue, 6 Feb 2018 09:13:48 +0000 (UTC) Received: from msk-vpn.virtuozzo.com ([195.214.232.6] helo=dim-vz7.qa.sw.ru) by new-relay.sw.ru with esmtp (Exim 4.89) (envelope-from ) id 1eizJy-0006tL-3o for libvir-list@redhat.com; Tue, 06 Feb 2018 12:13:46 +0300 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Tue, 6 Feb 2018 12:09:07 +0300 Message-Id: <1517908151-337420-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1517908151-337420-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1517908151-337420-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.38]); Tue, 06 Feb 2018 09:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 06 Feb 2018 09:13:49 +0000 (UTC) for IP:'195.214.232.40' DOMAIN:'new-relay.sw.ru' HELO:'new-relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 195.214.232.40 new-relay.sw.ru 195.214.232.40 new-relay.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/6] port allocator: remove range on manual port reserving 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 06 Feb 2018 09:15:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Range check in virPortAllocatorSetUsed is not useful anymore when we manage ports for entire unsigned short range values. --- src/bhyve/bhyve_command.c | 4 +--- src/bhyve/bhyve_process.c | 4 +--- src/qemu/qemu_process.c | 41 +++++++++++---------------------------= --- src/util/virportallocator.c | 9 +-------- src/util/virportallocator.h | 4 +--- tests/bhyvexml2argvtest.c | 2 +- tests/libxlxml2domconfigtest.c | 2 +- 7 files changed, 17 insertions(+), 49 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 55032ae..9d21788 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -411,9 +411,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; graphics->data.vnc.port =3D port; } else { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.vnc.port, - true) < 0) + if (virPortAllocatorSetUsed(graphics->data.vnc.port, true)= < 0) VIR_WARN("Failed to mark VNC port '%d' as used by '%s'= ", graphics->data.vnc.port, def->name); } diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 5076246..e215f6a 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -425,9 +425,7 @@ virBhyveProcessReconnect(virDomainObjPtr vm, if (vm->def->ngraphics =3D=3D 1 && vm->def->graphics[0]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYP= E_VNC) { int vnc_port =3D vm->def->graphics[0]->data.vnc.port; - if (virPortAllocatorSetUsed(data->driver->remotePorts, - vnc_port, - true) < 0) { + if (virPortAllocatorSetUsed(vnc_port, true) < 0) { VIR_WARN("Failed to mark VNC port '%d' as used by '%s= '", vnc_port, vm->def->name); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0368531..2a0690b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4203,8 +4203,7 @@ qemuProcessStartHook(virQEMUDriverPtr driver, =20 =20 static int -qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, - virDomainGraphicsDefPtr graphics, +qemuProcessGraphicsReservePorts(virDomainGraphicsDefPtr graphics, bool reconnect) { virDomainGraphicsListenDefPtr glisten; @@ -4222,16 +4221,12 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr dr= iver, case VIR_DOMAIN_GRAPHICS_TYPE_VNC: if (!graphics->data.vnc.autoport || reconnect) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.vnc.port, - true) < 0) + if (virPortAllocatorSetUsed(graphics->data.vnc.port, true) < 0) return -1; graphics->data.vnc.portReserved =3D true; } if (graphics->data.vnc.websocket > 0 && - virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.vnc.websocket, - true) < 0) + virPortAllocatorSetUsed(graphics->data.vnc.websocket, true) < = 0) return -1; break; =20 @@ -4240,17 +4235,13 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr dr= iver, return 0; =20 if (graphics->data.spice.port > 0) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.port, - true) < 0) + if (virPortAllocatorSetUsed(graphics->data.spice.port, true) <= 0) return -1; graphics->data.spice.portReserved =3D true; } =20 if (graphics->data.spice.tlsPort > 0) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.tlsPort, - true) < 0) + if (virPortAllocatorSetUsed(graphics->data.spice.tlsPort, true= ) < 0) return -1; graphics->data.spice.tlsPortReserved =3D true; } @@ -4440,7 +4431,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (i =3D 0; i < vm->def->ngraphics; i++) { graphics =3D vm->def->graphics[i]; =20 - if (qemuProcessGraphicsReservePorts(driver, graphics, false) <= 0) + if (qemuProcessGraphicsReservePorts(graphics, false) < 0) goto cleanup; } } @@ -6628,9 +6619,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, virPortAllocatorRelease(driver->remotePorts, graphics->data.vnc.port); } else if (graphics->data.vnc.portReserved) { - virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.port, - false); + virPortAllocatorSetUsed(graphics->data.spice.port, false); graphics->data.vnc.portReserved =3D false; } if (graphics->data.vnc.websocketGenerated) { @@ -6639,9 +6628,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, graphics->data.vnc.websocketGenerated =3D false; graphics->data.vnc.websocket =3D -1; } else if (graphics->data.vnc.websocket) { - virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.vnc.websocket, - false); + virPortAllocatorSetUsed(graphics->data.vnc.websocket, fals= e); } } if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { @@ -6652,16 +6639,12 @@ void qemuProcessStop(virQEMUDriverPtr driver, graphics->data.spice.tlsPort); } else { if (graphics->data.spice.portReserved) { - virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.port, - false); + virPortAllocatorSetUsed(graphics->data.spice.port, fal= se); graphics->data.spice.portReserved =3D false; } =20 if (graphics->data.spice.tlsPortReserved) { - virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.tlsPort, - false); + virPortAllocatorSetUsed(graphics->data.spice.tlsPort, = false); graphics->data.spice.tlsPortReserved =3D false; } } @@ -7258,9 +7241,7 @@ qemuProcessReconnect(void *opaque) } =20 for (i =3D 0; i < obj->def->ngraphics; i++) { - if (qemuProcessGraphicsReservePorts(driver, - obj->def->graphics[i], - true) < 0) + if (qemuProcessGraphicsReservePorts(obj->def->graphics[i], true) <= 0) goto error; } =20 diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c index be29e97..23c7af1 100644 --- a/src/util/virportallocator.c +++ b/src/util/virportallocator.c @@ -301,8 +301,7 @@ virPortAllocatorRelease(virPortAllocatorRangePtr range, } =20 int -virPortAllocatorSetUsed(virPortAllocatorRangePtr range, - unsigned short port, +virPortAllocatorSetUsed(unsigned short port, bool value) { int ret =3D -1; @@ -313,12 +312,6 @@ virPortAllocatorSetUsed(virPortAllocatorRangePtr range, =20 virObjectLock(pa); =20 - if (port < range->start || - port > range->end) { - ret =3D 0; - goto cleanup; - } - if (value) { if (virBitmapIsBitSet(pa->bitmap, port) || virBitmapSetBit(pa->bitmap, port) < 0) { diff --git a/src/util/virportallocator.h b/src/util/virportallocator.h index fb38c33..ea816bc 100644 --- a/src/util/virportallocator.h +++ b/src/util/virportallocator.h @@ -46,8 +46,6 @@ int virPortAllocatorAcquire(virPortAllocatorRangePtr rang= e, int virPortAllocatorRelease(virPortAllocatorRangePtr range, unsigned short port); =20 -int virPortAllocatorSetUsed(virPortAllocatorRangePtr range, - unsigned short port, - bool value); +int virPortAllocatorSetUsed(unsigned short port, bool value); =20 #endif /* __VIR_PORT_ALLOCATOR_H__ */ diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 47ea85b..e8089b8 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -97,7 +97,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (vmdef->graphics[0]->data.vnc.autoport) virPortAllocatorRelease(gports, vmdef->graphics[0]->data.vnc.p= ort); else - virPortAllocatorSetUsed(gports, vmdef->graphics[0]->data.vnc.p= ort, false); + virPortAllocatorSetUsed(vmdef->graphics[0]->data.vnc.port, fal= se); } =20 VIR_FREE(actualargv); diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 0512297..b146eb5 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -118,7 +118,7 @@ testCompareXMLToDomConfig(const char *xmlfile, if (vmdef->graphics[0]->data.vnc.autoport) virPortAllocatorRelease(gports, vmdef->graphics[0]->data.vnc.p= ort); else - virPortAllocatorSetUsed(gports, vmdef->graphics[0]->data.vnc.p= ort, false); + virPortAllocatorSetUsed(vmdef->graphics[0]->data.vnc.port, fal= se); } =20 VIR_FREE(expectjson); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list