From nobody Thu Dec 18 22:22:12 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623391758979592.4012306099429; Thu, 10 Jun 2021 23:09:18 -0700 (PDT) Received: from localhost ([::1]:50216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lraM1-0004M0-U9 for importer@patchew.org; Fri, 11 Jun 2021 02:09:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lraEC-0004hu-0S for qemu-devel@nongnu.org; Fri, 11 Jun 2021 02:01:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lraE7-0002Mh-D0 for qemu-devel@nongnu.org; Fri, 11 Jun 2021 02:01:11 -0400 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-76-QTYmKKOOPciq60PU2UWw4Q-1; Fri, 11 Jun 2021 02:01:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAB4F800C60; Fri, 11 Jun 2021 06:00:59 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-78.pek2.redhat.com [10.72.13.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E51960917; Fri, 11 Jun 2021 06:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623391266; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=vPoVtXmAAmG35zxaXt/Dm76PZA/RUTQ9Jem1FCBUfxQ=; b=FhalZodWON4b+2zLWKTpmDRAzVGVDl+OF6xqlZGlAkIt29pSfzLSGIeLCgxqxG0b2C1GZc 4LlndmNB6TaPZ0oDl6QKMjO4KZXT22a5spyVqjbF1Kvb7l6gZh3cGzYPCPDfQqVYIOzfrS b2XtMGuiR/pbdDYiOQc1dZErpN7OqLs= X-MC-Unique: QTYmKKOOPciq60PU2UWw4Q-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 11/12] Add the function of colo_compare_cleanup Date: Fri, 11 Jun 2021 14:00:23 +0800 Message-Id: <20210611060024.46763-12-jasowang@redhat.com> In-Reply-To: <20210611060024.46763-1-jasowang@redhat.com> References: <20210611060024.46763-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , "Rao, Lei" , Lukas Straub , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" This patch fixes the following: #0 __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/rais= e.c:50 #1 0x00007f6ae4559859 in __GI_abort () at abort.c:79 #2 0x0000559aaa386720 in error_exit (err=3D16, msg=3D0x559aaa5973d0 <_= _func__.16227> "qemu_mutex_destroy") at util/qemu-thread-posix.c:36 #3 0x0000559aaa3868c5 in qemu_mutex_destroy (mutex=3D0x559aabffe828) a= t util/qemu-thread-posix.c:69 #4 0x0000559aaa2f93a8 in char_finalize (obj=3D0x559aabffe800) at chard= ev/char.c:285 #5 0x0000559aaa23318a in object_deinit (obj=3D0x559aabffe800, type=3D0= x559aabfd7d20) at qom/object.c:606 #6 0x0000559aaa2331b8 in object_deinit (obj=3D0x559aabffe800, type=3D0= x559aabfd9060) at qom/object.c:610 #7 0x0000559aaa233200 in object_finalize (data=3D0x559aabffe800) at qo= m/object.c:620 #8 0x0000559aaa234202 in object_unref (obj=3D0x559aabffe800) at qom/ob= ject.c:1074 #9 0x0000559aaa2356b6 in object_finalize_child_property (obj=3D0x559aa= c0dac10, name=3D0x559aac778760 "compare0-0", opaque=3D0x559aabffe800) at qo= m/object.c:1584 #10 0x0000559aaa232f70 in object_property_del_all (obj=3D0x559aac0dac10= ) at qom/object.c:557 #11 0x0000559aaa2331ed in object_finalize (data=3D0x559aac0dac10) at qo= m/object.c:619 #12 0x0000559aaa234202 in object_unref (obj=3D0x559aac0dac10) at qom/ob= ject.c:1074 #13 0x0000559aaa2356b6 in object_finalize_child_property (obj=3D0x559aa= c0c75c0, name=3D0x559aac0dadc0 "chardevs", opaque=3D0x559aac0dac10) at qom/= object.c:1584 #14 0x0000559aaa233071 in object_property_del_child (obj=3D0x559aac0c75= c0, child=3D0x559aac0dac10, errp=3D0x0) at qom/object.c:580 #15 0x0000559aaa233155 in object_unparent (obj=3D0x559aac0dac10) at qom= /object.c:599 #16 0x0000559aaa2fb721 in qemu_chr_cleanup () at chardev/char.c:1159 #17 0x0000559aa9f9b110 in main (argc=3D54, argv=3D0x7ffeb62fa998, envp= =3D0x7ffeb62fab50) at vl.c:4539 When chardev is cleaned up, chr_write_lock needs to be destroyed. But the colo-compare module is not cleaned up normally before it when the guest poweroff. It is holding chr_write_lock at this time. This will cause qemu crash.So we add the function of colo_compare_cleanup() before qemu_chr_cleanup() to fix the bug. Signed-off-by: Lei Rao Reviewed-by: Zhang Chen Reviewed-by: Lukas Straub Tested-by: Lukas Straub Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 10 ++++++++++ net/colo-compare.h | 1 + net/net.c | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/net/colo-compare.c b/net/colo-compare.c index c142c08..5b538f4 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1402,6 +1402,16 @@ static void colo_compare_init(Object *obj) compare_set_vnet_hdr); } =20 +void colo_compare_cleanup(void) +{ + CompareState *tmp =3D NULL; + CompareState *n =3D NULL; + + QTAILQ_FOREACH_SAFE(tmp, &net_compares, next, n) { + object_unparent(OBJECT(tmp)); + } +} + static void colo_compare_finalize(Object *obj) { CompareState *s =3D COLO_COMPARE(obj); diff --git a/net/colo-compare.h b/net/colo-compare.h index 22ddd51..b055270 100644 --- a/net/colo-compare.h +++ b/net/colo-compare.h @@ -20,5 +20,6 @@ void colo_notify_compares_event(void *opaque, int event, Error **errp); void colo_compare_register_notifier(Notifier *notify); void colo_compare_unregister_notifier(Notifier *notify); +void colo_compare_cleanup(void); =20 #endif /* QEMU_COLO_COMPARE_H */ diff --git a/net/net.c b/net/net.c index 2a47260..76bbb7c 100644 --- a/net/net.c +++ b/net/net.c @@ -52,6 +52,7 @@ #include "qapi/error.h" #include "qapi/opts-visitor.h" #include "sysemu/runstate.h" +#include "net/colo-compare.h" #include "net/filter.h" #include "qapi/string-output-visitor.h" =20 @@ -1402,6 +1403,9 @@ void net_cleanup(void) { NetClientState *nc; =20 + /*cleanup colo compare module for COLO*/ + colo_compare_cleanup(); + /* We may del multiple entries during qemu_del_net_client(), * so QTAILQ_FOREACH_SAFE() is also not safe here. */ --=20 2.7.4