From nobody Mon Sep 8 17:04:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1756221541; cv=none; d=zohomail.com; s=zohoarc; b=PPF7FTvfSoFHN8DaINXW1AmOc+BclK0I32R7vvl9W0rWnJrinqXW6pzcrw7VjvMSM9ltllB40SlOIE4d65xQFsJgDn/rUY5190RSnbDk6FXrLwjpuPUWz82vXPN28DE1wZp3PVJ0JmdwAJ/U8BuKNynXbqgpw92lWoj7IfG9tFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756221541; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=RUVxeVZ2Id/6E4ZRYnKA4gki9OOxS4hca+NfHbd3Ihw=; b=H47xBc7f2JWh78do+E7M4hH0SZGYOZXgR0XEt6Yh5+e/ET1KPUrl7Wpj8l4knpKUjtMWMIjj1Gi3fa942t6m+VT5lonpWqt8YVzSqDPATqqlZk4ID0bPBGYtwF19BFxaGcxyvM0Fj2Qci4gU/9u8uPzTeMB7p9qo0MyCvkE9hEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1756221541338540.7936899401548; Tue, 26 Aug 2025 08:19:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7268A43F56; Tue, 26 Aug 2025 11:19:00 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0903A43F38; Tue, 26 Aug 2025 11:17:08 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1B73443F0F; Tue, 26 Aug 2025 11:16:46 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AB15243F0C for ; Tue, 26 Aug 2025 11:16:41 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-iz5_zBfhM_iNH98g607YBg-1; Tue, 26 Aug 2025 11:16:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F343F195608D for ; Tue, 26 Aug 2025 15:16:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.44.22.3]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3F68519560AB for ; Tue, 26 Aug 2025 15:16:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756221401; h=from:from: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; bh=RUVxeVZ2Id/6E4ZRYnKA4gki9OOxS4hca+NfHbd3Ihw=; b=YhmfSD98Icd+eMIjNHPfJN1fwIIiHKZ6t6zeJR5kCmtC/I4UlhtjWJWSgQe0YXabntf7+x kLFey2ER0Q5Ng0m2sGrYGO7AEMDMMB7nELBJa2sF6gtRvSirBW0Z9GCn9BbnQyKiBfKcnt 6N0p0i444ZhJWxa7ylf0Xi8A7bqaFCk= X-MC-Unique: iz5_zBfhM_iNH98g607YBg-1 X-Mimecast-MFC-AGG-ID: iz5_zBfhM_iNH98g607YBg_1756221399 To: devel@lists.libvirt.org Subject: [PATCH 1/3] qemu: hotplug: Audit device detach before deleting it Date: Tue, 26 Aug 2025 17:16:33 +0200 Message-ID: <5330c94ea9b43bcffb53275f60fc31d3745d1f16.1756221301.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JhcUUfyTyggVZZk8c4oMw4-XAO2earXvadW5VsKxSJk_1756221399 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MF26I6IYIPYMN3Q3L4NHTGCYJGODPPZU X-Message-ID-Hash: MF26I6IYIPYMN3Q3L4NHTGCYJGODPPZU X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1756221543176116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Commit f30843142aa0836423f5e3ff7a45707eb13ce553 introduced a code path for solving a race when qemu doesn't know about a device but libvirt still does. The patch introduced a call to 'qemuDomainRemoveDevice' (which deletes/frees the device definition) and placed it before the call to 'qemuDomainRemoveAuditDevice' (which accesses the device definition to do the audit log reporting). Reorder them to prevent the qemu driver crashing in the corner case where qemu already detached the device but libvirt didn't yet process it, which can be triggered by calling the asynchronous 'virDomainDetachDeviceAlias' API. In addition in case when we're about to delete the device and return success we need to also report successful detach in the audit log so the logic calling the auditing function needs to be fixed as well. Resolves: https://issues.redhat.com/browse/RHEL-110191 Fixes: f30843142aa0836423f5e3ff7a45707eb13ce553 Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e9568af125..afc75072ae 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6620,10 +6620,13 @@ qemuDomainDetachDeviceLive(virDomainObj *vm, rc =3D qemuDomainDeleteDevice(vm, info->alias); if (rc < 0) { + /* we want to report succesful detach if device doesn't exist any = more in qemu */ + if (virDomainObjIsActive(vm)) + qemuDomainRemoveAuditDevice(vm, &detach, rc =3D=3D -2); + if (rc =3D=3D -2) ret =3D qemuDomainRemoveDevice(driver, vm, &detach); - if (virDomainObjIsActive(vm)) - qemuDomainRemoveAuditDevice(vm, &detach, false); + goto cleanup; } --=20 2.51.0