From nobody Sun Sep 28 16:33:55 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756576733; cv=none; d=zohomail.com; s=zohoarc; b=Y8mKIXYCltC0482krMPRQLj6P/fIB+tMomSkI/7oXqFf19mw45fl2nhNy4Lbqqw04CwpIxvvUry7XJCP+Alo00tOEAS4SlqamlRoiJCkokdfcBwf9V792ZGsk8GQ1jk8LOrHPrTqY/uFC1DQaleNuTLFxrakrbiIIs7g/47lNJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756576733; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=na4sH+km3HYzwe61swwtwxTI4jRl6teeKdPTZ9vFC40=; b=UOnVzT+YTPxwBQ/eURhfil0BLXXZoVR5EbOGhUCuBhZQhSi5nJCnGFUIBtGZzdZu6a5lJgpiQU2wzrukm+aWC8qSQJYPaVgc57z2ezgmxzWOdpDuZGd3pHpw6xOZc1kal5uEL7ch7oZzM1CLNheYnotwWerFlElKBO7nmICWR6s= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175657673308139.4055758013875; Sat, 30 Aug 2025 10:58:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNeN-000497-H7; Sat, 30 Aug 2025 11:37:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us5NT-0006Sk-6G for qemu-devel@nongnu.org; Fri, 29 Aug 2025 16:07:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us5NR-0005EH-AN for qemu-devel@nongnu.org; Fri, 29 Aug 2025 16:07:14 -0400 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-jBYoufvwP6qav5odHR5_pQ-1; Fri, 29 Aug 2025 16:07:10 -0400 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-324e4c3af5fso2783883a91.3 for ; Fri, 29 Aug 2025 13:07:09 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.47.195.108]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-327d8f66f16sm3570543a91.0.2025.08.29.13.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 13:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756498032; 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=na4sH+km3HYzwe61swwtwxTI4jRl6teeKdPTZ9vFC40=; b=SVrFoXujynoifrOwtv6JhzUNpfc2xK0JELLz3wFHYZuVE0f7FuBN7fr8RDAHBJY3NnJE6C 1NBjL0wT7YiN3UjX4SNpO11NsOngeGzI7Fwx4eJrjFsFRgzE3JjJCZ7bquGA6xdC2tc0hp StICL6mCYM+vkQ2L0Ajab8Umgpo57nQ= X-MC-Unique: jBYoufvwP6qav5odHR5_pQ-1 X-Mimecast-MFC-AGG-ID: jBYoufvwP6qav5odHR5_pQ_1756498029 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756498028; x=1757102828; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=na4sH+km3HYzwe61swwtwxTI4jRl6teeKdPTZ9vFC40=; b=JKhFFhw3MZwb7/mH40ubI0gkq/Qkio88s1jNruAyqEbNA9kdrihaEiLH9yT/wZus0j szqnNCKnQjj+rALmDnTBKpe2wx3blpqoL3CS3A76pp6kfJGBsR+zDNYQLmFsbs1lag5k wbw8FhQJA7Ym+CFkSJpjwEhtWuWe2I8tpejslrMu7EN5ukMX3eO/fdpdHCGZ0uouK0r3 CaOEvSk0nwhC5lnefWvwrJEKexok4Va7AbUmE0fWC6zELmRnJYtrpPgPcjipDyQl9XpM zEDwj1GnjtQZENTp6ka05ubcLO+jqWxzzGl4Y8WxL6jR7AIfaaoMzo6uEG/LnNitN1xY rs3w== X-Gm-Message-State: AOJu0YypirfmpTjW0p8QI4fB1KnUbzmi0LfNbrnrH2QNTgUg/2T+NLDT ju4pOwfwY0PnVlwQ79hfjDW9oNyeiIwNm1OytKMV+PN5dNRhohnNHcCYreK9QJMfa/ILdDmWUzM 6Ff/SfmXA3NNskhVGbYHC2/8jSdSpHWDHsicKPwuqnPgIzSvbfq125T2u/TC1D4Uo X-Gm-Gg: ASbGncsyDdBUWkc+oZgAYVZ8U4EZCPQesQlG5Go58URxoabX835AqeRrW/IMPPZh8L9 4IFPFEM4pQFGRxqId8vHgG/JFyFgqcWBw9MSHa7r+TMSEkHwi0YhuJPITKIIQgxF2vzTnyJXj1P pbW+kocbzOl6/EbzyhG5gtCAN+netZMABN09SF5Qd8FfXbukqP0WgtHz5NxR0meHdduCJfxteYT 7635EqRunFDaCk+6ZoECOFosEQXRn3AFFSpNamGzVZJPVd+GrbYAIJTb8K+GZa7BQw8jWnmNcmy 3Y1x+S9CBpBf9gDYrFi140IOI6PjpMqGmkSKw03yCFsJn0frui6u5w== X-Received: by 2002:a17:90b:2682:b0:327:e34e:eb0c with SMTP id 98e67ed59e1d1-327e34eed02mr6029466a91.7.1756498028385; Fri, 29 Aug 2025 13:07:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEy8+xmFbq4qVMB6F4VleKnbnm/T2NRAXU98aC/DPn+RhCiQWHW4cMMl9EEelpkwXQ7sNopCg== X-Received: by 2002:a17:90b:2682:b0:327:e34e:eb0c with SMTP id 98e67ed59e1d1-327e34eed02mr6029416a91.7.1756498028019; Fri, 29 Aug 2025 13:07:08 -0700 (PDT) From: Arun Menon Date: Sat, 30 Aug 2025 01:32:01 +0530 Subject: [PATCH v13 21/27] migration: push Error **errp into loadvm_process_enable_colo() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250830-propagate_tpm_error-v13-21-a4e777b7eb2c@redhat.com> References: <20250830-propagate_tpm_error-v13-0-a4e777b7eb2c@redhat.com> In-Reply-To: <20250830-propagate_tpm_error-v13-0-a4e777b7eb2c@redhat.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Thomas Huth , Christian Borntraeger , Matthew Rosato , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Nicholas Piggin , Harsh Prateek Bora , Paolo Bonzini , Fam Zheng , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Steve Sistare , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Hailiang Zhang , Stefan Berger , Peter Maydell , qemu-arm@nongnu.org, Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6000; i=armenon@redhat.com; h=from:subject:message-id; bh=ot+hi4Fl01StiAWmhcGyzD+C9KopeNGMvcJMJork/3I=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ8Ymdr8LHXz5TByqJxlPfrScmCfxNbtrqudKZsfXvrd7m adYa+/sKGVhEONikBVTZGn4GiDbFFAYEWn78jrMHFYmkCEMXJwCMBHJywz/I/Rr5vNtPyOfpWXk OOPTkXua0Ruvf50ZeVTjpcYljaM+RQz/1I2OVzXvZMnWPXZ0zsudXEamKSxvrvydZi4Zcfva3xB 3VgA= X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E 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=armenon@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756576734393116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_process_enable_colo() must report an error in errp, in case of failure. Reviewed-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- include/migration/colo.h | 2 +- migration/migration.c | 12 ++++++------ migration/ram.c | 8 ++++---- migration/ram.h | 2 +- migration/savevm.c | 26 ++++++++++++++------------ 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 43222ef5ae6adc3f7d8aa6a48bef79af33d09208..d4fe422e4d335d3bef4f860f564= 00fcd73287a0e 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -25,7 +25,7 @@ void migrate_start_colo_process(MigrationState *s); bool migration_in_colo_state(void); =20 /* loadvm */ -int migration_incoming_enable_colo(void); +int migration_incoming_enable_colo(Error **errp); void migration_incoming_disable_colo(void); bool migration_incoming_colo_enabled(void); bool migration_incoming_in_colo_state(void); diff --git a/migration/migration.c b/migration/migration.c index 35f769bc55c235134abb5554ed01b94787d4bf78..39d6142abccf90c3a35e6c2df3d= f245052eb0bcf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -623,22 +623,22 @@ void migration_incoming_disable_colo(void) migration_colo_enabled =3D false; } =20 -int migration_incoming_enable_colo(void) +int migration_incoming_enable_colo(Error **errp) { #ifndef CONFIG_REPLICATION - error_report("ENABLE_COLO command come in migration stream, but the " - "replication module is not built in"); + error_setg(errp, "ENABLE_COLO command come in migration stream, but th= e " + "replication module is not built in"); return -ENOTSUP; #endif =20 if (!migrate_colo()) { - error_report("ENABLE_COLO command come in migration stream, but x-= colo " - "capability is not set"); + error_setg(errp, "ENABLE_COLO command come in migration stream" + ", but x-colo capability is not set"); return -EINVAL; } =20 if (ram_block_discard_disable(true)) { - error_report("COLO: cannot disable RAM discard"); + error_setg(errp, "COLO: cannot disable RAM discard"); return -EBUSY; } migration_colo_enabled =3D true; diff --git a/migration/ram.c b/migration/ram.c index 163265a57f26fb1dc88d9797629d58c278e9afb7..a8e8d2cc6790336625de626fee0= 70ecc51327200 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3578,7 +3578,7 @@ static void colo_init_ram_state(void) * * Returns zero to indicate success or -1 on error. */ -int colo_init_ram_cache(void) +int colo_init_ram_cache(Error **errp) { RAMBlock *block; =20 @@ -3587,9 +3587,9 @@ int colo_init_ram_cache(void) block->colo_cache =3D qemu_anon_ram_alloc(block->used_length, NULL, false, false); if (!block->colo_cache) { - error_report("%s: Can't alloc memory for COLO cache of blo= ck %s," - "size 0x" RAM_ADDR_FMT, __func__, block->idst= r, - block->used_length); + error_setg(errp, "Can't alloc memory for COLO cache of " + "block %s, size 0x" RAM_ADDR_FMT, + block->idstr, block->used_length); RAMBLOCK_FOREACH_NOT_IGNORED(block) { if (block->colo_cache) { qemu_anon_ram_free(block->colo_cache, block->used_= length); diff --git a/migration/ram.h b/migration/ram.h index 275709a99187f9429ccb4111e05281ec268ba0db..24cd0bf585762cfa1e86834dc03= c6baeea2f0627 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -109,7 +109,7 @@ void ramblock_set_file_bmap_atomic(RAMBlock *block, ram= _addr_t offset, bool set); =20 /* ram cache */ -int colo_init_ram_cache(void); +int colo_init_ram_cache(Error **errp); void colo_flush_ram_cache(void); void colo_release_ram_cache(void); void colo_incoming_start_dirty_log(void); diff --git a/migration/savevm.c b/migration/savevm.c index 13a809564aebf6346228f46fd60f611ba6104bea..8e891243dc1e7f5d3bc3a4326c6= c4a2f5c32e1a2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2515,15 +2515,21 @@ static int loadvm_handle_recv_bitmap(MigrationIncom= ingState *mis, return 0; } =20 -static int loadvm_process_enable_colo(MigrationIncomingState *mis) +static int loadvm_process_enable_colo(MigrationIncomingState *mis, + Error **errp) { - int ret =3D migration_incoming_enable_colo(); + ERRP_GUARD(); + int ret; =20 - if (!ret) { - ret =3D colo_init_ram_cache(); - if (ret) { - migration_incoming_disable_colo(); - } + ret =3D migration_incoming_enable_colo(errp); + if (ret < 0) { + return ret; + } + + ret =3D colo_init_ram_cache(errp); + if (ret) { + error_prepend(errp, "failed to init colo RAM cache: %d: ", ret); + migration_incoming_disable_colo(); } return ret; } @@ -2646,11 +2652,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_handle_recv_bitmap(mis, len, errp); =20 case MIG_CMD_ENABLE_COLO: - ret =3D loadvm_process_enable_colo(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_process_enable_colo(mis, errp); =20 case MIG_CMD_SWITCHOVER_START: ret =3D loadvm_postcopy_handle_switchover_start(); --=20 2.51.0