From nobody Mon May 13 06:48:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1649748748290838.4211306711077; Tue, 12 Apr 2022 00:32:28 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-495-SKecSpwLN1iAAV5HlLteeA-1; Tue, 12 Apr 2022 03:32:24 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA02B1C05B11; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91A3654AC9B; Tue, 12 Apr 2022 07:32:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7C18D1940377; Tue, 12 Apr 2022 07:32:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F38411947BBF for ; Tue, 12 Apr 2022 07:32:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D678240CF91E; Tue, 12 Apr 2022 07:32:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D20C740CF91A for ; Tue, 12 Apr 2022 07:32:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9B2A802803 for ; Tue, 12 Apr 2022 07:32:18 +0000 (UTC) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-14-AmrC2OiAMzeaLhGJZQz3dw-1; Tue, 12 Apr 2022 03:32:16 -0400 Received: by mail-lf1-f53.google.com with SMTP id u7so13590745lfs.8 for ; Tue, 12 Apr 2022 00:32:14 -0700 (PDT) Received: from vzbook.. (broadband-90-154-71-96.ip.moscow.rt.ru. [90.154.71.96]) by smtp.gmail.com with ESMTPSA id y16-20020a05651c107000b0024b50b2622csm1227816ljm.20.2022.04.12.00.32.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 00:32:12 -0700 (PDT) X-MC-Unique: SKecSpwLN1iAAV5HlLteeA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: AmrC2OiAMzeaLhGJZQz3dw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0fuT8G3tgNA0Aoa+AApSlq4SgZ082APlcJjTSgNjBk8=; b=GdjVonbVB11lVH1EAoVkA4GfE8l6DqOwc++qBkVUyZiyrrYOZ5mPwqjnhgUEBcIEiB vtReTcorFwsbYtee3sI9KyHKvJWdM1QF3+jh8MlPr3uaOvYaq/0lrT+p3wh6tzfsr4If Z9Lo6pKrf7+M557esfPV5DAN0IuD+ZhioLB9UQKl1Iiuzh7/bAMkiiedWPLp+gCSOI13 228d+FXYAynXgZif1BLOew+lxZlLqnryTyAjtkxZ7FMPozIpUKsblw6/k0UR1MYorPa7 TG1EMEzijc3ToUMwPPztKck09fgLpisUN4Yu/rpE1rQPXiExENJVyebw8CFeQ615GboC /flA== X-Gm-Message-State: AOAM531TMQAHOQ5uw/c8dwz6AcqNVbp6t3c/J5B3KFpI0A9IUw6R/NjH JfSwMEcpEn1LOi5RH2m3mRRscyzOvgblqg== X-Google-Smtp-Source: ABdhPJwGgoLAzgALzQz1D0P2vJGpG3SplXg9DT4IGOtMNwGq8NwuB3vsxmWVZ2M/wTxdFZ6jEJx2VA== X-Received: by 2002:a05:6512:400a:b0:46b:8cd9:1af8 with SMTP id br10-20020a056512400a00b0046b8cd91af8mr12545101lfb.545.1649748732928; Tue, 12 Apr 2022 00:32:12 -0700 (PDT) From: Nikolay Shirokovskiy X-Google-Original-From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 1/4] qemu: cleanup code to release VNC port Date: Tue, 12 Apr 2022 10:31:27 +0300 Message-Id: <20220412073130.149126-2-nshirokovskiy@openvz.org> In-Reply-To: <20220412073130.149126-1-nshirokovskiy@openvz.org> References: <20220412073130.149126-1-nshirokovskiy@openvz.org> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1649748749681100001 Content-Type: text/plain; charset="utf-8" Code to release VNC port looks repetitive. The reason is there were originally 2 functions to release ports - for auto and non-auto cases. Also portReserved flag is not cleared on stop in case of reconnect with auto port (flags is set on reconnect in qemuProcessGraphicsReservePorts cal= l). Yeah config is freed in the end of stopping domain but still. Let's use this flag whenever we reserve port (auto or not). This makes things clearer. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Martin Kletzander --- src/qemu/qemu_process.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2e11d24be2..cae87cdeca 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3994,6 +3994,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriver *driver, if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0) return -1; graphics->data.vnc.port =3D port; + graphics->data.vnc.portReserved =3D true; } =20 if (graphics->data.vnc.websocket =3D=3D -1) { @@ -8261,9 +8262,7 @@ void qemuProcessStop(virQEMUDriver *driver, for (i =3D 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDef *graphics =3D vm->def->graphics[i]; if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - if (graphics->data.vnc.autoport) { - virPortAllocatorRelease(graphics->data.vnc.port); - } else if (graphics->data.vnc.portReserved) { + if (graphics->data.vnc.portReserved) { virPortAllocatorRelease(graphics->data.vnc.port); graphics->data.vnc.portReserved =3D false; } --=20 2.35.1 From nobody Mon May 13 06:48:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1649748762632955.754541801338; Tue, 12 Apr 2022 00:32:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-340-thMhNwb9PwenQoVDtBWlXw-1; Tue, 12 Apr 2022 03:32:36 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4DFAF101AA52; Tue, 12 Apr 2022 07:32:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32FC34292C8; Tue, 12 Apr 2022 07:32:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C7E191949762; Tue, 12 Apr 2022 07:32:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A6B71947BBF for ; Tue, 12 Apr 2022 07:32:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8BD4D2024CD0; Tue, 12 Apr 2022 07:32:32 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 865B12024CBB for ; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5658801E67 for ; Tue, 12 Apr 2022 07:32:20 +0000 (UTC) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-fqlJOBg8P8qtE_VpbqSMgg-1; Tue, 12 Apr 2022 03:32:18 -0400 Received: by mail-lj1-f177.google.com with SMTP id u19so13368553ljd.11 for ; Tue, 12 Apr 2022 00:32:15 -0700 (PDT) Received: from vzbook.. (broadband-90-154-71-96.ip.moscow.rt.ru. [90.154.71.96]) by smtp.gmail.com with ESMTPSA id y16-20020a05651c107000b0024b50b2622csm1227816ljm.20.2022.04.12.00.32.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 00:32:13 -0700 (PDT) X-MC-Unique: thMhNwb9PwenQoVDtBWlXw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: fqlJOBg8P8qtE_VpbqSMgg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5/pjHDfjwk7VKBNh0V9yJWdlPB/B4FOvbsTAMxm4+vE=; b=k617v53fddmKxf6f8panAIp69ZfffeL0xJ9El9kief6Tp0zHfsiSa1AMRW/MGyFtyn yEJO6JVnHErQQi/fQ8RgiH/VhUB2KST2StilxQlbOclYcWsB/lyvnx6T3n07OVjbxs4T HpPe8O61UMRUs04vBnVFr5pMx8qrPqXn9qoNR+5zfKmlBQZUu1ZrmCESSauWzd4+yk/S yopKfD1a/Wci9WfP/dG9dsjmrKuWPVi70RM25YgrgXpTBKjP80djH6JYqGxKW6N5CdPd ZsZHdd0HsUmzVXfuYANbN63CoWMw+sb3huTeYIPBpgsI2e+T/XnwJbE9z0DKfTLEC4eo 3Gcg== X-Gm-Message-State: AOAM532XbpglwebkukQEVHQ+Z1FSqkMaGf45yRrFnH+VSaDaNKyuhLbs amGMUVpIpeYk1sC2tL7qw6ED9U+NPTm6/g== X-Google-Smtp-Source: ABdhPJz0ERW4gkqKlh367mG6Wg4mSV1VPiOzdk6TpwMU5dQuM0C7c1c3ZfhKEZswcJ3VK99aXf5yqA== X-Received: by 2002:a05:651c:1a11:b0:24b:54dd:720f with SMTP id by17-20020a05651c1a1100b0024b54dd720fmr11146482ljb.433.1649748733776; Tue, 12 Apr 2022 00:32:13 -0700 (PDT) From: Nikolay Shirokovskiy X-Google-Original-From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: fix releasing VNC websocket port domain does not own Date: Tue, 12 Apr 2022 10:31:28 +0300 Message-Id: <20220412073130.149126-3-nshirokovskiy@openvz.org> In-Reply-To: <20220412073130.149126-1-nshirokovskiy@openvz.org> References: <20220412073130.149126-1-nshirokovskiy@openvz.org> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1649748763167100001 Content-Type: text/plain; charset="utf-8" Scenario is with two domains with same VNC websocket port. - start first domain - start second, it will fail as port is occupied As a result port will be released which breaks port reservation logic. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Martin Kletzander --- src/conf/domain_conf.h | 1 + src/qemu/qemu_process.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 694491cd63..88a411d00c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1901,6 +1901,7 @@ struct _virDomainGraphicsDef { bool portReserved; int websocket; bool websocketGenerated; + bool websocketReserved; bool autoport; char *keymap; virDomainGraphicsAuthDef auth; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index cae87cdeca..9c7583a10b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4678,9 +4678,11 @@ qemuProcessGraphicsReservePorts(virDomainGraphicsDef= *graphics, return -1; graphics->data.vnc.portReserved =3D true; } - if (graphics->data.vnc.websocket > 0 && - virPortAllocatorSetUsed(graphics->data.vnc.websocket) < 0) - return -1; + if (graphics->data.vnc.websocket > 0) { + if (virPortAllocatorSetUsed(graphics->data.vnc.websocket) < 0) + return -1; + graphics->data.vnc.websocketReserved =3D true; + } break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: @@ -8270,7 +8272,7 @@ void qemuProcessStop(virQEMUDriver *driver, virPortAllocatorRelease(graphics->data.vnc.websocket); graphics->data.vnc.websocketGenerated =3D false; graphics->data.vnc.websocket =3D -1; - } else if (graphics->data.vnc.websocket) { + } else if (graphics->data.vnc.websocketReserved) { virPortAllocatorRelease(graphics->data.vnc.websocket); } } --=20 2.35.1 From nobody Mon May 13 06:48:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1649748757349686.6568888558817; Tue, 12 Apr 2022 00:32:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-294-cJ4VUQY0MTeFYqKQvFLpCQ-1; Tue, 12 Apr 2022 03:32:25 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22AF21C05B08; Tue, 12 Apr 2022 07:32:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E5F54292C1; Tue, 12 Apr 2022 07:32:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D3C4D1949762; Tue, 12 Apr 2022 07:32:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A547E1949762 for ; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 970CB4292CD; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 924494292C8 for ; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75E2280418E for ; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-4FTF4PdoNQmpQBbyxluisA-1; Tue, 12 Apr 2022 03:32:18 -0400 Received: by mail-lf1-f53.google.com with SMTP id bu29so30791303lfb.0 for ; Tue, 12 Apr 2022 00:32:16 -0700 (PDT) Received: from vzbook.. (broadband-90-154-71-96.ip.moscow.rt.ru. [90.154.71.96]) by smtp.gmail.com with ESMTPSA id y16-20020a05651c107000b0024b50b2622csm1227816ljm.20.2022.04.12.00.32.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 00:32:14 -0700 (PDT) X-MC-Unique: cJ4VUQY0MTeFYqKQvFLpCQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 4FTF4PdoNQmpQBbyxluisA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Uq3A7jzTwwY5rVL3ChxzO9Iqk/dtfnc/ak98Un6p9i8=; b=HsPOLqnuPycE2aSV5g1dv9Nbarl28TLnmnWM4giFyd8mFsuA0bcOghZzYJ8rqrvM1A sCmsr1aXO563VZmaSqke9wMRtJ6aBBmjPzOZc7vcGArv0mzd5Ql9ALMLpa2agKECu4BW fdYqFNZbL3aIiTAa9uA95CpMOnL/ZjW2c9WnT4gd/KjXGJdip/LziOPIjxlGFH9+xs2H OyqmOSAbvImfL98H7fw6UsYj1HSSx+qKQLVicBW5Owcfp5KRARF2ds0naKr5OiWAKkE4 YF9X+sWjhKbglT3poI/IP3IABR3u+aksiLxzAwfDfuFZ5tAEIgVKk4DkVSUH0HAF6bMe 9ZUA== X-Gm-Message-State: AOAM530Q/7SPluTProAGmVJcesAniPBdq0322DuBXJUvYYigE1WnK+Q7 sGhBwIDfHXFRdOEkObyYVY/p3Nint2QDmg== X-Google-Smtp-Source: ABdhPJxPf/HFONSWZnQyDnAOC/DA/Zl1rWcPmnI2azv7ogFTakCk7BBuEMCORyX16nOaCcab7P7Y1g== X-Received: by 2002:ac2:5604:0:b0:46b:b72f:c048 with SMTP id v4-20020ac25604000000b0046bb72fc048mr2154709lfd.591.1649748734613; Tue, 12 Apr 2022 00:32:14 -0700 (PDT) From: Nikolay Shirokovskiy X-Google-Original-From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 3/4] qemu: cleanup code to release VNC websocket port Date: Tue, 12 Apr 2022 10:31:29 +0300 Message-Id: <20220412073130.149126-4-nshirokovskiy@openvz.org> In-Reply-To: <20220412073130.149126-1-nshirokovskiy@openvz.org> References: <20220412073130.149126-1-nshirokovskiy@openvz.org> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1649748759202100001 Content-Type: text/plain; charset="utf-8" VNC websocket port cleanup looks a bit repetetive. Let's set websocketReser= ved flag whenever we reserve port (auto or not). Also websocketReserved flag is not cleared on stop in case of reconnect with auto port (flags is set on reconnect in qemuProcessGraphicsReservePorts call). Yeah config is freed in the end of stopping domain but still. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Martin Kletzander --- src/qemu/qemu_process.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9c7583a10b..6db8bbc421 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4002,6 +4002,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriver *driver, return -1; graphics->data.vnc.websocket =3D port; graphics->data.vnc.websocketGenerated =3D true; + graphics->data.vnc.websocketReserved =3D true; } =20 return 0; @@ -8268,12 +8269,13 @@ void qemuProcessStop(virQEMUDriver *driver, virPortAllocatorRelease(graphics->data.vnc.port); graphics->data.vnc.portReserved =3D false; } - if (graphics->data.vnc.websocketGenerated) { + if (graphics->data.vnc.websocketReserved) { virPortAllocatorRelease(graphics->data.vnc.websocket); + graphics->data.vnc.websocketReserved =3D false; + } + if (graphics->data.vnc.websocketGenerated) { graphics->data.vnc.websocketGenerated =3D false; graphics->data.vnc.websocket =3D -1; - } else if (graphics->data.vnc.websocketReserved) { - virPortAllocatorRelease(graphics->data.vnc.websocket); } } if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { --=20 2.35.1 From nobody Mon May 13 06:48:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1649748750253290.1267519868803; Tue, 12 Apr 2022 00:32:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-65-uEyI7HAeNqGeMAgfss06bw-1; Tue, 12 Apr 2022 03:32:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FC79185A7B2; Tue, 12 Apr 2022 07:32:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B67AC44CC4; Tue, 12 Apr 2022 07:32:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 26C9B1949762; Tue, 12 Apr 2022 07:32:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 30F8E1947BBF for ; Tue, 12 Apr 2022 07:32:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 233114292C8; Tue, 12 Apr 2022 07:32:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1ED804292C1 for ; Tue, 12 Apr 2022 07:32:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DFC4C38149B6 for ; Tue, 12 Apr 2022 07:32:21 +0000 (UTC) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-101-deXHc80OPI-V6U5YD7Ot8Q-1; Tue, 12 Apr 2022 03:32:18 -0400 Received: by mail-lf1-f41.google.com with SMTP id u19so10583769lff.4 for ; Tue, 12 Apr 2022 00:32:16 -0700 (PDT) Received: from vzbook.. (broadband-90-154-71-96.ip.moscow.rt.ru. [90.154.71.96]) by smtp.gmail.com with ESMTPSA id y16-20020a05651c107000b0024b50b2622csm1227816ljm.20.2022.04.12.00.32.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 00:32:15 -0700 (PDT) X-MC-Unique: uEyI7HAeNqGeMAgfss06bw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: deXHc80OPI-V6U5YD7Ot8Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3fsUJB4E2MAV0lbEWnZW/LHeF894WcmMWgzJArFbpN8=; b=Vq2ZLl1BEux8NX+KMREYnjYVb7HF+tW2c+t8k7bpJ0k/onG4vYSABjmVr3ch5/LimP l/awJ9SulWHiKh/LbLCFJ6sC/ceiojkPvd9U3Sq3ZXRzYr1Hf/OFVR6jGXihQp0JPuJo 22VSFjQ4P39P9e9zg1K7QDZ+DQ2F01hKBWzce0hSRp1KVID5IAtIwDQfCeSbFyhyiki2 DZ2o9nj07P/6l6Ua04Rly/msxTV4T8UFT9FOFlKoKk8A1K8JLTbYLPf7WkghOtlH7JhH MwL4UnjCiWo0WsK/NuH8SvvHZK7HRf1OMtwj0otcYIa680dQJXEXAfZ4Bh2Z+XxnTlnh CYAQ== X-Gm-Message-State: AOAM530arVKOt/aZ3OPWHLceDPJ39p38Nhw8uL70oHy8QzuQ/O3icCwE nTaOe4DBZxxMa3BTX2OgxEOcGkqEmOvmMA== X-Google-Smtp-Source: ABdhPJwsGrepvkTGOsG31MzR1OhlLgSN2DQGSMWUAyAgeBDEICaBE0hZ64axtkCwIn2lPjQVXkPGDw== X-Received: by 2002:a05:6512:2207:b0:45d:cd01:d3ca with SMTP id h7-20020a056512220700b0045dcd01d3camr25151281lfu.561.1649748735390; Tue, 12 Apr 2022 00:32:15 -0700 (PDT) From: Nikolay Shirokovskiy X-Google-Original-From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu: cleanup code to relece SPICE ports Date: Tue, 12 Apr 2022 10:31:30 +0300 Message-Id: <20220412073130.149126-5-nshirokovskiy@openvz.org> In-Reply-To: <20220412073130.149126-1-nshirokovskiy@openvz.org> References: <20220412073130.149126-1-nshirokovskiy@openvz.org> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1649748751290100003 Content-Type: text/plain; charset="utf-8" SPICE ports cleanup looks overly complicated. We can just set *reserved flags whenever port is reserved (auto or non auto). Also *Reserved flags are not cleared on stop in case of reconnect with autoport (flags are set on reconnect in qemuProcessGraphicsReservePorts call). Yeah config is freed in the end of stopping domain but still. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Martin Kletzander --- src/qemu/qemu_process.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6db8bbc421..08a38edfb6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4071,9 +4071,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriver *driver, return -1; =20 graphics->data.spice.port =3D port; - - if (!graphics->data.spice.autoport) - graphics->data.spice.portReserved =3D true; + graphics->data.spice.portReserved =3D true; } =20 if (needTLSPort || graphics->data.spice.tlsPort =3D=3D -1) { @@ -4088,9 +4086,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriver *driver, return -1; =20 graphics->data.spice.tlsPort =3D tlsPort; - - if (!graphics->data.spice.autoport) - graphics->data.spice.tlsPortReserved =3D true; + graphics->data.spice.tlsPortReserved =3D true; } =20 return 0; @@ -8279,19 +8275,14 @@ void qemuProcessStop(virQEMUDriver *driver, } } if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - if (graphics->data.spice.autoport) { + if (graphics->data.spice.portReserved) { virPortAllocatorRelease(graphics->data.spice.port); - virPortAllocatorRelease(graphics->data.spice.tlsPort); - } else { - if (graphics->data.spice.portReserved) { - virPortAllocatorRelease(graphics->data.spice.port); - graphics->data.spice.portReserved =3D false; - } + graphics->data.spice.portReserved =3D false; + } =20 - if (graphics->data.spice.tlsPortReserved) { - virPortAllocatorRelease(graphics->data.spice.tlsPort); - graphics->data.spice.tlsPortReserved =3D false; - } + if (graphics->data.spice.tlsPortReserved) { + virPortAllocatorRelease(graphics->data.spice.tlsPort); + graphics->data.spice.tlsPortReserved =3D false; } } } --=20 2.35.1