From nobody Thu May 9 20:37:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=zte.com.cn Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1650963899342880.2357585792865; Tue, 26 Apr 2022 02:04:59 -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-472-Ka6f1Fm-O8eFQfATLI3sfQ-1; Tue, 26 Apr 2022 05:04:52 -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 94C7D3810786; Tue, 26 Apr 2022 09:04:50 +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 3559641615C; Tue, 26 Apr 2022 09:04:50 +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 E09261947BBF; Tue, 26 Apr 2022 09:04:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9F0951947BBE for ; Tue, 26 Apr 2022 09:04:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7EE1BC202CB; Tue, 26 Apr 2022 09:04:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AA41C15D5C for ; Tue, 26 Apr 2022 09:04:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.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 624E885A5A8 for ; Tue, 26 Apr 2022 09:04:48 +0000 (UTC) Received: from mxct.zte.com.cn (mxct.zte.com.cn [58.251.27.85]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-aOCKvJu9NqGtKwadOTGMfQ-1; Tue, 26 Apr 2022 05:04:45 -0400 Received: from mxde.zte.com.cn (unknown [10.35.8.64]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4KnbYQ2mmmzvM7 for ; Tue, 26 Apr 2022 17:04:42 +0800 (CST) Received: from mxus.zte.com.cn (unknown [10.207.168.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxde.zte.com.cn (FangMail) with ESMTPS id 4KnbY12mP9zCFQtL for ; Tue, 26 Apr 2022 17:04:21 +0800 (CST) Received: from mxhk.zte.com.cn (unknown [192.168.250.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxus.zte.com.cn (FangMail) with ESMTPS id 4KnbXv4XwQzdmX8n for ; Tue, 26 Apr 2022 17:04:15 +0800 (CST) Received: from mxct.zte.com.cn (unknown [192.168.251.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4KnbXl4WXqz8R03y for ; Tue, 26 Apr 2022 17:04:07 +0800 (CST) Received: from mse-fl1.zte.com.cn (unknown [10.30.14.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4KnbXd2dX6z501RV; Tue, 26 Apr 2022 17:04:01 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl1.zte.com.cn with SMTP id 23Q93qgt059442; Tue, 26 Apr 2022 17:03:52 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-cloudhost8.zte.com.cn (unknown [10.234.72.110]) by smtp (Zmail) with SMTP; Tue, 26 Apr 2022 17:03:52 +0800 X-MC-Unique: Ka6f1Fm-O8eFQfATLI3sfQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: aOCKvJu9NqGtKwadOTGMfQ-1 X-Zmail-TransId: 3e816267b57800d-5abe6 From: Yi Wang To: libvir-list@redhat.com Subject: [PATCH][RESEND] processMonitorEOFEvent:fix delet Domain object about the new VM in processMonitorEOFEvent() Date: Tue, 26 Apr 2022 16:58:03 +0800 Message-Id: <20220426085803.2879-1-wang.yi59@zte.com.cn> MIME-Version: 1.0 X-MAIL: mse-fl1.zte.com.cn 23Q93qgt059442 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.14.novalocal with ID 6267B5A9.000 by FangMail milter! X-FangMail-Envelope: 1650963882/4KnbYQ2mmmzvM7/6267B5A9.000/10.35.8.64/[10.35.8.64]/mxde.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6267B5A9.000/4KnbYQ2mmmzvM7 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.8 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: wang.yi59@zte.com.cn, , wang.liang82@zte.com.cn, Wang PengJun , LIN-184C297BAE7.zte.com.cn@listman.corp.redhat.com, xue.zhihong@zte.com.cn Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1650963900763100001 Content-Type: text/plain; charset="utf-8" From: =E7=8E=8B=E9=B9=8F=E9=92=A710288409 <10288409@zte.intra@LIN-184C297BA= E7.zte.com.cn> Virsh shutdown is executed firstly, virsh destroy is executed later, and VM is recreated again. In this process, due to will delet Domain object about the new VM in processMonitorEOFEvent(), which virDomainObjListRemove is called to remove objlist, the new VM cannot be found through virsh list command and qemu process is still running. Therefore, add virDomainObjListFindByName function checks to avoid delet Domain object about the new VM in objlist. This process chart of problem is as follows shutdown | destroy | create =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemuMonitorIO | | qemuProcessHandleMonitorEOF | | | virDomainDestroy | | qemuProcessStop | | | qemuDomainCreateXML | | qemuProcessInit processMonitorEOFEvent | | qemuDomainRemoveInactive | | | | qemuProcessLaunch Signed-off-by: Wang PengJun Signed-off-by: Yi Wang --- src/qemu/qemu_driver.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ee0963c30d..a504f89724 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4024,6 +4024,7 @@ processMonitorEOFEvent(virQEMUDriver *driver, const char *auditReason =3D "shutdown"; unsigned int stopFlags =3D 0; virObjectEvent *event =3D NULL; + virDomainObj *obj; =20 if (qemuProcessBeginStopJob(driver, vm, VIR_JOB_DESTROY, true) < 0) return; @@ -4055,7 +4056,12 @@ processMonitorEOFEvent(virQEMUDriver *driver, virObjectEventStateQueue(driver->domainEventState, event); =20 endjob: - qemuDomainRemoveInactive(driver, vm); + virObjectUnlock(vm); + obj =3D virDomainObjListFindByName(driver->domains, vm->def->name); + if (vm =3D=3D obj) + qemuDomainRemoveInactive(driver, vm); + virDomainObjEndAPI(&obj); + virObjectLock(vm); qemuDomainObjEndJob(vm); } =20 --=20 2.27.0