From nobody Fri Mar 29 08:49:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1590134817; cv=none; d=zohomail.com; s=zohoarc; b=Cjy4XA4hpMjzFJkmufkDZAE2ThbnhO2JX1G31wiMxt7Pl/manGrHH+KtsGSi+qiMy+XM6NvO/wE4DtUbI9JZN1ZCe7h5YsiZCcJRbfSX+ZyCgXvxryRgpoxtrPVeRESF+Pn5FeohXYE/fuNeOUjTDgOeAa8EuoQOd1p4kNBlJEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590134817; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=RhJO/pVUQcamJTCiar4a/XYz3ieFTdwOCkBppCBue1k=; b=eMok0V7WQaOsJ7uNaIBVneXjywuhPN7OZ84tsyj6Ih+1RhdBVMPMSstSVKnbtHWODYINdYVemAq9sHPyoyPoNjBTg2h9S0v+0uQ3r7eXJXoTqM0Cl5O6mGFBy3C/3lTahxApw966d9J0ckmk9UdibUSX6WOqRnZPXDbiIOjEbBw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590134817759248.3910858806679; Fri, 22 May 2020 01:06:57 -0700 (PDT) Received: from localhost ([::1]:55352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jc2hk-0003Oz-Ip for importer@patchew.org; Fri, 22 May 2020 04:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc2fd-00069x-KP for qemu-devel@nongnu.org; Fri, 22 May 2020 04:04:45 -0400 Received: from mga17.intel.com ([192.55.52.151]:30282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc2fc-0006Um-Ot for qemu-devel@nongnu.org; Fri, 22 May 2020 04:04:45 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 01:04:43 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005.fm.intel.com with ESMTP; 22 May 2020 01:04:42 -0700 IronPort-SDR: INdNCjF9paE6hFwq3jBRhWsMlRAQhe7mCkCrqRDncVUKPsX1rqBwkTitfIVxgJhzD2vZrSRAw4 Vu1O5cC5l9WA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False IronPort-SDR: oqD34MHsnF+OvOH8PeeYeb4lhEysaQd3KHebdANXq9mUHzepcHxAdcWVvO0DV2EzJGtLIs3mZQ RZpTkI4pecWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,420,1583222400"; d="scan'208";a="467104569" From: Zhang Chen To: Jason Wang Subject: [PATCH V2 6/7] net/colo-compare.c: Correct ordering in complete and finalize Date: Fri, 22 May 2020 15:53:56 +0800 Message-Id: <20200522075357.19883-7-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522075357.19883-1-chen.zhang@intel.com> References: <20200522075357.19883-1-chen.zhang@intel.com> 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=192.55.52.151; envelope-from=chen.zhang@intel.com; helo=mga17.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 04:04:33 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, FROM_ADDR_WS=2.999, FROM_WSP_TRAIL=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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 , Lukas Straub , qemu-dev , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Lukas Straub In colo_compare_complete, insert CompareState into net_compares only after everything has been initialized. In colo_compare_finalize, remove CompareState from net_compares before anything is deinitialized. Signed-off-by: Lukas Straub Reviewed-by: Zhang Chen Signed-off-by: Zhang Chen --- net/colo-compare.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index c30dbfb6e6..ed1f3d0af0 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1283,15 +1283,6 @@ static void colo_compare_complete(UserCreatable *uc,= Error **errp) s->vnet_hdr); } =20 - qemu_mutex_lock(&colo_compare_mutex); - if (!colo_compare_active) { - qemu_mutex_init(&event_mtx); - qemu_cond_init(&event_complete_cond); - colo_compare_active =3D true; - } - QTAILQ_INSERT_TAIL(&net_compares, s, next); - qemu_mutex_unlock(&colo_compare_mutex); - s->out_sendco.s =3D s; s->out_sendco.chr =3D &s->chr_out; s->out_sendco.notify_remote_frame =3D false; @@ -1314,6 +1305,16 @@ static void colo_compare_complete(UserCreatable *uc,= Error **errp) connection_destroy); =20 colo_compare_iothread(s); + + qemu_mutex_lock(&colo_compare_mutex); + if (!colo_compare_active) { + qemu_mutex_init(&event_mtx); + qemu_cond_init(&event_complete_cond); + colo_compare_active =3D true; + } + QTAILQ_INSERT_TAIL(&net_compares, s, next); + qemu_mutex_unlock(&colo_compare_mutex); + return; } =20 @@ -1382,19 +1383,6 @@ static void colo_compare_finalize(Object *obj) CompareState *s =3D COLO_COMPARE(obj); CompareState *tmp =3D NULL; =20 - qemu_chr_fe_deinit(&s->chr_pri_in, false); - qemu_chr_fe_deinit(&s->chr_sec_in, false); - qemu_chr_fe_deinit(&s->chr_out, false); - if (s->notify_dev) { - qemu_chr_fe_deinit(&s->chr_notify_dev, false); - } - - if (s->iothread) { - colo_compare_timer_del(s); - } - - qemu_bh_delete(s->event_bh); - qemu_mutex_lock(&colo_compare_mutex); QTAILQ_FOREACH(tmp, &net_compares, next) { if (tmp =3D=3D s) { @@ -1409,6 +1397,19 @@ static void colo_compare_finalize(Object *obj) } qemu_mutex_unlock(&colo_compare_mutex); =20 + qemu_chr_fe_deinit(&s->chr_pri_in, false); + qemu_chr_fe_deinit(&s->chr_sec_in, false); + qemu_chr_fe_deinit(&s->chr_out, false); + if (s->notify_dev) { + qemu_chr_fe_deinit(&s->chr_notify_dev, false); + } + + if (s->iothread) { + colo_compare_timer_del(s); + } + + qemu_bh_delete(s->event_bh); + AioContext *ctx =3D iothread_get_aio_context(s->iothread); aio_context_acquire(ctx); AIO_WAIT_WHILE(ctx, !s->out_sendco.done); --=20 2.17.1