From nobody Fri Sep 20 22:15:57 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; 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=fail(p=none dis=none) header.from=corp.ovh.com ARC-Seal: i=1; a=rsa-sha256; t=1661961986; cv=none; d=zohomail.com; s=zohoarc; b=ZosCaZltnGckYK3uZrrtCsnaAM/Exz566L84u8tUqSwFVKj1KnK/O+Ye8+5RBW76plWfS3HjBW/UBlcSL21mc8j6sjYT8gi6ZduHX32vgnO8bAFD21PWJXKNxtrgFcmgBP9dkuRbGrPEh3V6Qjl7EMgx0Zi3fp9pqaWRAj7y2NI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661961986; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=7zU2iIyMO9YQp29uYLejBAPgC9yFBlNdPyW8WBChV2A=; b=ZATDEiZml9nhk0Xhll1CWlWsNYggIOtXOzEt2wA3OzxVE3kdCjK58uPuzKPo+fOEHK7bdIu7SRCYKFaqUo/vxRmoXxfYu7SUlT0lKL/rIaeFlh/0M7wFh+cy6QW1ogSuTxmoGRm8/QSP3VW7SbkOOL/RdbMIaPaT+6Uk9Sarslo= 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=fail 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 1661961985965371.46142334313265; Wed, 31 Aug 2022 09:06:25 -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-139-LjVP6X1jNuuWPjZ-mpDPjQ-1; Wed, 31 Aug 2022 12:06:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2464980C8EE; Wed, 31 Aug 2022 16:05:58 +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 C0C5B4010D43; Wed, 31 Aug 2022 16:05:57 +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 9ED641946A45; Wed, 31 Aug 2022 16:05:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7148C1946A40 for ; Wed, 31 Aug 2022 12:32:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 26A71492CA5; Wed, 31 Aug 2022 12:32:40 +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 17F41492CA2 for ; Wed, 31 Aug 2022 12:32:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 F410D80418F for ; Wed, 31 Aug 2022 12:32:39 +0000 (UTC) Received: from 10.mo301.mail-out.ovh.net (10.mo301.mail-out.ovh.net [137.74.110.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-354-iKNNJePqP1y5pFXbDaHMYQ-1; Wed, 31 Aug 2022 08:32:37 -0400 Received: from DAGFR10EX2.OVH.local (unknown [51.255.55.251]) by mo301.mail-out.ovh.net (Postfix) with ESMTPS id 41DF199ECA for ; Wed, 31 Aug 2022 14:23:09 +0200 (CEST) Received: from C02DJ10BP3YX.gns.ovh.net (109.190.254.58) by DAGFR10EX2.OVH.local (172.16.2.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.12; Wed, 31 Aug 2022 14:23:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661961985; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7zU2iIyMO9YQp29uYLejBAPgC9yFBlNdPyW8WBChV2A=; b=YlAlgQUmWnBCWqyEfcu7hLIohg+ZCSiwxPInubX1B6gB3SOWqx9L50YSN2ldVR96EOjpd0 p7BWjze22wJxyFuKdkjHxVj/b1zWSHX6xkjfYy0Rafc8Hlvw6+qL1rIUijmK/N1RVPmy4n qIjCNfKhmEEFhzvhJyAgLLof4Aaus1A= X-MC-Unique: LjVP6X1jNuuWPjZ-mpDPjQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: iKNNJePqP1y5pFXbDaHMYQ-1 From: Pierre LIBEAU To: Subject: [PATCH] Fix race condition when detaching a device Date: Wed, 31 Aug 2022 14:22:51 +0200 Message-ID: <20220831122251.74048-1-pierre.libeau@corp.ovh.com> MIME-Version: 1.0 X-Originating-IP: [109.190.254.58] X-ClientProxiedBy: DAGFR9EX1.OVH.local (172.16.2.26) To DAGFR10EX2.OVH.local (172.16.2.31) X-OVH-CORPLIMIT-SKIP: true X-Ovh-Tracer-Id: 5957417882284051308 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekiedgvdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffoggfgtghisehtkeertdertddtnecuhfhrohhmpefrihgvrhhrvgcunffkuefgtegfuceophhivghrrhgvrdhlihgsvggruhestghorhhprdhovhhhrdgtohhmqeenucggtffrrghtthgvrhhnpedtkeffudeguedtiedvjeeukeeftdduudelkeffudeludeuffefkefhvddtteeiveenucfkpheptddrtddrtddrtddpuddtledrudeltddrvdehgedrheeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopefftefihfftuddtgfgivddrqfggjfdrlhhotggrlhdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepphhivghrrhgvrdhlihgsvggruhesohhvhhgtlhhouhgurdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhisghvihhrqdhlihhsthesrhgvughhrghtrdgtohhmpdfovfetjfhoshhtpehmoheftddu 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.9 X-Mailman-Approved-At: Wed, 31 Aug 2022 15:03:00 +0000 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: , Cc: Pierre LIBEAU Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1661961988095100001 Content-Type: text/plain; charset="utf-8" Qemu reply to libvirt "DeviceNotFound" and libvirt didn't clean on the side the live configuration. qemuMonitorDelDevice() return -2 to qemuDomainDeleteDevice() and during this action in qemuDomainDetachDeviceLive() the remove is never call. Ref #359 Signed-off-by: Pierre LIBEAU Reviewed-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9b508dc8f0..52a14a4476 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -93,6 +93,8 @@ qemuDomainResetDeviceRemoval(virDomainObj *vm); * * Returns: 0 on success, * -1 otherwise. + * -2 device does not exist in qemu, but it still + * exists in libvirt */ static int qemuDomainDeleteDevice(virDomainObj *vm, @@ -124,7 +126,6 @@ qemuDomainDeleteDevice(virDomainObj *vm, * domain XML is queried right after detach API the * device would still be there. */ VIR_DEBUG("Detaching of device %s failed and no event arrived"= , alias); - rc =3D 0; } } =20 @@ -6055,7 +6056,11 @@ qemuDomainDetachDeviceLive(virDomainObj *vm, if (!async) qemuDomainMarkDeviceForRemoval(vm, info); =20 - if (qemuDomainDeleteDevice(vm, info->alias) < 0) { + int rc; + rc =3D qemuDomainDeleteDevice(vm, info->alias); + if (rc < 0) { + if (rc =3D=3D -2) + ret =3D qemuDomainRemoveDevice(driver, vm, &detach); if (virDomainObjIsActive(vm)) qemuDomainRemoveAuditDevice(vm, &detach, false); goto cleanup; --=20 2.37.3