From nobody Mon Feb 9 01:44:06 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1681309522; cv=none; d=zohomail.com; s=zohoarc; b=TemFukZbfSOln9Zw9D+c3JXlzkugCSS4vdrt4dWNYHA4cRkGkatQRBuoYcdkHLbRWowIhBsifj+V3TZ/Ix+zX4xuqYkXPvh+BYhHSuLAdlpz62a/ZLkpJgLJDl9MvFeoHWLTz4AzzlCjeHWUyytRnbCUtKhvER9FazLzLBcTtds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681309522; 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=vFZ6kR2NGpy4WzT4tFoAWfHQ0z4cXJ7rLsZZMZMSXng=; b=lOqyM6qptRuzT8qSuxGoGvofN9PfZzj82rkXbLo2ZnBBgR0jDq0rVElOZs0+8n3OcniD0HWKsXT7+DmkacgOmmHjKAWv8gEAfIEtDekZz9dfMcEXouUl+tK+7NkkUlK1W8FZTvFvFgI7ZTaFab0fgr45pLwiM5Kt9IMM7PWsO+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1681309522907273.44218729084537; Wed, 12 Apr 2023 07:25:22 -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-103-Mh4jd2JvPq6Rt-D0u35s2w-1; Wed, 12 Apr 2023 10:25:18 -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 37EDC855311; Wed, 12 Apr 2023 14:25:15 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF0C9492C13; Wed, 12 Apr 2023 14:25:14 +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 23CDC1946A49; Wed, 12 Apr 2023 14:25:14 +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 3DA6D1946587 for ; Wed, 12 Apr 2023 14:25:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 202AB2027044; Wed, 12 Apr 2023 14:25:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1B6B2027043 for ; Wed, 12 Apr 2023 14:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681309522; 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=vFZ6kR2NGpy4WzT4tFoAWfHQ0z4cXJ7rLsZZMZMSXng=; b=CY4KUfgxDxxWumLgx7vymQxWaBUtbtvgzJ06V7ZrjuuHUOBw7Rw9cUH9L1We2F1dR9Oscu TKbgOLljiDH7aoQMcpkhHhX0TQC9/nPJD1a02pX2auuJ5hEy4aOh+xrbaN4vCwIPMMYmTg J/dIk4aazhTPyTZZg7vinBGD+Yf8EAk= X-MC-Unique: Mh4jd2JvPq6Rt-D0u35s2w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] qemuDomainChrInsertPreAlloced: Fix adding implicit console Date: Wed, 12 Apr 2023 16:25:06 +0200 Message-Id: <4d7a0abcca0ae5c52b1c555af2472a401dc6f359.1681307447.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681309524027100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When hotpluging a device, we might need to add a device with it (because of some crazy backcompat). Now, hotplugging is done in several phases. In one of them, qemuDomainChrPreInsert() allocates space for both devices, and then qemuDomainChrInsertPreAlloced() actually inserts the device into domain definition and sets up the device with it. Except, the condition that checks whether to create the aliased is wrong as it compares nconsoles against 0. Surprisingly, qemuDomainChrInsertPreAllocCleanup() doesn't suffer from the same error. Fixes: daf51be5f1b0f7b41c0813d43d6b66edfbe4f6d9 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3f45a48393..f517646c55 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1875,9 +1875,8 @@ qemuDomainChrInsertPreAlloced(virDomainDef *vmdef, virDomainChrDef *chr) { virDomainChrInsertPreAlloced(vmdef, chr); - if (vmdef->nserials =3D=3D 1 && vmdef->nconsoles =3D=3D 0 && + if (vmdef->nserials =3D=3D 1 && vmdef->nconsoles =3D=3D 1 && chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { - vmdef->nconsoles =3D 1; =20 /* Create an console alias for the serial port */ vmdef->consoles[0]->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONS= OLE; --=20 2.39.2 From nobody Mon Feb 9 01:44:06 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1681309525; cv=none; d=zohomail.com; s=zohoarc; b=baWq2Mj43BEb6jHAtm769QFqMcQsC6gDlJMJxlhkdSbY4jPuHbk8MKGhJkrlfpdhHiIKlN5xYC1Ms8OMFEDYGnmZXh+VtFGTraKuoV0DWq/4kuKdYD664BU6ymyFfFr4vNddGs20Ty6hoekAbNmqWQZjasWuuo4U8RGgNX9Ozts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681309525; 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=s/HapDv5NRmuZPKBXRwFqq+MkXya+ZDPUndSvCyxFQM=; b=cRqczavZpUOr7eQhnBrKbBRyVEItY/uhB0IUwNjXTuq5O3/6pfUIcnzFu2lwDg7JMQIsTvyMvifRWj2b3+CRkoq+dHNaK1LwCAO5DbnQEqBNgZz0XUXJE46m1IQWfyni1eJXxFoZErSwRIRO8wNiHfd8yZjXYq6Ojs88uMO07vw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 168130952589920.775091021565117; Wed, 12 Apr 2023 07:25:25 -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-519-6H-nHQgeN324w2gNAp-NAg-1; Wed, 12 Apr 2023 10:25:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EF7F3C025D0; Wed, 12 Apr 2023 14:25:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 788C114171B6; Wed, 12 Apr 2023 14:25:16 +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 5E8B8194658F; Wed, 12 Apr 2023 14:25:16 +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 E0C0D194658F for ; Wed, 12 Apr 2023 14:25:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D2D6D2027044; Wed, 12 Apr 2023 14:25:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 732902027043 for ; Wed, 12 Apr 2023 14:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681309524; 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=s/HapDv5NRmuZPKBXRwFqq+MkXya+ZDPUndSvCyxFQM=; b=MbeDaFP5LsdOmBhAvIZhJSBU5hpM4i8MP3S4M0OEyBTp/w3R7Pnye4JxqWPwOKvmJW860z Xmu8MZ1hfNPN6F98m5Xq9lYmPLPt5vsid/UPcP2gNfEStuN+K5zQyE0H7ntwvqkTbNFhph HJkhJw4EFiorrwxPijWwuepmsnmCPTM= X-MC-Unique: 6H-nHQgeN324w2gNAp-NAg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] qemuDomainChrRemove: Don't leak vmdef->consoles[0] Date: Wed, 12 Apr 2023 16:25:07 +0200 Message-Id: <31b29272dc4ce06c17848a472935cac5863d1aa3.1681307447.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681309527611100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When removing the compat console from domain defintion, removing it from the vmdef->consoles array is good, but not sufficient. The console definition might have been fully allocated (after daemon restarted and reloaded the status XML). Use virDomainChrDefFree() to free also the definition. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f517646c55..a6407f074b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1937,8 +1937,10 @@ qemuDomainChrRemove(virDomainDef *vmdef, return NULL; } =20 - if (removeCompat) + if (removeCompat) { + virDomainChrDefFree(vmdef->consoles[0]); VIR_DELETE_ELEMENT(vmdef->consoles, 0, vmdef->nconsoles); + } =20 return ret; } --=20 2.39.2 From nobody Mon Feb 9 01:44:06 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1681309528; cv=none; d=zohomail.com; s=zohoarc; b=l326RY2UplX0x4mryBvv8ittYrlOjeBP3UbxuQdM/zVo8q90sIgLnHjnHt261TRlBFUkNm4Sm9UMSzuSVRO2wYTh28eZ6IEj7K0CQSdlNQs0aUJMU/mDaQF7FDYS8N8sXl0qAjA48a7UBtIIz6y8el6o4ZdwalQ1e7dMsnCzv1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681309528; 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=8lNOxe9Y3zGEF/V3UFri8pY/UvDpMlAoPYb4oLpCYeI=; b=h9NCl290ukRnqBJQCn48If9iAe2znUbyNQN23yuodhgGW2nhAuC69uTQZ3ghL8198E0+/vqty1esIU3mBCAAebGiJzmU/bBhZWX9y5pfwNMvI3ztQnHm8PQw+Hg+yL30FOQ8KdD1GOGOGoznWp9NLmpq+s6TPJ5Xatmjt+BfBy0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1681309528107939.7766883917127; Wed, 12 Apr 2023 07:25:28 -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-600-ouUtqdtzM6-_zZE6n5GV6Q-1; Wed, 12 Apr 2023 10:25:19 -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 DB56285531A; Wed, 12 Apr 2023 14:25:15 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5413492C13; Wed, 12 Apr 2023 14:25:15 +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 A186C1946595; Wed, 12 Apr 2023 14:25:15 +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 C1C251946597 for ; Wed, 12 Apr 2023 14:25:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A67D82027045; Wed, 12 Apr 2023 14:25:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A7AD2027043 for ; Wed, 12 Apr 2023 14:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681309527; 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=8lNOxe9Y3zGEF/V3UFri8pY/UvDpMlAoPYb4oLpCYeI=; b=JNwwVMdxKzUR2MVGSnJNQwHX/ub9zlt5IuXyf2lNtUz31l4mU7RCxAu0sQGoRis6iE6yfO 0Zrs6hOrHxbqR1RQECPcg4p0NiTsntYnkMczwoM4Pqmq4iUmlj2teKg5R+1wvzczqbrEsz NlsBShiN9Q61C0jEJdFQnktDmIffv04= X-MC-Unique: ouUtqdtzM6-_zZE6n5GV6Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] qemuAssignDeviceChrAlias: Fix a crasher during hotplug Date: Wed, 12 Apr 2023 16:25:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681309529981100001 Content-Type: text/plain; charset="utf-8"; x-default="true" For a running guest, a device can be hotunplugged. This will then remove also aliased . Trying to hotplug a device then, libvirtd crashed because it dereferences def->consoles while there's none. Fixes: 42d53ac799a1d7f1414737caa4deb73871876992 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_alias.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 85db7fbfe3..161d30cf72 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -95,6 +95,7 @@ qemuAssignDeviceChrAlias(virDomainDef *def, if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL && def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && + def->nconsoles && def->consoles[0] =3D=3D chr && def->nserials && def->serials[0]->info.alias) { --=20 2.39.2 From nobody Mon Feb 9 01:44:06 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1681309563; cv=none; d=zohomail.com; s=zohoarc; b=gELalpbn2ehwu6PRqx/VZC20sNp9GQvSg3rC938EUOjdeUeFk92NMvhRNwLuncKRu2LKlWTBO3bydDIOT4TXXwWlw8SuEHihUkDz3e4HLKrF60s+6Rlaoq/vDrRYiwo3dFYu9v3IBQOHZ9mNdQrxUOb98YiKjtjYBkz65I9iwGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681309563; 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=MOSgyFYPh3oTRU5ohtzXZDuSNeD7iNckxO3SxFOx2MA=; b=gGnQf7RG2EXvT7BFZBLjlc0NetGEshvebYToJpsoG9z52ChANDk2ZgHzjFdfiRCTmTe2pXRFPE3NhlKDKD1t9wxjyKLm3utqQI6y0gKEmjIy5IF+fLE1Gs6wOQ1hUxTQTLAK2OSOdUCC8Taye9odXuMlQmvR/xdn/jUH/zZiSEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1681309563207776.43332772752; Wed, 12 Apr 2023 07:26:03 -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-660-QMAsRir2Nt2AVvN3L2qs4w-1; Wed, 12 Apr 2023 10:25:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC91C8996FF; Wed, 12 Apr 2023 14:25:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C30062166B2D; Wed, 12 Apr 2023 14:25:16 +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 9D8D61946A62; Wed, 12 Apr 2023 14:25:16 +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 935AD1946587 for ; Wed, 12 Apr 2023 14:25:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 79CAE2027EAE; Wed, 12 Apr 2023 14:25:15 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11068202717C for ; Wed, 12 Apr 2023 14:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681309562; 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=MOSgyFYPh3oTRU5ohtzXZDuSNeD7iNckxO3SxFOx2MA=; b=GPLDdGQwgwhQLzIVMHIaV+Yi1H7rxWHn6OP1pVsfpUWaPEI66tGHcGKuoSo52c95nlx+IN dGKQHmr4luNv+lkYWUiHbH9p6P7wUPYXbuySh+GmE8bGpJCSuBbqogVeqYdUBku7fkqr/s 4WY6XggPMMwt3aqN9w4tOiCRMPH0ZIg= X-MC-Unique: QMAsRir2Nt2AVvN3L2qs4w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] qemuDomainRemoveChrDevice: Deal with qemuDomainChrRemove() failure Date: Wed, 12 Apr 2023 16:25:09 +0200 Message-Id: <944e105424fa001b99a0b655a64df187a6a410b1.1681307447.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681309563820100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When cleaning up after removed device, qemuDomainChrRemove() is called. But this may fail, in which case we successfully ignore the failure and virDomainChrDefFree() the device anyway. While it decreases our memory consumption, it's a bit too far, especially if the next step is 'virsh dumpxml'. Then our memory consumption decreases all the way down to zero as we crash. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a6407f074b..d9a102191f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4695,6 +4695,7 @@ qemuDomainRemoveChrDevice(virQEMUDriver *driver, virObjectEvent *event; g_autofree char *charAlias =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainChrDef *chrRemoved =3D NULL; int rc =3D 0; =20 VIR_DEBUG("Removing character device %s from domain %p %s", @@ -4728,17 +4729,24 @@ qemuDomainRemoveChrDevice(virQEMUDriver *driver, if (qemuDomainNamespaceTeardownChardev(vm, chr) < 0) VIR_WARN("Unable to remove chr device from /dev"); =20 - qemuDomainReleaseDeviceAddress(vm, &chr->info); - qemuDomainChrRemove(vm->def, chr); + if (!(chrRemoved =3D qemuDomainChrRemove(vm->def, chr))) { + /* At this point, we only have bad options. The device + * was successfully removed from QEMU, denied in CGropus, + * etc. and yet, we failed to remove it from domain + * definition. */ + VIR_WARN("Unable to remove chr device from domain definition"); + } else { + qemuDomainReleaseDeviceAddress(vm, &chrRemoved->info); =20 - /* The caller does not emit the event, so we must do it here. Note - * that the event should be reported only after all backend - * teardown is completed. - */ - event =3D virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias); - virObjectEventStateQueue(driver->domainEventState, event); + /* The caller does not emit the event, so we must do it here. Note + * that the event should be reported only after all backend + * teardown is completed. + */ + event =3D virDomainEventDeviceRemovedNewFromObj(vm, chrRemoved->in= fo.alias); + virObjectEventStateQueue(driver->domainEventState, event); =20 - virDomainChrDefFree(chr); + virDomainChrDefFree(chrRemoved); + } return 0; } =20 --=20 2.39.2 From nobody Mon Feb 9 01:44:06 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1681309526; cv=none; d=zohomail.com; s=zohoarc; b=Z9Ztp24/zD+UdGhLcA7TEvXglEsxSIMbOsNIENmbNASwPm30enalG0LD9PdkkyZPx5asUNcW5sIBM+/+voOeDrjNPIdPHnKCyFD9B6TKXEFqjh1BwMUj5cTVAa40ahGQOJSdsefN+0maRCZrX4cabpSll4mWAnc60QhdWr0n0hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681309526; 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=Qt1I/AuvcNIfO4aqKL55vEI6T/E5yf5Fk9wM9TMjRXA=; b=gwu3tJAxMmo7fDYENps64TWJNzTHXt/0pwHkLsLpOk4DyhJcrKbO+olhJThI2RogKqz4gjN1uqvdAU0xCnjHUajhr9nbWdbgrApkITIuhD4xPZWDGMoYVsy1W1J2fQw9QmfOQsghu3THXbX3zmPlhfiPRB3FWNdAXUA5Y1diba0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1681309526307259.3517870595912; Wed, 12 Apr 2023 07:25:26 -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-392-CkYTDMzgMielmQuvVn4tWg-1; Wed, 12 Apr 2023 10:25:22 -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 07833381494D; Wed, 12 Apr 2023 14:25:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9994C15BB8; Wed, 12 Apr 2023 14:25:17 +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 D9D2D194658F; Wed, 12 Apr 2023 14:25:17 +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 88AF51946A41 for ; Wed, 12 Apr 2023 14:25:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6B82F2027043; Wed, 12 Apr 2023 14:25:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC4C92027EAD for ; Wed, 12 Apr 2023 14:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681309525; 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=Qt1I/AuvcNIfO4aqKL55vEI6T/E5yf5Fk9wM9TMjRXA=; b=YE9ErJr6KGXP1gIQnmCJkzkApx2g2FioP9krjBrYmpYd1gnVJJp33ga4BFemttH83CPWVg V1UxeS84MFQp2cj3YJc1Q6PCqd7NH25BIGpAAz0PyaL34sHMWHWc6R8AyHl9XlpvQfpQ+L NlPZzHiY29kF2SnZd57j9UxMP3iZTfM= X-MC-Unique: CkYTDMzgMielmQuvVn4tWg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] qemu_hotplug: Deny live detach of Date: Wed, 12 Apr 2023 16:25:10 +0200 Message-Id: <25e8696106dfc388d9b02ddfefb841d02c8b5d2c.1681307447.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681309527870100003 Content-Type: text/plain; charset="utf-8"; x-default="true" I've tried, then I've tried even harder, but still wasn't able to make sense of our console backcompat code in all its fine details. Since I value my sanity, let's just forbid hotunplug of , especially since detaching of corresponding works. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d9a102191f..5072798cb7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5693,6 +5693,16 @@ qemuDomainDetachDeviceChr(virQEMUDriver *driver, goto cleanup; } =20 + if (vmdef->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && + tmpChr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + (tmpChr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERI= AL || + tmpChr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE= )) { + /* Raise this limitation once device removal works. */ + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("detaching of is unsupported. Try corr= esponding instead")); + goto cleanup; + } + /* guestfwd channels are not really -device rather than * -netdev. We need to treat them slightly differently. */ guestfwd =3D tmpChr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHAN= NEL && --=20 2.39.2