From nobody Wed May 8 00:18:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=ucloud.cn ARC-Seal: i=1; a=rsa-sha256; t=1591871870; cv=none; d=zohomail.com; s=zohoarc; b=NoHKMnyvIy7nKGgk4YKwLgDXxCO39hXAxrY8PtbyJKCYZUm6Uvf05rrA3LEjmXlZyIJ/qjNp8QoWbfdktEjVnadpP54bjuiu5EmRGvqEk0n7vMoDkNRAvmVF/32deMZcIawW/816TDOigWmIfuHrdIjC72csg6ulz7+el+L8i4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591871870; h=Content-Type:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=wr4hT02z4dgozFJgAjWa50I19a+YBV/oJwqMKajRxlo=; b=IouHLS9VkkoDrBgb1ee31YVnAVwPuMQnSWye2XZbv9y6Q5OvImD9s2DpVVs6c/11xVimGKhiw+ImReaBYc/rEFgKu2eV1X5omAdjbthtopHEKftA7pD+J1OySPPDn52/Cqm3gjs0M6fKwJf2L7sPaBrbWw+OjQsILI2XwiBHS4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591871870414115.63912628280673; Thu, 11 Jun 2020 03:37:50 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-mQHeGNkFMIaca9M3sJDPeA-1; Thu, 11 Jun 2020 06:37:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52341805723; Thu, 11 Jun 2020 10:37:39 +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 1E4C360F8A; Thu, 11 Jun 2020 10:37:38 +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 9F97C1800B73; Thu, 11 Jun 2020 10:37:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05BA3iN7000334 for ; Thu, 11 Jun 2020 06:03:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id F14132029F72; Thu, 11 Jun 2020 10:03:43 +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 EC65A2029F70 for ; Thu, 11 Jun 2020 10:03:41 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E27828007DB for ; Thu, 11 Jun 2020 10:03:40 +0000 (UTC) Received: from m9785.mail.qiye.163.com (m9785.mail.qiye.163.com [220.181.97.85]) by relay.mimecast.com with ESMTP id us-mta-345-poMMrXp0NMW0KJdmE3CLGQ-1; Thu, 11 Jun 2020 06:03:37 -0400 Received: from localhost.localdomain (unknown [106.75.220.3]) by m9785.mail.qiye.163.com (Hmail) with ESMTPA id 3CBC95C1867 for ; Thu, 11 Jun 2020 17:58:09 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591871869; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:content-type:content-type:list-id: list-help:list-unsubscribe:list-subscribe:list-post; bh=wr4hT02z4dgozFJgAjWa50I19a+YBV/oJwqMKajRxlo=; b=AGtnIMm9DzEs0DVe+sMoDRbJGIB9U5l8zW1uy72EfWZp7KV09Ma2BUtsEeCtZ0rPHTdjb8 NrGpUKZyShf3sq5+hGvKRd1v4ySHt2PxfdMEi+snYnOw+3gpDLbEsUvXYyCwhFROiZVp9v YYizR9QtKjQTIk/aOoiY5W02vztXX+4= X-MC-Unique: mQHeGNkFMIaca9M3sJDPeA-1 X-MC-Unique: poMMrXp0NMW0KJdmE3CLGQ-1 From: Bingsong Si To: libvir-list@redhat.com Subject: [PATCH] network: Fix a race condition when shutdown & start vm at the same time Date: Thu, 11 Jun 2020 17:58:02 +0800 Message-Id: <20200611095802.9367-1-owen.si@ucloud.cn> X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZT1VITU5CQkJNQkNNSENCSVlXWShZQU lCN1dZLVlBSVdZDwkaFQgSH1lBWR0iNQs4HDgVKBMuAzo0MR4VCBcLOhxWVlVITkwoSVlXWQkOFx 4IWUFZNTQpNjo3JCkuNz5ZV1kWGg8SFR0UWUFZNDBZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NlE6HCo*KjgzDTABLCwaNT8u PwsaCyNVSlVKTkJKQ01CT0NCT0pJVTMWGhIXVRQMHhVVCBI7DhgXFA4fVRgVRVlXWRILWUFZSktN VUxOVUlJS1VIWVdZCAFZQUpCTE03Bg++ X-HM-Tid: 0a72a2d0c07c2087kuqy3cbc95c1867 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Thu, 11 Jun 2020 06:37:36 -0400 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.79 on 10.5.11.12 X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" when shutdown vm, the qemuProcessStop cleanup virtual interface in two step= s: 1. qemuProcessKill kill qemu process, and vif disappeared 2. ovs-vsctl del-port from the brige if start a vm in the middle of the two steps, the new vm will reused the vi= f, but removed from bridge by step 2 Signed-off-by: Bingsong Si Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_process.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d36088ba98..706248815a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7483,9 +7483,11 @@ void qemuProcessStop(virQEMUDriverPtr driver, if (vport->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE_MIDONE= T) { ignore_value(virNetDevMidonetUnbindPort(vport)); } else if (vport->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE= _OPENVSWITCH) { - ignore_value(virNetDevOpenvswitchRemovePort( - virDomainNetGetActualBridgeName(net), - net->ifname)); + virMacAddr mac; + if (virNetDevGetMAC(net->ifname, &mac) < 0 || !virMacAddr= Cmp(&mac, &net->mac)) + ignore_value(virNetDevOpenvswitchRemovePort( + virDomainNetGetActualBridgeName(net), + net->ifname)); } } =20 --=20 2.18.2