From nobody Tue Jun 18 01:53:51 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 ARC-Seal: i=1; a=rsa-sha256; t=1686708133; cv=none; d=zohomail.com; s=zohoarc; b=U/xpWOHfsrmxWcOsLRo6n9HoDrMWaJGyb9PiUhL+t6ZCzg/KZSeRoT/I331111ffu+psZr8ohU9uHAqQjzd/90nxR/A+1YGsFoX+9Qflb5PU++5/ihZLFE+M1qEjZEvseLCwndXCRkBTLSlbE+S8wxsOjMoNLxn4d4UoppJtzos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686708133; 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=MLicFV7/qGihdYna6m4VwT6X5m0gMqS8oHhbEc+VNrs=; b=hjF32IYYWVqtP2KfzixuooGjZS8gOOOpodvTrOgo8nnALmal4b9JPL0m7cTcSEQCFlwYpiDdkwJAamRvMrM+dUCigjLOQHQsYr5dLlXWIHch2yJxY1glumN4QpK8vnwibc6/NKNFeWOYJL6k/hw3oxJACgdfCeqXHIIMl7fmlVQ= 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 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 1686708133683506.9524642476806; Tue, 13 Jun 2023 19:02:13 -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-31-UQruEGZOM86XmxeEdpSvtQ-1; Tue, 13 Jun 2023 22:02:10 -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 CE5B5299E763; Wed, 14 Jun 2023 02:02:07 +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 508B5492C1B; Wed, 14 Jun 2023 02:02:05 +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 080ED19452C3; Wed, 14 Jun 2023 02:02:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8EA60194658C for ; Wed, 14 Jun 2023 02:02:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6BF53141510A; Wed, 14 Jun 2023 02:02:03 +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 648A91415102 for ; Wed, 14 Jun 2023 02:02:03 +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 4506080120A for ; Wed, 14 Jun 2023 02:02:03 +0000 (UTC) Received: from baidu.com (mx21.baidu.com [220.181.3.85]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-hPEN2v8UNCmSMua0G64SHA-1; Tue, 13 Jun 2023 22:02:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686708132; 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=MLicFV7/qGihdYna6m4VwT6X5m0gMqS8oHhbEc+VNrs=; b=erpAFnDnC1MkE8Wsrmz/i7Dc5Rch6GD5QFhIobZTLi8HoVDqmqB9+W/tZzRxB67zUPiVCV enudUWUHA8RafCvTxA1gncau3uwMjv5ZzAzb/L85sfDeAi6ha6Kq5ovtDC5ciyurgAuELj CoI60W+gC8xh6gvekelBVHj9Y6AJi6s= X-MC-Unique: UQruEGZOM86XmxeEdpSvtQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: hPEN2v8UNCmSMua0G64SHA-1 From: "Zuo,Boqun" To: "libvir-list@redhat.com" Subject: =?gb2312?B?tPC4tDogW1BBVENIXSBxZW11RG9tYWluV2FpdEZvckRldmljZVJlbW92YWw6?= =?gb2312?B?IHJlY2hlY2sgdGhlIHZhbHVlIG9mIHByaXYtPnVucGx1Zy5hbGlhcyB3aGVu?= =?gb2312?Q?_timeout?= Thread-Topic: [PATCH] qemuDomainWaitForDeviceRemoval: recheck the value of priv->unplug.alias when timeout Thread-Index: AQHZl2Iv22gKPeiiFkWak9r/axtpIa+JmXOQ Date: Wed, 14 Jun 2023 02:01:54 +0000 Message-ID: References: <20230605035936.2704-1-zuoboqun@baidu.com> In-Reply-To: <20230605035936.2704-1-zuoboqun@baidu.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.64.68] MIME-Version: 1.0 X-FEAS-Client-IP: 172.31.51.54 X-FE-Last-Public-Client-IP: 100.100.100.49 X-FE-Policy-ID: 15:10:21:SYSTEM 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 3.1 on 10.11.54.7 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.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: baidu.com Content-Language: zh-CN Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686708137282100001 Content-Type: text/plain; charset="utf-8" ping -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- =E5=8F=91=E4=BB=B6=E4=BA=BA: Zuo,Boqun =20 =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B46=E6=9C=885=E6=97=A5 12:= 00 =E6=94=B6=E4=BB=B6=E4=BA=BA: libvir-list@redhat.com =E6=8A=84=E9=80=81: Zuo,Boqun =E4=B8=BB=E9=A2=98: [PATCH] qemuDomainWaitForDeviceRemoval: recheck the val= ue of priv->unplug.alias when timeout When detaching a device, the following race condition may happen: Once qemuDomainSignalDeviceRemoval() marks the device for removal, it retur= ns true, which means it is the caller that marked the device for removal is= going to remove the device from domain definition. But qemuDomainWaitForDeviceRemoval() may still receive timeout from virDoma= inObjWaitUntil() which is implemented by pthread_cond_timedwait() due to an= unavoidable race between the expiration of the timeout and the predicate state(priv->unplug.alias) change. And then qemuDomainWaitForDeviceRemoval() will return 0, thus the caller wi= ll not remove the device from domain definition. In this situation, the device is still present in the domain definition but= doesn't exist in qemu anymore. Worse, there is no way to remove it from th= e domain definition. Solution is to recheck the value of priv->unplug.alias to determine who is = going to remove the device from domain definition. Signed-off-by: zuo boqun --- src/qemu/qemu_hotplug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 972df5= 72a7..c8028df93a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5399,8 +5399,12 @@ qemuDomainWaitForDeviceRemoval(virDomainObj *vm) until +=3D qemuDomainGetUnplugTimeout(vm); =20 while (priv->unplug.alias) { - if ((rc =3D virDomainObjWaitUntil(vm, until)) =3D=3D 1) - return 0; + if ((rc =3D virDomainObjWaitUntil(vm, until)) =3D=3D 1) { + if (priv->unplug.alias) + return 0; + else + return 1; + } =20 if (rc < 0) { VIR_WARN("Failed to wait on unplug condition for domain '%s' " -- 2.34.0.windows.1