From patchwork Fri May 22 06:47:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11564797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28058913 for ; Fri, 22 May 2020 06:56:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00ECA20679 for ; Fri, 22 May 2020 06:56:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="VneAj4WS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00ECA20679 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jc1bi-0000Du-UN for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 May 2020 02:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc1TW-0007WE-87 for qemu-devel@nongnu.org; Fri, 22 May 2020 02:48:10 -0400 Received: from mout.web.de ([212.227.15.4]:48021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc1TU-00016y-NJ for qemu-devel@nongnu.org; Fri, 22 May 2020 02:48:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1590130072; bh=MXoVmF4cguAy8DgHsq/lz4aLwi/zGS3q1d2e0sLrm8s=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=VneAj4WSKIy9b94B7uaPd8VxFjV5EZJB+qOjGAQg9o1noHptIhPskUK9q3OeVdP9N 6eFdaY5/l2YGVpRaWv3PtlnK40qQ77UwjKMm1EJvqsfnEiaDNYMMkXAmAqlM43O1bX Q+XWUNVTz0MgoRzbtt5TeudsODyChImNV/P11I3k= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.67]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MWApN-1jZR3m3Hsv-00XL4Q; Fri, 22 May 2020 08:47:51 +0200 Date: Fri, 22 May 2020 08:47:49 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 6/6] net/colo-compare.c: Correct ordering in complete and finalize Message-ID: <4ea8eafa6a09cd0de48b85f865d88195ddb2e74e.1590129793.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:dAgkL82XolU30CnmSdgu3mkibl9fbyP93lT710BODEZEXcm6zRW fvSzQ+CQ7ZkcmZEqNBl5kxa0LwZ5FMdaNf7NwX17FBc4Y1ukgRYav5JEU62w1MlUMY7gJwN 73qK3TaCQnxMX3UamjCVZFF5QxMmlLJ7ijldiBkS96rVp38OiFW5ic0ly6HyuYS57isVQxK Vi8Zw2HJk1M6RBQ/6vSsA== X-UI-Out-Filterresults: notjunk:1;V03:K0:Dv7s4B8EJ6k=:/9qHpXxKLkxYH06ytWLT9I cBVRA6peWl80cjyFMPBjwk/WLQngVgWiL0vPeokZwtaSzmUujIVAWppw2oog9IC4mz8AzI0E3 wImGvc6aghsrgt12FerpLtF72oGgvqoggDHHI+sm9CcffF28b4ulW+vJVhNGEuOy+cnuvE4QF w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N/k0E5g74ML5aHI5XkaWbJWuWBt1N8V wqZASNChyOEkM/ctc Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 02:47:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jason Wang , Li Zhijian , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- net/colo-compare.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) -- 2.20.1 diff --git a/net/colo-compare.c b/net/colo-compare.c index 64d2453450..160776d39e 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); } - qemu_mutex_lock(&colo_compare_mutex); - if (!colo_compare_active) { - qemu_mutex_init(&event_mtx); - qemu_cond_init(&event_complete_cond); - colo_compare_active = true; - } - QTAILQ_INSERT_TAIL(&net_compares, s, next); - qemu_mutex_unlock(&colo_compare_mutex); - s->out_sendco.s = s; s->out_sendco.chr = &s->chr_out; s->out_sendco.notify_remote_frame = false; @@ -1314,6 +1305,16 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) connection_destroy); 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 = true; + } + QTAILQ_INSERT_TAIL(&net_compares, s, next); + qemu_mutex_unlock(&colo_compare_mutex); + return; } @@ -1386,19 +1387,6 @@ static void colo_compare_finalize(Object *obj) CompareState *s = COLO_COMPARE(obj); CompareState *tmp = NULL; - 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 == s) { @@ -1413,6 +1401,19 @@ static void colo_compare_finalize(Object *obj) } qemu_mutex_unlock(&colo_compare_mutex); + 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 = iothread_get_aio_context(s->iothread); aio_context_acquire(ctx); AIO_WAIT_WHILE(ctx, !s->out_sendco.done);