From nobody Wed May 8 22:52:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1494227078381792.5840949794582; Mon, 8 May 2017 00:04:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D87480059; Mon, 8 May 2017 07:04:36 +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 69548171B4; Mon, 8 May 2017 07:04:34 +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 DA81918523C0; Mon, 8 May 2017 07:04:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4874TQJ007321 for ; Mon, 8 May 2017 03:04:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06E2680B1D; Mon, 8 May 2017 07:04:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F321980B1B for ; Mon, 8 May 2017 07:04:25 +0000 (UTC) Received: from mx7.zte.com.cn (mx7.zte.com.cn [202.103.147.169]) by mx1.redhat.com (Postfix) with ESMTP id 009E43DBEC for ; Mon, 8 May 2017 07:04:22 +0000 (UTC) Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 8 May 2017 06:57:48 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v4873pek076834; Mon, 8 May 2017 15:03:51 +0800 (GMT-8) (envelope-from lu.zhipeng@zte.com.cn) Received: from ceshi.localdomain ([10.74.120.130]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017050815035299-472951 ; Mon, 8 May 2017 15:03:52 +0800 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D87480059 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D87480059 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 009E43DBEC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lu.zhipeng@zte.com.cn DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 009E43DBEC X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170508145748 From: ZhiPeng Lu To: libvir-list@redhat.com, berrange@redhat.com, laine@laine.org Date: Mon, 8 May 2017 15:03:30 +0800 Message-Id: <1494227010-23513-1-git-send-email-lu.zhipeng@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-05-08 15:03:53, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-05-08 15:03:39, Serialize complete at 2017-05-08 15:03:39 X-MAIL: mse01.zte.com.cn v4873pek076834 X-HQIP: 127.0.0.1 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 08 May 2017 07:04:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 08 May 2017 07:04:23 +0000 (UTC) for IP:'202.103.147.169' DOMAIN:'mx7.zte.com.cn' HELO:'mx7.zte.com.cn' FROM:'lu.zhipeng@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -1.922 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RP_MATCHES_RCVD, SPF_PASS) 202.103.147.169 mx7.zte.com.cn 202.103.147.169 mx7.zte.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: ZhiPeng Lu Subject: [libvirt] [PATCH v2] qemu: clean up network interfaces before qemuProcessKill is called in qemuProcessStop 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 08 May 2017 07:04:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In qemuProcessStop we explicitly remove the port from the openvswitch bridg= e after qemuProcessKill is called. But there is a certain interval of time between deleting tap device and removing it from bridge. The problem occurs when tw= o vms start and shutdown with the same name's network interface attached to the s= ame openvswitch bridge. When one vm with the nic named "vnet0" stopping, it del= eted tap device without timely removing the port from bridge. At this time, another vm created the tap device named "vnet0" and added por= t to the same bridge. Then, the first vm removed the port from the same bridge. Finally, the tap device of the second vm did not attached to the bridge. We need to delete the bridge port before deleting the tap device instead of= after. So what's needed is to move the loop in qemuProcessStop that cleans up network interfaces so that it happens before qemuProcessKill is called. Signed-off-by: Zhipeng Lu Signed-off-by: Laine Stump --- src/qemu/qemu_process.c | 99 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 53170d7..f76ced1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6253,56 +6253,6 @@ void qemuProcessStop(virQEMUDriverPtr driver, qemuProcessCleanupChardevDevice, NULL)); =20 - - /* shut it off for sure */ - ignore_value(qemuProcessKill(vm, - VIR_QEMU_PROCESS_KILL_FORCE| - VIR_QEMU_PROCESS_KILL_NOCHECK)); - - qemuDomainCleanupRun(driver, vm); - - /* Stop autodestroy in case guest is restarted */ - qemuProcessAutoDestroyRemove(driver, vm); - - /* now that we know it's stopped call the hook if present */ - if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) { - char *xml =3D qemuDomainDefFormatXML(driver, vm->def, 0); - - /* we can't stop the operation even if the script raised an error = */ - ignore_value(virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name, - VIR_HOOK_QEMU_OP_STOPPED, VIR_HOOK_SUBOP_= END, - NULL, xml, NULL)); - VIR_FREE(xml); - } - - /* Reset Security Labels unless caller don't want us to */ - if (!(flags & VIR_QEMU_PROCESS_STOP_NO_RELABEL)) - qemuSecurityRestoreAllLabel(driver, vm, - !!(flags & VIR_QEMU_PROCESS_STOP_MIGRA= TED)); - - qemuSecurityReleaseLabel(driver->securityManager, vm->def); - - for (i =3D 0; i < vm->def->ndisks; i++) { - virDomainDeviceDef dev; - virDomainDiskDefPtr disk =3D vm->def->disks[i]; - - dev.type =3D VIR_DOMAIN_DEVICE_DISK; - dev.data.disk =3D disk; - ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name)); - } - - /* Clear out dynamically assigned labels */ - for (i =3D 0; i < vm->def->nseclabels; i++) { - if (vm->def->seclabels[i]->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC) - VIR_FREE(vm->def->seclabels[i]->label); - VIR_FREE(vm->def->seclabels[i]->imagelabel); - } - - virStringListFree(priv->qemuDevices); - priv->qemuDevices =3D NULL; - - qemuHostdevReAttachDomainDevices(driver, vm->def); - def =3D vm->def; for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; @@ -6360,6 +6310,55 @@ void qemuProcessStop(virQEMUDriverPtr driver, networkReleaseActualDevice(vm->def, net); } =20 + /* shut it off for sure */ + ignore_value(qemuProcessKill(vm, + VIR_QEMU_PROCESS_KILL_FORCE| + VIR_QEMU_PROCESS_KILL_NOCHECK)); + + qemuDomainCleanupRun(driver, vm); + + /* Stop autodestroy in case guest is restarted */ + qemuProcessAutoDestroyRemove(driver, vm); + + /* now that we know it's stopped call the hook if present */ + if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) { + char *xml =3D qemuDomainDefFormatXML(driver, vm->def, 0); + + /* we can't stop the operation even if the script raised an error = */ + ignore_value(virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name, + VIR_HOOK_QEMU_OP_STOPPED, VIR_HOOK_SUBOP_= END, + NULL, xml, NULL)); + VIR_FREE(xml); + } + + /* Reset Security Labels unless caller don't want us to */ + if (!(flags & VIR_QEMU_PROCESS_STOP_NO_RELABEL)) + qemuSecurityRestoreAllLabel(driver, vm, + !!(flags & VIR_QEMU_PROCESS_STOP_MIGRA= TED)); + + qemuSecurityReleaseLabel(driver->securityManager, vm->def); + + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDeviceDef dev; + virDomainDiskDefPtr disk =3D vm->def->disks[i]; + + dev.type =3D VIR_DOMAIN_DEVICE_DISK; + dev.data.disk =3D disk; + ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name)); + } + + /* Clear out dynamically assigned labels */ + for (i =3D 0; i < vm->def->nseclabels; i++) { + if (vm->def->seclabels[i]->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC) + VIR_FREE(vm->def->seclabels[i]->label); + VIR_FREE(vm->def->seclabels[i]->imagelabel); + } + + virStringListFree(priv->qemuDevices); + priv->qemuDevices =3D NULL; + + qemuHostdevReAttachDomainDevices(driver, vm->def); + retry: if ((ret =3D qemuRemoveCgroup(vm)) < 0) { if (ret =3D=3D -EBUSY && (retries++ < 5)) { --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list