From nobody Sat Feb 7 07:10:33 2026 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=quarantine dis=quarantine) header.from=suse.com 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 1644014273639400.4866785642614; Fri, 4 Feb 2022 14:37:53 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-145-rfOZKQwENye9Ti2zCYxjjg-1; Fri, 04 Feb 2022 17:37:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9CAA801ADB; Fri, 4 Feb 2022 22:37:43 +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 24D0A104253D; Fri, 4 Feb 2022 22:37:43 +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 DD3AA1809CB8; Fri, 4 Feb 2022 22:37:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214MVNHh019230 for ; Fri, 4 Feb 2022 17:31:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8BCDE40F9D7C; Fri, 4 Feb 2022 22:31:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 867E540F9D6D for ; Fri, 4 Feb 2022 22:31:23 +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 6BAEC3C00130 for ; Fri, 4 Feb 2022 22:31:23 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-526-D-MkqO20O2ueGW6BQT_ZqA-1; Fri, 04 Feb 2022 17:31:21 -0500 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2059.outbound.protection.outlook.com [104.47.4.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-30-3P2vtz6BNV2Kz5GjHxFkBg-1; Fri, 04 Feb 2022 23:31:19 +0100 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) by AM9PR04MB8987.eurprd04.prod.outlook.com (2603:10a6:20b:40a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14; Fri, 4 Feb 2022 22:31:19 +0000 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::9d7c:24e:fb2d:2b34]) by AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::9d7c:24e:fb2d:2b34%6]) with mapi id 15.20.4951.016; Fri, 4 Feb 2022 22:31:19 +0000 X-MC-Unique: rfOZKQwENye9Ti2zCYxjjg-1 X-MC-Unique: D-MkqO20O2ueGW6BQT_ZqA-1 X-MC-Unique: 3P2vtz6BNV2Kz5GjHxFkBg-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH] libxl: Set auto-allocated graphics ports to used on reconnect Date: Fri, 4 Feb 2022 15:31:15 -0700 Message-ID: <20220204223115.28070-1-jfehlig@suse.com> X-ClientProxiedBy: AS9PR06CA0336.eurprd06.prod.outlook.com (2603:10a6:20b:466::6) To AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24ea07f8-862a-468b-863e-08d9e82e104f X-MS-TrafficTypeDiagnostic: AM9PR04MB8987:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 2HSJ/rH3iJXGM0GWOHjVA+Wn1x0RRHZByKWdgHLMdBxSJtkOy8BKjfU1eJ/aroy/7PKW9fTDDFDwuJvWVbEjrVuNQ6p69BYNNHww0NDgu0oqcEwEEXP0xaU/m9TfSFrs5LkbElin0ibQWqH0yFuvVFh5wk+N1z1xaGN+tb2imn7TPwLLkO2MResKb3lqG8SIttj/egILtPRuH733VfJu/uy4K0wcXS1ckwmpPPrPhw3mAcm/OwATRlEGBIJIS0vfu3/Qoa13GrELETTdKHDHH+CE0hhz52ZjPFPIIgChSCwma+b093w6LFead7yTlFaxAUFn3X7QyBvBsWD3EZkvw+3jqGF+xt9eJAexh0DbdurnorOMGnE4w+Rm1xVrjzJg9DCYO5vUUgtRgf2BZpSXWpd00rp1MIIakl9DxEq5jlpDuIw14dT//XKt3K+mslu0O2G4WWW0Y0n1B90Ij52d605xqwty8WvvSRfRXhWZ2vkLSPfbtBT4tK8rp6jKVNEH5TsnKklEo8Ltvt3eyFkwoDGx67ZwCCVQKLhOm3JLJGHyKTtSxidKVbZXi4+XT5TqW93v9yuI3mlgBmvuVEVHdO28eXvQ9k8Odxb9Q+fSs3FsWLWNp3pokLrDE49pKkqZFjaf+A4s9SOTnXJwLko80g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB4899.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(83380400001)(186003)(6506007)(508600001)(1076003)(2616005)(36756003)(6486002)(6512007)(6666004)(8676002)(66556008)(38100700002)(66476007)(86362001)(66574015)(26005)(316002)(6916009)(66946007)(5660300002)(8936002)(2906002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JXIsmkErPJlAeopqsCu5GkN3X9nfkVfUKyyFlSJDcebC5dMccf6W/xcmSJ+n?= =?us-ascii?Q?fsm+1wBV7MlJb6nBH55XGYVdztG+DUWRl5fPm0mG+YK67VUchoTL8o/+JZAA?= =?us-ascii?Q?nW+mYQaViUBRtpbAYoLBbqFS6hipkSyWfD5rlLWdBsewGiBrAZaFvdr9AF/U?= =?us-ascii?Q?I29kqAAgOcuG8KxbXbaJ+btcdIgMRfc06qSbvoU3IsqV+Anme7wniJ4mK8AW?= =?us-ascii?Q?cLtYiwNoXUMgESFNYD+BXpyJ9yb2vxv+WHK3Kkzv/XblY4F8YPT1e/6/3cjB?= =?us-ascii?Q?XgF3xHUF4+mWBuq4sZG1jmZkuEPTyBGuQj0+PPe7uSfT+GZn4hM7jW8Z1TNp?= =?us-ascii?Q?vTKqeTxas0CjaTjAh/ihJASeUZwmB/PBrrot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klHljEQAHK3zZoMl7QP72Zo1GeBoeiAk9APe56fXcDXD0QAG9FQDy9t65?= =?us-ascii?Q?+xqARhrEK+2b3/zucXZaE8lQ7cwJNIcBRAHujP+phgD7lnZkqueFOLSqEwWq?= =?us-ascii?Q?cbpuzZ818uoRT0F9itaTZA758wAWQPaMXroymIoZdvvN3oJUUaaPSfls/iWR?= =?us-ascii?Q?KK2ToIjqE2fSKK34+eeF5xHVX1nBJ+ufQze5MhRxlBQzXlrT/r/JtGxFR6P1?= =?us-ascii?Q?+OGVY/XCwnCPnECVgVudRL4DKhc15t4u10OTpLFPxgi4lXqCCg/SiyABjL/P?= =?us-ascii?Q?45UhjBDU8SZHTifkzoasXUx4M0uiFzMwj/geyyfc83Ba72iEVeqtAaMP2RHp?= =?us-ascii?Q?l9nprLkWHz2HrfSEW0fwjpE=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24ea07f8-862a-468b-863e-08d9e82e104f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4899.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 22:31:19.0516 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VKhDVSlKyD2NotVNGMFgO/nlDar3Uj1mgf14PzAVBpl3C5IRHq4/y0znqOxUUCcOdGkMvl3Fgvx66ZjK2VueSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8987 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-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 214MVNHh019230 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.84 on 10.5.11.22 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: 1644014274421100001 Content-Type: text/plain; charset="utf-8" The libxl driver reconnects to all running VMs when libvirtd is restarted, but it failed to mark auto-allocated graphics ports as set in the port allocator. If many VMs are running that use port auto-allocation and libvirtd is restarted, the port allocator is likely to hand out a port already in use when a new VM is created that uses auto-allocation. VM creation will fail due to the port clash. When reconnecting to running VMs after a libvirtd restart, let the port allocator know about previously allocated ports. Signed-off-by: Jim Fehlig Reviewed-by: J=C3=A1n Tomko --- Like 31e937fb3b, another item unaccounted for when reconnecting to VMs after a daemon restart. src/libxl/libxl_driver.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 2d9385654c..97965aaf1d 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -393,6 +393,7 @@ libxlReconnectDomain(virDomainObj *vm, virHostdevManager *hostdev_mgr =3D driver->hostdevMgr; unsigned int hostdev_flags =3D VIR_HOSTDEV_SP_PCI; int ret =3D -1; + size_t i; =20 hostdev_flags |=3D VIR_HOSTDEV_SP_USB; =20 @@ -447,6 +448,28 @@ libxlReconnectDomain(virDomainObj *vm, =20 libxlReconnectNotifyNets(vm->def); =20 + /* Set any auto-allocated graphics ports to used */ + for (i =3D 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDef *graphics =3D vm->def->graphics[i]; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + if (graphics->data.vnc.autoport) + virPortAllocatorSetUsed(graphics->data.vnc.port); + break; + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (graphics->data.spice.autoport) + virPortAllocatorSetUsed(graphics->data.spice.port); + break; + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; + } + } + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Cannot update XML for running Xen guest %s", vm->def->na= me); =20 --=20 2.34.1