From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B967EC87FCA for ; Fri, 25 Jul 2025 12:21:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufHPw-0005kJ-Qd; Fri, 25 Jul 2025 08:20:52 -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 1ufHPt-0005bu-Kt for qemu-devel@nongnu.org; Fri, 25 Jul 2025 08:20:49 -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 1ufHPm-0000NN-Tj for qemu-devel@nongnu.org; Fri, 25 Jul 2025 08:20:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753446041; 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=zNAgORb7hQlsYDUYHzd7vbIdy55OMDiBcF3GYRQ8Gek=; b=iF+Dg7XNriboob3YBfQBVIwBc6l2sCiIDkq+nCky1K03cjgcOGczasE+Jy8a/5eePl/9e0 CqCesUAF1cTaNTBk3yL2iqFF0crmomMijrUqIWnCuHu0n3kptPcwLxGQiUkOcY+PiPYzOt g3w5JOGn8p9p78BrfWVW2TPRSAcwDOk= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-UKjqgdLbPYiVJcL6QAMi7g-1; Fri, 25 Jul 2025 08:20:40 -0400 X-MC-Unique: UKjqgdLbPYiVJcL6QAMi7g-1 X-Mimecast-MFC-AGG-ID: UKjqgdLbPYiVJcL6QAMi7g_1753446039 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-311e98ee3fcso3658581a91.0 for ; Fri, 25 Jul 2025 05:20:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753446039; x=1754050839; 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=zNAgORb7hQlsYDUYHzd7vbIdy55OMDiBcF3GYRQ8Gek=; b=l7xehr7gk92SaU2SbvFiGt9Gic7XyU77zxjCPfT3yEJVZYd59Rc1XRNEQ9DjF9VX6d HGtozQcsz2SEy60ANatehKf4FOyJZeg3g7dZbijiN5TyUTARuv/C5XEyK9eKJ6xnBIwX wPGb4CTgRkEaiKLMp1nv5rH5tPguo7rj6Xv+TAPGmAJoWbiUvfUrCGXmZMDz3o0euXPW x0Ne+2onuRxfluhfTG0Vb71onb9TN44FiFpwf5udSDOqB4yW7n3bRyKSKGDhDt/WqVtv VWxuDbRkDNOxFkrHdGiaNV/Lwfi7dF6qtdIiOQ5Kzk8hk6ZMUjinn2QcIdcR//XxiTbm /btA== X-Gm-Message-State: AOJu0Ywtck4JIgrIM9rEZdFfrwAnzQeBcvF42frXIxnA7EDYgpRHGy37 fTYbffYD78D9yxQ9O0TnztZd6HDtFihHdognMPLgvm99I4NC0bSCQTCQICLHsqPF6kSaLuahPJM kvumubDiS0i05MPlGFD7VjL4w2gfRCUXjDdCLLAbkaevG/lw/Z6zd0rmg X-Gm-Gg: ASbGncu0pL+dX8lktLW0GfmjaXpiL+9BKuC0Zf+nUlKv3VT7XTyi+0SS+uSSv7g+wxK xedxOdKfndYq7/MoMEdjoJkqGLsg8qmESGgzk9lLEodzInuMjwE9Ut4T2sOuXQl4+OsFKAGzpBL V0kgDX3raoYFpqKNLbOrL/9AOnV6LZvbPEnfXGGAz6IEu6g+JAevK2d6iKzlH34wmeqxpzb8/fl YbXVg2DGAFEaCywbuWqwvDu4SkCDWbTEDeMEQdPmYv+aC4pd2wYBTLz0HuoAiz0GivDH3DDVtD0 IRk4HdicwuMrCmL6myGkCh4w6+HWj2KHydbe9VjF4EYAC3dV1P+8QA== X-Received: by 2002:a17:90b:1e07:b0:314:2cd2:595d with SMTP id 98e67ed59e1d1-31e765dc413mr2897170a91.8.1753446039218; Fri, 25 Jul 2025 05:20:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNwPpY89pviHlo8ZZKjzlNB1b6XhHRzzS7sBEGMyEOhDsdT38Xv+zeTyWszLRkvCHBnLXTbA== X-Received: by 2002:a17:90b:1e07:b0:314:2cd2:595d with SMTP id 98e67ed59e1d1-31e765dc413mr2897093a91.8.1753446038700; Fri, 25 Jul 2025 05:20:38 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.103.239]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31e662df8dcsm3419352a91.25.2025.07.25.05.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jul 2025 05:20:38 -0700 (PDT) From: Arun Menon Date: Fri, 25 Jul 2025 17:48:50 +0530 Subject: [PATCH v7 11/24] migration: push Error **errp into ram_postcopy_incoming_init() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250725-propagate_tpm_error-v7-11-d52704443975@redhat.com> References: <20250725-propagate_tpm_error-v7-0-d52704443975@redhat.com> In-Reply-To: <20250725-propagate_tpm_error-v7-0-d52704443975@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Christian Borntraeger , Paolo Bonzini , Fam Zheng , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Xu , Fabiano Rosas , Hailiang Zhang , Steve Sistare , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Stefan Berger , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Matthew Rosato , Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4697; i=armenon@redhat.com; h=from:subject:message-id; bh=Xbb6xB2UTYoqNXP7efnq/4hgfmGfqmyIvfICP+ID4G4=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Zzmc407kL1/oPKv1eetuVwWMTm5s5bddMjdJ931N+WB cyLrcw7SlkYxLgYZMUUWRq+Bsg2BRRGRNq+vA4zh5UJZAgDF6cATMTKnZFhoUOUSqh42mvN1RuC BdY3NPa7qXe+t1quvWH/R3GLm54RDH/FGBd/m6nwwfxeIxeTzdW02M2OEvl1B1h2/zvaWnFfcxI 7AA== X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.175, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 ram_postcopy_incoming_init() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- migration/postcopy-ram.c | 9 ++++++--- migration/postcopy-ram.h | 2 +- migration/ram.c | 4 ++-- migration/ram.h | 2 +- migration/savevm.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 45af9a361e8eacaad0fb217a5da2c5004416c1da..05617e5fbcad62226a54fe17d9f7d9a316baf1e4 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -681,6 +681,7 @@ out: */ static int init_range(RAMBlock *rb, void *opaque) { + Error **errp = opaque; const char *block_name = qemu_ram_get_idstr(rb); void *host_addr = qemu_ram_get_host_addr(rb); ram_addr_t offset = qemu_ram_get_offset(rb); @@ -701,6 +702,8 @@ static int init_range(RAMBlock *rb, void *opaque) * (Precopy will just overwrite this data, so doesn't need the discard) */ if (ram_discard_range(block_name, 0, length)) { + error_setg(errp, "failed to discard RAM block %s len=%zu", + block_name, length); return -1; } @@ -749,9 +752,9 @@ static int cleanup_range(RAMBlock *rb, void *opaque) * postcopy later; must be called prior to any precopy. * called from arch_init's similarly named ram_postcopy_incoming_init */ -int postcopy_ram_incoming_init(MigrationIncomingState *mis) +int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp) { - if (foreach_not_ignored_block(init_range, NULL)) { + if (foreach_not_ignored_block(init_range, errp)) { return -1; } @@ -1703,7 +1706,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp) return false; } -int postcopy_ram_incoming_init(MigrationIncomingState *mis) +int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp) { error_report("postcopy_ram_incoming_init: No OS support"); return -1; diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 3852141d7e37ab18bada4b46c137fef0969d0070..ca19433b246893fa5105bcebffb442c58a9a4f48 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -30,7 +30,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis); * postcopy later; must be called prior to any precopy. * called from ram.c's similarly named ram_postcopy_incoming_init */ -int postcopy_ram_incoming_init(MigrationIncomingState *mis); +int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp); /* * At the end of a migration where postcopy_ram_incoming_init was called. diff --git a/migration/ram.c b/migration/ram.c index 7208bc114fb5c366740db380ee6956a91b3871a0..6a0dcc04f436524a37672c41c38f201f06773374 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3716,9 +3716,9 @@ static int ram_load_cleanup(void *opaque) * postcopy-ram. postcopy-ram's similarly names * postcopy_ram_incoming_init does the work. */ -int ram_postcopy_incoming_init(MigrationIncomingState *mis) +int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp) { - return postcopy_ram_incoming_init(mis); + return postcopy_ram_incoming_init(mis, errp); } /** diff --git a/migration/ram.h b/migration/ram.h index 921c39a2c5c45bc2344be80854c46e4c10c09aeb..275709a99187f9429ccb4111e05281ec268ba0db 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -86,7 +86,7 @@ void ram_postcopy_migrated_memory_release(MigrationState *ms); void ram_postcopy_send_discard_bitmap(MigrationState *ms); /* For incoming postcopy discard */ int ram_discard_range(const char *block_name, uint64_t start, size_t length); -int ram_postcopy_incoming_init(MigrationIncomingState *mis); +int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp); int ram_load_postcopy(QEMUFile *f, int channel); void ram_handle_zero(void *host, uint64_t size); diff --git a/migration/savevm.c b/migration/savevm.c index 63cf488d9f411c0fb8d5f1bc8a719aa575bbabdc..60a055f3e1f248b09e5e5d721f14d2eeafd0a7ad 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1989,7 +1989,7 @@ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis, return -1; } - if (ram_postcopy_incoming_init(mis)) { + if (ram_postcopy_incoming_init(mis, NULL) < 0) { return -1; } -- 2.50.0