From nobody Sun Jul 13 20:38:06 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652425784; cv=none; d=zohomail.com; s=zohoarc; b=l5QdJJA6zkRYDolPm3FPUHMKsIjXC8JRNrG4kGbH0ny2IP55p4xDprEascJ9j1epz1a/k+EElAALB0MfaFdlk4pESD/504/TzWIVReSxZ4zt+9E9S3S2sj+gr5l+Wwv8eBJMDlCt71A/8m59zUfpKFuUt/GoaF6pP/c4jxAbSL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652425784; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lLTCgWh8tMEf/ECVl7WDAR0ennoJMz25C77dPc/klYo=; b=IzF/Te9TleV/OtMaoBqX+4mBX0/C8Nq3JOi3XvEDucW0F03B7t3tXIAtxiVglFFjryei+3jgegiWBjk90DbwwPedBd/AsGsvk3z6uCdL1uZYS2W4irc6jJc5YwU3vBQ2GiqvBXxmPmftvxigo96+Z/bfTB1MsUDDUJ3abxXyT3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652425784656282.97127587192756; Fri, 13 May 2022 00:09:44 -0700 (PDT) Received: from localhost ([::1]:60910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npPQk-0006nD-Uv for importer2@patchew.org; Fri, 13 May 2022 03:09:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npOnz-0007Vg-C0 for qemu-devel@nongnu.org; Fri, 13 May 2022 02:29:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npOnx-0000a9-EO for qemu-devel@nongnu.org; Fri, 13 May 2022 02:29:39 -0400 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-310-SxoN3gJuNQOdm7n9ku_YRA-1; Fri, 13 May 2022 02:29:32 -0400 Received: by mail-oo1-f72.google.com with SMTP id h7-20020a4aa287000000b0035ea2f18e54so3836510ool.10 for ; Thu, 12 May 2022 23:29:32 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7f0:55e:b3e6:9ebe:4b75:fe72]) by smtp.gmail.com with ESMTPSA id a14-20020a05680804ce00b00325cda1ffbasm678341oie.57.2022.05.12.23.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652423373; 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=lLTCgWh8tMEf/ECVl7WDAR0ennoJMz25C77dPc/klYo=; b=Z89uHvKjsvsMSPu8HLIgIkudGAUBN++DH47Nho8dcXHi/5/ry5UqU/EaXtfjsZhs37EETv KQ99KixMbfgZubo8sZnzzaiq4j6yGDQ2FzKxWqIuK4uW3jZkVcKw6yRXEBomDy7GBH7ZEM SzOR/wiVircXUpHOnYy5NkWSzAAfNzc= X-MC-Unique: SxoN3gJuNQOdm7n9ku_YRA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lLTCgWh8tMEf/ECVl7WDAR0ennoJMz25C77dPc/klYo=; b=g/wWeuBBGEqXSx0qVkH/XWf/QGeIiu40ryiu4YNRw/zoT9k2SCGyLlG2qZOGFFcBHB 6PYcH88bI4ZKpUcYxD9QI+BSd0cgO5fedPzK2OOW3ZQG+Hct0Rjdl+up7aC39+LBSr/J k4sdrjYQLeaOiuspB6cpMrx1yMFqvJdN6UkZB23J421e15u5yxsOnLBNe3ebyXiJ+AHQ v9eMCbWziAsyhS0Wd3rOsQa79WWUtVuIyGaweYfxqGmxteiziN0G0qj8kvXLYFNGn7qX FZlfTufH9fLSuRWyG8V7o0ag2kkQ143rxrXeLkvlUuKihbaJMZa2pJLSVAZRrI3oEEPo Krow== X-Gm-Message-State: AOAM530RKV5fKD4CUFOHNEWqd+v/uce1WttA3kBgvJ6Bc0tqOL83/Ysk hIyyamcWhkaDGAtlQ8Igt7gWaID2nkB09H25tHKSebHZwY6WBDk5WR2ywy6FZWxrcRtH3BFIyKI aow8ZOqogRGVyWa4= X-Received: by 2002:a05:6871:80e:b0:ed:895a:ae92 with SMTP id q14-20020a056871080e00b000ed895aae92mr1693846oap.187.1652423371636; Thu, 12 May 2022 23:29:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi+H+JY2f7gGzkfSJNAOtuuvOI/TXW1E4c9xM0UeBPx/mn/h4GezUZTwZ5mBPX5SL/zkrT2w== X-Received: by 2002:a05:6871:80e:b0:ed:895a:ae92 with SMTP id q14-20020a056871080e00b000ed895aae92mr1693830oap.187.1652423371417; Thu, 12 May 2022 23:29:31 -0700 (PDT) From: Leonardo Bras To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Elena Ufimtseva , Jagannathan Raman , John G Johnson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Fam Zheng , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH v13 6/8] multifd: multifd_send_sync_main now returns negative on error Date: Fri, 13 May 2022 03:28:35 -0300 Message-Id: <20220513062836.965425-7-leobras@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220513062836.965425-1-leobras@redhat.com> References: <20220513062836.965425-1-leobras@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=leobras@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652425785898100001 Even though multifd_send_sync_main() currently emits error_reports, it's callers don't really check it before continuing. Change multifd_send_sync_main() to return -1 on error and 0 on success. Also change all it's callers to make use of this change and possibly fail earlier. (This change is important to next patch on multifd zero copy implementation, to make it sure an error in zero-copy flush does not go unnoticed. Signed-off-by: Leonardo Bras Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu --- migration/multifd.h | 2 +- migration/multifd.c | 10 ++++++---- migration/ram.c | 29 ++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 7d0effcb03..bcf5992945 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -20,7 +20,7 @@ int multifd_load_cleanup(Error **errp); bool multifd_recv_all_channels_created(void); bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp); void multifd_recv_sync_main(void); -void multifd_send_sync_main(QEMUFile *f); +int multifd_send_sync_main(QEMUFile *f); int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset); =20 /* Multifd Compression flags */ diff --git a/migration/multifd.c b/migration/multifd.c index 2a8c8570c3..15fb668e64 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -566,17 +566,17 @@ void multifd_save_cleanup(void) multifd_send_state =3D NULL; } =20 -void multifd_send_sync_main(QEMUFile *f) +int multifd_send_sync_main(QEMUFile *f) { int i; =20 if (!migrate_use_multifd()) { - return; + return 0; } if (multifd_send_state->pages->num) { if (multifd_send_pages(f) < 0) { error_report("%s: multifd_send_pages fail", __func__); - return; + return -1; } } for (i =3D 0; i < migrate_multifd_channels(); i++) { @@ -589,7 +589,7 @@ void multifd_send_sync_main(QEMUFile *f) if (p->quit) { error_report("%s: channel %d has already quit", __func__, i); qemu_mutex_unlock(&p->mutex); - return; + return -1; } =20 p->packet_num =3D multifd_send_state->packet_num++; @@ -608,6 +608,8 @@ void multifd_send_sync_main(QEMUFile *f) qemu_sem_wait(&p->sem_sync); } trace_multifd_send_sync_main(multifd_send_state->packet_num); + + return 0; } =20 static void *multifd_send_thread(void *opaque) diff --git a/migration/ram.c b/migration/ram.c index a2489a2699..5f5e37f64d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2909,6 +2909,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMState **rsp =3D opaque; RAMBlock *block; + int ret; =20 if (compress_threads_save_setup()) { return -1; @@ -2943,7 +2944,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ram_control_before_iterate(f, RAM_CONTROL_SETUP); ram_control_after_iterate(f, RAM_CONTROL_SETUP); =20 - multifd_send_sync_main(f); + ret =3D multifd_send_sync_main(f); + if (ret < 0) { + return ret; + } + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); =20 @@ -3052,7 +3057,11 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) out: if (ret >=3D 0 && migration_is_setup_or_active(migrate_get_current()->state)) { - multifd_send_sync_main(rs->f); + ret =3D multifd_send_sync_main(rs->f); + if (ret < 0) { + return ret; + } + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); ram_transferred_add(8); @@ -3112,13 +3121,19 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) ram_control_after_iterate(f, RAM_CONTROL_FINISH); } =20 - if (ret >=3D 0) { - multifd_send_sync_main(rs->f); - qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - qemu_fflush(f); + if (ret < 0) { + return ret; } =20 - return ret; + ret =3D multifd_send_sync_main(rs->f); + if (ret < 0) { + return ret; + } + + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + qemu_fflush(f); + + return 0; } =20 static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, --=20 2.36.1