From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462398; cv=none; d=zohomail.com; s=zohoarc; b=Mg/zJfKd0TDe8RiFU1eH6Vi9dWploxoBfmBmCcDskr8GxpnV8iFzMMmmccxx/xfT1zSHGSHXvOb5LKMeatzJjxV9/Q9UKrjhU+qZqxaVClwfcQmBAWCxugZTPWJL/DDHRR5WJwFX6c37uk5R01gYz5JyD128Tz84jH+Xw89CQso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462398; 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=4ICTjmTIp4/9iz8NS7/XDDwyC855gnPc7jJgUvonyEI=; b=TzJQb7l07hsoboidxJPwmBTfgJBvhJTvLvvOgb72BlzAXSTGBavf7IzuZWjgofD3RcRJkMc9w4SpGe+49HwpsuYc3jp9vnfexBvEHQpHcHa7Xf3nnggufT+zi+Uk+px5mRIMKpuXp6FVdaS3hZPjybkVDczpNmM9WoVQHOweF1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462398687112.3645108415609; Thu, 4 Feb 2021 10:13:18 -0800 (PST) Received: from localhost ([::1]:37700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j81-0005ii-Mq for importer@patchew.org; Thu, 04 Feb 2021 13:13:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI2-0007HD-VR for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHp-0005Ib-Fy for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:33 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-33-3dPm2e_QOhySIEQCmfnOXg-1; Thu, 04 Feb 2021 12:19:16 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7B1C80197B; Thu, 4 Feb 2021 17:19:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id C580660CCF; Thu, 4 Feb 2021 17:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459158; 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=4ICTjmTIp4/9iz8NS7/XDDwyC855gnPc7jJgUvonyEI=; b=QM6bd/mqBxm/jfgDRqy95dFPvwxo4DFL1X7uxypGjHndrgpkImb30/p3xXyHp4aUcV5oiH 0TDvbMNxxez2Aix6QuHuSzKestjMkVUZrMRGUAXDVNezsWx1MbeIO3NJ+yhRY5l1p+dxqx DlLHSQE8RUuZflIJ9+XeuLr3ZCT1Ka4= X-MC-Unique: 3dPm2e_QOhySIEQCmfnOXg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 01/33] migration: push Error **errp into qemu_loadvm_state() Date: Thu, 4 Feb 2021 17:18:35 +0000 Message-Id: <20210204171907.901471-2-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/migration.c | 4 ++-- migration/savevm.c | 36 ++++++++++++++++++++---------------- migration/savevm.h | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 1986cb8573..287a18d269 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -519,7 +519,7 @@ static void process_incoming_migration_co(void *opaque) postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_ACTIVE); - ret =3D qemu_loadvm_state(mis->from_src_file); + ret =3D qemu_loadvm_state(mis->from_src_file, &local_err); =20 ps =3D postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); @@ -563,7 +563,7 @@ static void process_incoming_migration_co(void *opaque) } =20 if (ret < 0) { - error_report("load of migration failed: %s", strerror(-ret)); + error_report_err(local_err); goto fail; } mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); diff --git a/migration/savevm.c b/migration/savevm.c index 6b320423c7..c8d93eee1e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2638,40 +2638,49 @@ out: return ret; } =20 -int qemu_loadvm_state(QEMUFile *f) +int qemu_loadvm_state(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); - Error *local_err =3D NULL; int ret; =20 - if (qemu_savevm_state_blocked(&local_err)) { - error_report_err(local_err); - return -EINVAL; + if (qemu_savevm_state_blocked(errp)) { + return -1; } =20 ret =3D qemu_loadvm_state_header(f); if (ret) { - return ret; + error_setg(errp, "Error %d while loading VM state", ret); + return -1; } =20 if (qemu_loadvm_state_setup(f) !=3D 0) { - return -EINVAL; + error_setg(errp, "Error %d while loading VM state", -EINVAL); + return -1; } =20 cpu_synchronize_all_pre_loadvm(); =20 ret =3D qemu_loadvm_state_main(f, mis); + if (ret < 0) { + error_setg(errp, "Error %d while loading VM state", ret); + ret =3D -1; + } qemu_event_set(&mis->main_thread_load_event); =20 trace_qemu_loadvm_state_post_main(ret); =20 if (mis->have_listen_thread) { + error_setg(errp, "Error %d while loading VM state", ret); /* Listen thread still going, can't clean up yet */ return ret; } =20 if (ret =3D=3D 0) { ret =3D qemu_file_get_error(f); + if (ret < 0) { + error_setg(errp, "Error %d while loading VM state", ret); + ret =3D -1; + } } =20 /* @@ -2690,8 +2699,8 @@ int qemu_loadvm_state(QEMUFile *f) uint8_t section_type =3D qemu_get_byte(f); =20 if (section_type !=3D QEMU_VM_VMDESCRIPTION) { - error_report("Expected vmdescription section, but got %d", - section_type); + error_setg(errp, "Expected vmdescription section, but got %d", + section_type); /* * It doesn't seem worth failing at this point since * we apparently have an otherwise valid VM state @@ -2921,7 +2930,6 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) { QEMUFile *f; QIOChannelFile *ioc; - int ret; =20 /* Guest must be paused before loading the device state; the RAM state * will already have been loaded by xc @@ -2940,11 +2948,8 @@ void qmp_xen_load_devices_state(const char *filename= , Error **errp) f =3D qemu_fopen_channel_input(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); =20 - ret =3D qemu_loadvm_state(f); + qemu_loadvm_state(f, errp); qemu_fclose(f); - if (ret < 0) { - error_setg(errp, QERR_IO_ERROR); - } migration_incoming_state_destroy(); } =20 @@ -3018,14 +3023,13 @@ bool load_snapshot(const char *name, const char *vm= state, goto err_drain; } aio_context_acquire(aio_context); - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, errp); migration_incoming_state_destroy(); aio_context_release(aio_context); =20 bdrv_drain_all_end(); =20 if (ret < 0) { - error_setg(errp, "Error %d while loading VM state", ret); return false; } =20 diff --git a/migration/savevm.h b/migration/savevm.h index ba64a7e271..1069e2dd4f 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -60,7 +60,7 @@ void qemu_savevm_send_colo_enable(QEMUFile *f); void qemu_savevm_live_state(QEMUFile *f); int qemu_save_device_state(QEMUFile *f); =20 -int qemu_loadvm_state(QEMUFile *f); +int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(void); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); int qemu_load_device_state(QEMUFile *f); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462614; cv=none; d=zohomail.com; s=zohoarc; b=Z9HLj7tZsgvtEh15BqcsmYQbr0JMOBjI17+t2HgG/6tuhFfQnh3rqGJ/FQJ3jk53kkhYBoTSn3OxvaTpFv6AgL5YGUt2exQRYBDA/2oa3/fmaBVRbMeCImbsBlNWJ6GwTe+kb/SIAJr3aD5XrZbmay5u5geIey6DaBYzcgJ6PZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462614; 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=YGKgElaIhsvlpt+cRXr/iFaG/Eh4AjDHbnagqgiYya8=; b=B050pjOs+XB8vOGMBuFH0764NrHDu26O0TJP5OnADk7Nu+X6VmHOQlFVE4YsHatWRfnOjWqVBIc3R+ImrX79GG2eEeVQiL8YcO0vWemKukKTbZ4SoGWaSHTrZmB2cPJQhW3OkTRj39agUA3z33MljUu07Qa8JAc/yderKrtg/X0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 16124626141401004.038339254146; Thu, 4 Feb 2021 10:16:54 -0800 (PST) Received: from localhost ([::1]:46354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jBU-0001CL-VZ for importer@patchew.org; Thu, 04 Feb 2021 13:16:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI2-0007HE-VK for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHr-0005JW-A5 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:34 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-XtZCNDgVNMaC6Z2LblLfqw-1; Thu, 04 Feb 2021 12:19:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33DC9100C660; Thu, 4 Feb 2021 17:19:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DDA460CCF; Thu, 4 Feb 2021 17:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459161; 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=YGKgElaIhsvlpt+cRXr/iFaG/Eh4AjDHbnagqgiYya8=; b=JU6KLESi7Gq/EVUVwVnAkjAp/t3JGo4BRh2wtPpJquQ3DtUOgapD++PZkXfPgPj+aldpuX tXkPRpKhZalXkVEYBj2yD/OTMwtwNTZUNGR0A81fbpeH/yKEFQz7Vn0gA6HdrPDp+P1zwI d/lItdOpDHg/QgC6Kk9HjPngMP2yaBc= X-MC-Unique: XtZCNDgVNMaC6Z2LblLfqw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 02/33] migration: push Error **errp into qemu_loadvm_state_header() Date: Thu, 4 Feb 2021 17:18:36 +0000 Message-Id: <20210204171907.901471-3-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index c8d93eee1e..870199b629 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2448,38 +2448,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, Migration= IncomingState *mis) return 0; } =20 -static int qemu_loadvm_state_header(QEMUFile *f) +static int qemu_loadvm_state_header(QEMUFile *f, Error **errp) { unsigned int v; int ret; =20 v =3D qemu_get_be32(f); if (v !=3D QEMU_VM_FILE_MAGIC) { - error_report("Not a migration stream"); - return -EINVAL; + error_setg(errp, "Not a migration stream, magic %x !=3D %x", + v, QEMU_VM_FILE_MAGIC); + return -1; } =20 v =3D qemu_get_be32(f); if (v =3D=3D QEMU_VM_FILE_VERSION_COMPAT) { - error_report("SaveVM v2 format is obsolete and don't work anymore"= ); - return -ENOTSUP; + error_setg(errp, "SaveVM v2 format is obsolete and don't work anym= ore"); + return -1; } if (v !=3D QEMU_VM_FILE_VERSION) { - error_report("Unsupported migration stream version"); - return -ENOTSUP; + error_setg(errp, "Unsupported migration stream, version %x !=3D %x= ", + v, QEMU_VM_FILE_VERSION); + return -1; } =20 if (migrate_get_current()->send_configuration) { - if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { - error_report("Configuration section missing"); + v =3D qemu_get_byte(f); + if (v !=3D QEMU_VM_CONFIGURATION) { + error_setg(errp, "Configuration section missing, %x !=3D %x", + v, QEMU_VM_CONFIGURATION); qemu_loadvm_state_cleanup(); - return -EINVAL; + return -1; } ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0); =20 if (ret) { + error_setg(errp, "Error %d while loading VM state", ret); qemu_loadvm_state_cleanup(); - return ret; + return -1; } } return 0; @@ -2647,9 +2652,7 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) return -1; } =20 - ret =3D qemu_loadvm_state_header(f); - if (ret) { - error_setg(errp, "Error %d while loading VM state", ret); + if (qemu_loadvm_state_header(f, errp) < 0) { return -1; } =20 --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462611; cv=none; d=zohomail.com; s=zohoarc; b=Gawp4JUX9AWTW+9fSR3XmNBNJivlRwdAIPjzE1CuQ6NsCi+PsVryzLTY7hKzDfxA0dcJlK12eJIkdIdKliMBaoqrwpXUX+VdF7eDBImxmS4J10KVWuNB7VdE41WQ1UAeHmkoPVaKS0hb0kS8C9J92MN1iXjMxUD71DIL5bH+/Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462611; 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=H1spxRuGKADqe5kdWakopLr0Nmw7HaMMiS0jKdfdPYM=; b=ItY0nHplmHqGhPgHuNah3ESvjQQecQKIuPKNN2cW2BLdRI7ttmER9MEs2L4I8KE9dGrOKh9WbDJNlsq+l1NbFCtgYygr+cFZUEr32JaYJ3S9gmdNgc8eOC8zaKj9214WTAaC4/Nwqbi8ceZ3KbShb/EhAVyMTRmYNNZKGHY73hU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462611343982.116753369757; Thu, 4 Feb 2021 10:16:51 -0800 (PST) Received: from localhost ([::1]:46056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jBS-00012t-4g for importer@patchew.org; Thu, 04 Feb 2021 13:16:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI4-0007Kd-1E for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHr-0005Jv-DI for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-xdhbw3yVPnyUcuGvySoIUQ-1; Thu, 04 Feb 2021 12:19:19 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A408DBBEEC; Thu, 4 Feb 2021 17:19:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E90A60937; Thu, 4 Feb 2021 17:19:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459162; 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=H1spxRuGKADqe5kdWakopLr0Nmw7HaMMiS0jKdfdPYM=; b=XJaMUWGOcgS5kz/vs/xabBbr30rKaOS34fkfPJKrNdOFAVmlsY+opoxcUzOvg0wkZgfwQo HwNNj9x7elEh4uSQT46mTDCE2Paut7MSSA5DOg6i/4Gy2jCB40UnHfpx6V+IdgZYZI/2Ov S2/iFAUU/afeKIIfoC8pKmriEAJdyqY= X-MC-Unique: xdhbw3yVPnyUcuGvySoIUQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 03/33] migration: push Error **errp into qemu_loadvm_state_setup() Date: Thu, 4 Feb 2021 17:18:37 +0000 Message-Id: <20210204171907.901471-4-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 870199b629..f4ed14a230 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2490,7 +2490,7 @@ static int qemu_loadvm_state_header(QEMUFile *f, Erro= r **errp) return 0; } =20 -static int qemu_loadvm_state_setup(QEMUFile *f) +static int qemu_loadvm_state_setup(QEMUFile *f, Error **errp) { SaveStateEntry *se; int ret; @@ -2509,7 +2509,7 @@ static int qemu_loadvm_state_setup(QEMUFile *f) ret =3D se->ops->load_setup(f, se->opaque); if (ret < 0) { qemu_file_set_error(f, ret); - error_report("Load state of device %s failed", se->idstr); + error_setg(errp, "Load state of device %s failed", se->idstr); return ret; } } @@ -2656,8 +2656,7 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) return -1; } =20 - if (qemu_loadvm_state_setup(f) !=3D 0) { - error_setg(errp, "Error %d while loading VM state", -EINVAL); + if (qemu_loadvm_state_setup(f, errp) < 0) { return -1; } =20 --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612460767; cv=none; d=zohomail.com; s=zohoarc; b=eqPfKyhzRAJEFUELmrRDgPCQp4PYQhSjAyZMxCmMZ/Ny4rQ9nzqjQJZEHEBop6WNrNvxFYlVSOC5a6Ae7sQmMQ+W1X2DUp43IECAhGB0+qshyONSDp4nDU6Prp+QWm0bg2yikMR/pk+gWCamYCOTdXl5+OdLO0rWqD+LTWRPYZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612460767; 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=aV60K5iSYGZO/NHqiWupOSBXYV3hOJzXZFsSGX6KjIg=; b=a5wUJZkCIqHFB1DqsMttsGS1oMMreaExlaj0MWgUsfSu91/5Hlg42ZJFkQkvRdG3NjaULH6ntezwuw1+9yezNftYshw9xM3UyA6zQS3MLtHviZqwshXkLU7NvFTk6V5VU7kZT4giyGTKMOsDtk1N4aoyH/h0DPpPdoEQtwUnvWg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612460767140107.44401374106042; Thu, 4 Feb 2021 09:46:07 -0800 (PST) Received: from localhost ([::1]:57600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7ihh-00017u-3D for importer@patchew.org; Thu, 04 Feb 2021 12:46:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI3-0007Ji-Mz for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHs-0005K1-Gc for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-25ZctDZ5PWmPjM_Psku5JA-1; Thu, 04 Feb 2021 12:19:21 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F33A1936B65; Thu, 4 Feb 2021 17:19:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id F072360937; Thu, 4 Feb 2021 17:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459162; 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=aV60K5iSYGZO/NHqiWupOSBXYV3hOJzXZFsSGX6KjIg=; b=cvZkq2K3G8f3jM1Ea3uE6kp0u8oZCxYKzYYPgp7x3qvMYM/viJuwqhkFEO/JAec/cwZjeE tQ/0rRkFwyMxtkirrh1+DyN0aNGeJpP6GU8htPO3NtP7+DWC9VnxqLUgcYrKQAqaeQr5pV gzpVl7A+5k9k9naV7bv05RAxbxYMbko= X-MC-Unique: 25ZctDZ5PWmPjM_Psku5JA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 04/33] migration: push Error **errp into qemu_load_device_state() Date: Thu, 4 Feb 2021 17:18:38 +0000 Message-Id: <20210204171907.901471-5-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/colo.c | 3 +-- migration/savevm.c | 4 ++-- migration/savevm.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index de27662cab..e344b7cf32 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -748,9 +748,8 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, qemu_mutex_lock_iothread(); vmstate_loading =3D true; colo_flush_ram_cache(); - ret =3D qemu_load_device_state(fb); + ret =3D qemu_load_device_state(fb, errp); if (ret < 0) { - error_setg(errp, "COLO: load device state failed"); vmstate_loading =3D false; qemu_mutex_unlock_iothread(); return; diff --git a/migration/savevm.c b/migration/savevm.c index f4ed14a230..dd41292d4e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2726,7 +2726,7 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) return ret; } =20 -int qemu_load_device_state(QEMUFile *f) +int qemu_load_device_state(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); int ret; @@ -2734,7 +2734,7 @@ int qemu_load_device_state(QEMUFile *f) /* Load QEMU_VM_SECTION_FULL section */ ret =3D qemu_loadvm_state_main(f, mis); if (ret < 0) { - error_report("Failed to load device state: %d", ret); + error_setg(errp, "Failed to load device state: %d", ret); return ret; } =20 diff --git a/migration/savevm.h b/migration/savevm.h index 1069e2dd4f..c727bc103e 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -63,6 +63,6 @@ int qemu_save_device_state(QEMUFile *f); int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(void); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); -int qemu_load_device_state(QEMUFile *f); +int qemu_load_device_state(QEMUFile *f, Error **errp); =20 #endif --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461479; cv=none; d=zohomail.com; s=zohoarc; b=NWYIO3mJOgB5OZ7ii8xMdNi9JIoqE537nXOC3hs7+gNtgJbdXxDZkBFIoltwsjGflhVmzcupLZ7pBe1ZUE7hBifTQiP5KKVQUoZFzjsapNUuMKx7pjahIgXU5IYnx23gZIk2x0y0I/Ej6SYnqvIdHgtNL9TsjQ0YSAd/QO3YbkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461479; 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=z82hPCuPNywI76qXcAVHA5376rMDOnpXCV/Rkt7SE5E=; b=NwR0r2qaEPJhKeuXrmpGEm8uEa9cNZY69hcMd6ROo6YsMusgkq4O6MOAmGmYFfaXabzlfETgL0c71lLnEJrewR2uosqPZKPrXO67uOxr1qiFnqWgEtErnDv5FXPMzp/XrwCgB7tJSr1UhkhVfkMQlfkasZC/bIFKaoKrd0sMiHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461479468499.4137811567249; Thu, 4 Feb 2021 09:57:59 -0800 (PST) Received: from localhost ([::1]:57700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7itC-0006VX-5J for importer@patchew.org; Thu, 04 Feb 2021 12:57:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI4-0007MG-Ln for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHv-0005Kk-48 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-i4L7Vw6sNoq2Ks7M5mhMCg-1; Thu, 04 Feb 2021 12:19:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E2C4107ACF6; Thu, 4 Feb 2021 17:19:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 691EC60CCF; Thu, 4 Feb 2021 17:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459165; 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=z82hPCuPNywI76qXcAVHA5376rMDOnpXCV/Rkt7SE5E=; b=GDG2/DH5koTnzPeKSGHk+6xFEv77iFHm9xjhEcUbbya7ja3sW6e4gJr/yCDTLRLHtLAdTx XuJhKGiQjcznHoyPw9qbHQcp0kVBzyhq55Nlx4BRMf3x8pcwvLNUWDMSuZhjfb5Ysl2XC3 /l/PJiQApM8cbbUR3lVpNMoGR9Epgao= X-MC-Unique: i4L7Vw6sNoq2Ks7M5mhMCg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 05/33] migration: push Error **errp into qemu_loadvm_state_main() Date: Thu, 4 Feb 2021 17:18:39 +0000 Message-Id: <20210204171907.901471-6-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/colo.c | 3 +- migration/savevm.c | 73 +++++++++++++++++++++++++++++++--------------- migration/savevm.h | 3 +- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index e344b7cf32..4a050ac579 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -705,11 +705,10 @@ static void colo_incoming_process_checkpoint(Migratio= nIncomingState *mis, =20 qemu_mutex_lock_iothread(); cpu_synchronize_all_states(); - ret =3D qemu_loadvm_state_main(mis->from_src_file, mis); + ret =3D qemu_loadvm_state_main(mis->from_src_file, mis, errp); qemu_mutex_unlock_iothread(); =20 if (ret < 0) { - error_setg(errp, "Load VM's live state (ram) error"); return; } =20 diff --git a/migration/savevm.c b/migration/savevm.c index dd41292d4e..e47aec435c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1819,6 +1819,7 @@ static void *postcopy_ram_listen_thread(void *opaque) QEMUFile *f =3D mis->from_src_file; int load_res; MigrationState *migr =3D migrate_get_current(); + Error *local_err =3D NULL; =20 object_ref(OBJECT(migr)); =20 @@ -1833,7 +1834,7 @@ static void *postcopy_ram_listen_thread(void *opaque) * in qemu_file, and thus we must be blocking now. */ qemu_file_set_blocking(f, true); - load_res =3D qemu_loadvm_state_main(f, mis); + load_res =3D qemu_loadvm_state_main(f, mis, &local_err); =20 /* * This is tricky, but, mis->from_src_file can change after it @@ -1849,6 +1850,7 @@ static void *postcopy_ram_listen_thread(void *opaque) if (load_res < 0) { qemu_file_set_error(f, load_res); dirty_bitmap_mig_cancel_incoming(); + error_report_err(local_err); if (postcopy_state_get() =3D=3D POSTCOPY_INCOMING_RUNNING && !migrate_postcopy_ram() && migrate_dirty_bitmaps()) { @@ -1859,12 +1861,10 @@ static void *postcopy_ram_listen_thread(void *opaqu= e) __func__, load_res); load_res =3D 0; /* prevent further exit() */ } else { - error_report("%s: loadvm failed: %d", __func__, load_res); migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, MIGRATION_STATUS_FAILED); } - } - if (load_res >=3D 0) { + } else { /* * This looks good, but it's possible that the device loading in t= he * main thread hasn't finished yet, and so we might not be in 'RUN' @@ -2116,14 +2116,17 @@ static int loadvm_postcopy_handle_resume(MigrationI= ncomingState *mis) * @mis: Incoming state * @length: Length of packaged data to read * - * Returns: Negative values on error - * + * Returns: + * 0: success + * LOADVM_QUIT: success, but stop + * -1: error */ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis) { int ret; size_t length; QIOChannelBuffer *bioc; + Error *local_err =3D NULL; =20 length =3D qemu_get_be32(mis->from_src_file); trace_loadvm_handle_cmd_packaged(length); @@ -2149,8 +2152,11 @@ static int loadvm_handle_cmd_packaged(MigrationIncom= ingState *mis) =20 QEMUFile *packf =3D qemu_fopen_channel_input(QIO_CHANNEL(bioc)); =20 - ret =3D qemu_loadvm_state_main(packf, mis); + ret =3D qemu_loadvm_state_main(packf, mis, &local_err); trace_loadvm_handle_cmd_packaged_main(ret); + if (ret < 0) { + error_report_err(local_err); + } qemu_fclose(packf); object_unref(OBJECT(bioc)); =20 @@ -2568,7 +2574,14 @@ static bool postcopy_pause_incoming(MigrationIncomin= gState *mis) return true; } =20 -int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) +/* + * Returns: + * 0: success + * LOADVM_QUIT: success, but stop + * -1: error + */ +int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, + Error **errp) { uint8_t section_type; int ret =3D 0; @@ -2579,7 +2592,9 @@ retry: =20 if (qemu_file_get_error(f)) { ret =3D qemu_file_get_error(f); - break; + error_setg(errp, + "Failed to load device state section ID: %d", ret); + goto out; } =20 trace_qemu_loadvm_state_section(section_type); @@ -2588,6 +2603,9 @@ retry: case QEMU_VM_SECTION_FULL: ret =3D qemu_loadvm_section_start_full(f, mis); if (ret < 0) { + error_setg(errp, + "Failed to load device state section start: %d", + ret); goto out; } break; @@ -2595,29 +2613,38 @@ retry: case QEMU_VM_SECTION_END: ret =3D qemu_loadvm_section_part_end(f, mis); if (ret < 0) { + error_setg(errp, + "Failed to load device state section end: %d", = ret); goto out; } break; case QEMU_VM_COMMAND: ret =3D loadvm_process_command(f); trace_qemu_loadvm_state_section_command(ret); - if ((ret < 0) || (ret =3D=3D LOADVM_QUIT)) { + if (ret < 0) { + error_setg(errp, + "Failed to load device state command: %d", ret); + goto out; + } + if (ret =3D=3D LOADVM_QUIT) { goto out; } break; case QEMU_VM_EOF: /* This is the end of migration */ + ret =3D 0; goto out; default: - error_report("Unknown savevm section type %d", section_type); - ret =3D -EINVAL; + error_setg(errp, + "Unknown savevm section type %d", section_type); + ret =3D -1; goto out; } } =20 out: if (ret < 0) { - qemu_file_set_error(f, ret); + qemu_file_set_error(f, -EINVAL); =20 /* Cancel bitmaps incoming regardless of recovery */ dirty_bitmap_mig_cancel_incoming(); @@ -2643,6 +2670,12 @@ out: return ret; } =20 +/* + * Returns: + * 0: success + * LOADVM_QUIT: success, but stop + * -1: error + */ int qemu_loadvm_state(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); @@ -2662,17 +2695,12 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) =20 cpu_synchronize_all_pre_loadvm(); =20 - ret =3D qemu_loadvm_state_main(f, mis); - if (ret < 0) { - error_setg(errp, "Error %d while loading VM state", ret); - ret =3D -1; - } + ret =3D qemu_loadvm_state_main(f, mis, errp); qemu_event_set(&mis->main_thread_load_event); =20 trace_qemu_loadvm_state_post_main(ret); =20 if (mis->have_listen_thread) { - error_setg(errp, "Error %d while loading VM state", ret); /* Listen thread still going, can't clean up yet */ return ret; } @@ -2729,13 +2757,10 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) int qemu_load_device_state(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); - int ret; =20 /* Load QEMU_VM_SECTION_FULL section */ - ret =3D qemu_loadvm_state_main(f, mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state: %d", ret); - return ret; + if (qemu_loadvm_state_main(f, mis, errp) < 0) { + return -1; } =20 cpu_synchronize_all_post_init(); diff --git a/migration/savevm.h b/migration/savevm.h index c727bc103e..1cec83c729 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -62,7 +62,8 @@ int qemu_save_device_state(QEMUFile *f); =20 int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(void); -int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); +int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, + Error **errp); int qemu_load_device_state(QEMUFile *f, Error **errp); =20 #endif --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461740; cv=none; d=zohomail.com; s=zohoarc; b=OgyaNpq8MnjoNu+pCt01FT3iqHZ3hR5OR3dzJX+dHpuKHg/h1L3t/79qJqQKZ33HFGpQy2WQV4XCuX9X6ANvcTOMpeZUoHq7wy4U8QLM82csUo37ebX+z+B8uu9MHfQ1BpUh6IevLdqejjKpgq8Hk0rq1EeZaH+eXzyg8tTuIao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461740; 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=wHusVvUpENiraCIsO2mGYaSUCOjLQU0oOVgnp9EG2Lk=; b=APLeMTaecuwHyqQN0WvM+sxAsQEYkoPhnVsxr6lxGH2ru+1QKEbxmD9x2k4uuZZieDpOfiovYUNdxqTWMbj/VN9K9ODrGggfzU6zZitt2zx3hiZGNgJO3DUANIQ4CNpynEMRHdsXH/Hzt0lHgzfHmUhLW4iqIP9NrQlOqkSVtrk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461740056693.7417139458305; Thu, 4 Feb 2021 10:02:20 -0800 (PST) Received: from localhost ([::1]:38398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7ixN-0001nu-Nm for importer@patchew.org; Thu, 04 Feb 2021 13:02:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI5-0007NO-5Z for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28219) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHv-0005Ko-4I for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-d_EizzR7N-uleCWChIcstA-1; Thu, 04 Feb 2021 12:19:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0995D814301; Thu, 4 Feb 2021 17:19:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D962A60937; Thu, 4 Feb 2021 17:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459165; 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=wHusVvUpENiraCIsO2mGYaSUCOjLQU0oOVgnp9EG2Lk=; b=RwCacpWZnK4eDJ5pNdfbcg0xCHdNnP3smQzZgodDDRgGPTvLaoh6zJkDrA3cIdt2POiv9H FtG+snmPbP4T6Io3QFLV6g5dwL8FlCymnfKwF7k8MX006xS7ddYX9ZOXsTO2jxFSUPoI5D +8eDFPPnYBcvWsLN4xTwznZ+1VAWsrs= X-MC-Unique: d_EizzR7N-uleCWChIcstA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 06/33] migration: push Error **errp into qemu_loadvm_section_start_full() Date: Thu, 4 Feb 2021 17:18:40 +0000 Message-Id: <20210204171907.901471-7-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. This is particularly useful for loading snapshots as this is a likely error scenario to hit when the source and dest VM configs do not match. This is illustrated by the improved error reporting in the QMP load snapshot test. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 49 +++++++++---------- .../tests/internal-snapshots-qapi.out | 3 +- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index e47aec435c..f2eee0a4a7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2350,7 +2350,8 @@ static bool check_section_footer(QEMUFile *f, SaveSta= teEntry *se) } =20 static int -qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) +qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis, + Error **errp) { uint32_t instance_id, version_id, section_id; SaveStateEntry *se; @@ -2360,18 +2361,18 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migrati= onIncomingState *mis) /* Read section start */ section_id =3D qemu_get_be32(f); if (!qemu_get_counted_string(f, idstr)) { - error_report("Unable to read ID string for section %u", - section_id); - return -EINVAL; + error_setg(errp, "Unable to read ID string for section %u", + section_id); + return -1; } instance_id =3D qemu_get_be32(f); version_id =3D qemu_get_be32(f); =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read instance/version ID: %d", - __func__, ret); - return ret; + error_setg(errp, "Failed to read instance/version ID: %d", + ret); + return -1; } =20 trace_qemu_loadvm_state_section_startfull(section_id, idstr, @@ -2379,36 +2380,37 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migrati= onIncomingState *mis) /* Find savevm section */ se =3D find_se(idstr, instance_id); if (se =3D=3D NULL) { - error_report("Unknown savevm section or instance '%s' %"PRIu32". " - "Make sure that your current VM setup matches your " - "saved VM setup, including any hotplugged devices", - idstr, instance_id); - return -EINVAL; + error_setg(errp, "Unknown savevm section or instance '%s' %"PRIu32= ". " + "Make sure that your current VM setup matches your " + "saved VM setup, including any hotplugged devices", + idstr, instance_id); + return -1; } =20 /* Validate version */ if (version_id > se->version_id) { - error_report("savevm: unsupported version %d for '%s' v%d", - version_id, idstr, se->version_id); - return -EINVAL; + error_setg(errp, "savevm: unsupported version %d for '%s' v%d", + version_id, idstr, se->version_id); + return -1; } se->load_version_id =3D version_id; se->load_section_id =3D section_id; =20 /* Validate if it is a device's state */ if (xen_enabled() && se->is_ram) { - error_report("loadvm: %s RAM loading not allowed on Xen", idstr); - return -EINVAL; + error_setg(errp, "loadvm: %s RAM loading not allowed on Xen", idst= r); + return -1; } =20 ret =3D vmstate_load(f, se); if (ret < 0) { - error_report("error while loading state for instance 0x%"PRIx32" o= f" - " device '%s'", instance_id, idstr); - return ret; + error_setg(errp, "error while loading state for instance 0x%"PRIx3= 2" of" + " device '%s'", instance_id, idstr); + return -1; } if (!check_section_footer(f, se)) { - return -EINVAL; + error_setg(errp, "failed check for device state section footer"); + return -1; } =20 return 0; @@ -2601,11 +2603,8 @@ retry: switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret =3D qemu_loadvm_section_start_full(f, mis); + ret =3D qemu_loadvm_section_start_full(f, mis, errp); if (ret < 0) { - error_setg(errp, - "Failed to load device state section start: %d", - ret); goto out; } break; diff --git a/tests/qemu-iotests/tests/internal-snapshots-qapi.out b/tests/q= emu-iotests/tests/internal-snapshots-qapi.out index 26ff4a838c..fd3e2a9ed0 100644 --- a/tests/qemu-iotests/tests/internal-snapshots-qapi.out +++ b/tests/qemu-iotests/tests/internal-snapshots-qapi.out @@ -345,13 +345,12 @@ Formatting 'TEST_DIR/t.qcow2.alt2', fmt=3DIMGFMT size= =3D134217728 "devices": ["diskfmt0"]}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "load-err-stderr= "}} -qemu-system-x86_64: Unknown savevm section or instance '0000:00:02.0/virti= o-rng' 0. Make sure that your current VM setup matches your saved VM setup,= including any hotplugged devices {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "load-err-stderr= "}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "STOP"} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "load-err-stder= r"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "load-err-stde= rr"}} {"execute": "query-jobs"} -{"return": [{"current-progress": 1, "status": "concluded", "total-progress= ": 1, "type": "snapshot-load", "id": "load-err-stderr", "error": "Error -22= while loading VM state"}]} +{"return": [{"current-progress": 1, "status": "concluded", "total-progress= ": 1, "type": "snapshot-load", "id": "load-err-stderr", "error": "Unknown s= avevm section or instance '0000:00:02.0/virtio-rng' 0. Make sure that your = current VM setup matches your saved VM setup, including any hotplugged devi= ces"}]} {"execute": "job-dismiss", "arguments": {"id": "load-err-stderr"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "load-err-stderr"}} --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462758; cv=none; d=zohomail.com; s=zohoarc; b=brLSqMGVzzYw0vlqB9CGi+FAe664+xshx/LxBa8y8XDZppYhGphnUCb90qSsjjP+/Jkwzn5OylW+/YkMz//GtTWWlbVz3AFi8grS41DDa4CqYcjojMG3iHYDbWUypTkDLYiwUBufMZ6lB/7lM2ZxMQLDKOpDjSdZSrIuHHrsfks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462758; 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=r4BAgbkThq9UKPe+0L3DH3cgmVZ8tj4HqG8Ncac36ro=; b=OPJ+J4OElU4siiN/K5Hajb/0lZtO/pgicGcDl36JIMPb4LPstirjvua3s41NJjdFxdtCiHTJ7PYW0yXbpLmnSgHyS+26iXVNoeLvfjtSqS+kGxg8LpXv0Mi9z5/Fd++1gtDRCNWfgWYZNU2LqrIaUUUTJIKB6SC20znDH8+2Bdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462758706294.44070085817293; Thu, 4 Feb 2021 10:19:18 -0800 (PST) Received: from localhost ([::1]:54774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jDp-0005Uw-Hv for importer@patchew.org; Thu, 04 Feb 2021 13:19:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI3-0007KA-Qu for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHw-0005Kv-VX for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-D3B4drhtOamJf_IInesgGA-1; Thu, 04 Feb 2021 12:19:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78DF2801979; Thu, 4 Feb 2021 17:19:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5540360937; Thu, 4 Feb 2021 17:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459167; 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=r4BAgbkThq9UKPe+0L3DH3cgmVZ8tj4HqG8Ncac36ro=; b=gqcyz1sNq2XgbdZ8Oz8ZVinl3/5KIZke/nOKxjrYimodYWGS7ECa7oQqn4PTQr67H72JKb ShSWSLrs4e6Af7eGNd6z/lzECoEZdZy1PF8oHgthOj0ILD6Z7iSH3mo1wFTLwuq4xi6NZp g3W9bAJgpREhUQjbtWGgrLF3tWHk9a0= X-MC-Unique: D3B4drhtOamJf_IInesgGA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 07/33] migration: push Error **errp into qemu_loadvm_section_part_end() Date: Thu, 4 Feb 2021 17:18:41 +0000 Message-Id: <20210204171907.901471-8-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index f2eee0a4a7..350d5a315a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2417,7 +2417,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis, } =20 static int -qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) +qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis, + Error **errp) { uint32_t section_id; SaveStateEntry *se; @@ -2427,9 +2428,9 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIn= comingState *mis) =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read section ID: %d", - __func__, ret); - return ret; + error_setg(errp, "failed to read device state section end ID: %d", + ret); + return -1; } =20 trace_qemu_loadvm_state_section_partend(section_id); @@ -2439,18 +2440,19 @@ qemu_loadvm_section_part_end(QEMUFile *f, Migration= IncomingState *mis) } } if (se =3D=3D NULL) { - error_report("Unknown savevm section %d", section_id); - return -EINVAL; + error_setg(errp, "unknown savevm section %d", section_id); + return -1; } =20 ret =3D vmstate_load(f, se); if (ret < 0) { - error_report("error while loading state section id %d(%s)", - section_id, se->idstr); - return ret; + error_setg(errp, "error while loading state section id %d(%s)", + section_id, se->idstr); + return -1; } if (!check_section_footer(f, se)) { - return -EINVAL; + error_setg(errp, "failed check for device state section footer"); + return -1; } =20 return 0; @@ -2610,10 +2612,8 @@ retry: break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: - ret =3D qemu_loadvm_section_part_end(f, mis); + ret =3D qemu_loadvm_section_part_end(f, mis, errp); if (ret < 0) { - error_setg(errp, - "Failed to load device state section end: %d", = ret); goto out; } break; --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461946; cv=none; d=zohomail.com; s=zohoarc; b=I7TX71PsZUGoeAazp7kR03auUcOyBtUecJ58UhESXUGIOiPw7Gxlo8SdM9MSK4bZ0JU1YUXTeoGU15qUEM2fYaxaSRN24HAoIoGAr9EvPaInczGZw4+u1ndSzK/30Oklr0D8RUfbCkGv45I1PiZvm4ghq6eiGIagaZzWCg6f7zk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461946; 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=Vg1bRX7N9JDOScn0JxILXqPbezFU/kjNDuDBmBTy460=; b=UY9IkO38SiOuBkNYNjCmdYKWE3yPYwVZQAb16bWMC9BOtCjgeljwOPYIbQeP8wz98CH++ow1Bhep2aSCfyRQvssYMgI4kwKbx+89RmGq2QCeyeNmxFOxTknzFZfiKhZ51iy9AmY5KLPqX4yslT3KWj3q9KZm/CcDGuN33Nf4H38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461946653856.6609108905116; Thu, 4 Feb 2021 10:05:46 -0800 (PST) Received: from localhost ([::1]:47198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j0j-00060c-Jh for importer@patchew.org; Thu, 04 Feb 2021 13:05:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI5-0007Np-CQ for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iHy-0005L1-N9 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-5k5US026PgiPMrBs1oUe2A-1; Thu, 04 Feb 2021 12:19:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4C3C107ACE4; Thu, 4 Feb 2021 17:19:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1C7460937; Thu, 4 Feb 2021 17:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459168; 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=Vg1bRX7N9JDOScn0JxILXqPbezFU/kjNDuDBmBTy460=; b=VAeES7nPEazoJmpTugjeJS5kS2LBFT5zIsnToRnf+6DUAuzKL349huHgD1PEbVig+QpvW3 X0NkQqFU/k28kb5NbOvQMkIg0Q/Zx65BT+W7EXw3yVRMiBtsfOP2P3DCpoJC4nxk3oMgnA 6VE3iPwdmtgX+68rl2Uvk93SAzwMY1g= X-MC-Unique: 5k5US026PgiPMrBs1oUe2A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 08/33] migration: push Error **errp into loadvm_process_command() Date: Thu, 4 Feb 2021 17:18:42 +0000 Message-Id: <20210204171907.901471-9-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 87 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 23 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 350d5a315a..450c36994f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2223,34 +2223,37 @@ static int loadvm_process_enable_colo(MigrationInco= mingState *mis) * Process an incoming 'QEMU_VM_COMMAND' * 0 just a normal return * LOADVM_QUIT All good, but exit the loop - * <0 Error + * -1 Error */ -static int loadvm_process_command(QEMUFile *f) +static int loadvm_process_command(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); uint16_t cmd; uint16_t len; uint32_t tmp32; + int ret; =20 cmd =3D qemu_get_be16(f); len =3D qemu_get_be16(f); =20 /* Check validity before continue processing of cmds */ if (qemu_file_get_error(f)) { - return qemu_file_get_error(f); + error_setg(errp, "device state stream has error: %d", + qemu_file_get_error(f)); + return -1; } =20 trace_loadvm_process_command(cmd, len); if (cmd >=3D MIG_CMD_MAX || cmd =3D=3D MIG_CMD_INVALID) { - error_report("MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); - return -EINVAL; + error_setg(errp, "MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); + return -1; } =20 if (mig_cmd_args[cmd].len !=3D -1 && mig_cmd_args[cmd].len !=3D len) { - error_report("%s received with bad length - expecting %zu, got %d", - mig_cmd_args[cmd].name, - (size_t)mig_cmd_args[cmd].len, len); - return -ERANGE; + error_setg(errp, "%s received with bad length - expecting %zu, got= %d", + mig_cmd_args[cmd].name, + (size_t)mig_cmd_args[cmd].len, len); + return -1; } =20 switch (cmd) { @@ -2262,7 +2265,7 @@ static int loadvm_process_command(QEMUFile *f) } mis->to_src_file =3D qemu_file_get_return_path(f); if (!mis->to_src_file) { - error_report("CMD_OPEN_RETURN_PATH failed"); + error_setg(errp, "CMD_OPEN_RETURN_PATH failed"); return -1; } break; @@ -2271,36 +2274,76 @@ static int loadvm_process_command(QEMUFile *f) tmp32 =3D qemu_get_be32(f); trace_loadvm_process_command_ping(tmp32); if (!mis->to_src_file) { - error_report("CMD_PING (0x%x) received with no return path", - tmp32); + error_setg(errp, "CMD_PING (0x%x) received with no return path= ", + tmp32); return -1; } migrate_send_rp_pong(mis, tmp32); break; =20 case MIG_CMD_PACKAGED: - return loadvm_handle_cmd_packaged(mis); + ret =3D loadvm_handle_cmd_packaged(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_POSTCOPY_ADVISE: - return loadvm_postcopy_handle_advise(mis, len); + ret =3D loadvm_postcopy_handle_advise(mis, len); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_POSTCOPY_LISTEN: - return loadvm_postcopy_handle_listen(mis); + ret =3D loadvm_postcopy_handle_listen(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_POSTCOPY_RUN: - return loadvm_postcopy_handle_run(mis); + ret =3D loadvm_postcopy_handle_run(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_POSTCOPY_RAM_DISCARD: - return loadvm_postcopy_ram_handle_discard(mis, len); + ret =3D loadvm_postcopy_ram_handle_discard(mis, len); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_POSTCOPY_RESUME: - return loadvm_postcopy_handle_resume(mis); + ret =3D loadvm_postcopy_handle_resume(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_RECV_BITMAP: - return loadvm_handle_recv_bitmap(mis, len); + ret =3D loadvm_handle_recv_bitmap(mis, len); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; =20 case MIG_CMD_ENABLE_COLO: - return loadvm_process_enable_colo(mis); + ret =3D loadvm_process_enable_colo(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + return -1; + } + return ret; } =20 return 0; @@ -2618,11 +2661,9 @@ retry: } break; case QEMU_VM_COMMAND: - ret =3D loadvm_process_command(f); + ret =3D loadvm_process_command(f, errp); trace_qemu_loadvm_state_section_command(ret); if (ret < 0) { - error_setg(errp, - "Failed to load device state command: %d", ret); goto out; } if (ret =3D=3D LOADVM_QUIT) { --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462170; cv=none; d=zohomail.com; s=zohoarc; b=NtkPBp0tSgVKHjgJIoCN2adOQtjjWYnTeCaxXnmkd/SyDiydBbQ4hsUOXlVQ2eeaTb7TuhIylCQwT3Mx7FJN1ebhUX4Rss7OfazNIgMMc89xQtqtfkxINMXtz2tS478MYUgsKsx62svtRlydCBZ3vmrlYW2vVMOUudi1jy438vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462170; 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=chjKnqN30lt2ndWgun1hEhWVFr6iaBC4+T/1AjolowQ=; b=Uv1RwYI2MgNVzDS3zysvQPOkEpch0OooUhzDyt/sZE4qABL8hmMPIN9GJQs+IACturFcGXZQwJCpc2HHdq5DmWMZinslvq0wkOYTqoeYL+cmLyVYuu8m+E77tod/ttS/yj25kNDDRU3xVP4J/PB2bXQ65h6GsQuQN+6LHOaa+w0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462170017202.7015806604535; Thu, 4 Feb 2021 10:09:30 -0800 (PST) Received: from localhost ([::1]:55900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j4H-0001M2-Sg for importer@patchew.org; Thu, 04 Feb 2021 13:09:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI5-0007OT-Je for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iI2-0005Lq-O7 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-4phkoMkpPxWuqDGNsE8img-1; Thu, 04 Feb 2021 12:19:31 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 738C9BBEE2; Thu, 4 Feb 2021 17:19:30 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52391226EE; Thu, 4 Feb 2021 17:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459173; 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=chjKnqN30lt2ndWgun1hEhWVFr6iaBC4+T/1AjolowQ=; b=XYnnvn8skKEfjxVxzmEF0isRRfiqvjhjnVCEaY+Qpsmq9BmVE8yh2xEfI+F9B41Dkk8YKM N1paJsnDM0RBrhIUxnB9bFhOHcWGWf+NRsGmEUvJp1M1qGCiUe4GtjiBcHiK0Q3/0YNGmN c8dDCV1rZbwgbMv8G73QRbMslwqYKPM= X-MC-Unique: 4phkoMkpPxWuqDGNsE8img-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 09/33] migration: push Error **errp into loadvm_handle_cmd_packaged() Date: Thu, 4 Feb 2021 17:18:43 +0000 Message-Id: <20210204171907.901471-10-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 450c36994f..d9170b4364 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2121,18 +2121,18 @@ static int loadvm_postcopy_handle_resume(MigrationI= ncomingState *mis) * LOADVM_QUIT: success, but stop * -1: error */ -static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis) +static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis, Error *= *errp) { int ret; size_t length; QIOChannelBuffer *bioc; - Error *local_err =3D NULL; =20 length =3D qemu_get_be32(mis->from_src_file); trace_loadvm_handle_cmd_packaged(length); =20 if (length > MAX_VM_CMD_PACKAGED_SIZE) { - error_report("Unreasonably large packaged state: %zu", length); + error_setg(errp, "Unreasonably large packaged state: %zu > %d", + length, MAX_VM_CMD_PACKAGED_SIZE); return -1; } =20 @@ -2143,20 +2143,17 @@ static int loadvm_handle_cmd_packaged(MigrationInco= mingState *mis) length); if (ret !=3D length) { object_unref(OBJECT(bioc)); - error_report("CMD_PACKAGED: Buffer receive fail ret=3D%d length=3D= %zu", - ret, length); - return (ret < 0) ? ret : -EAGAIN; + error_setg(errp, "CMD_PACKAGED: Buffer receive fail ret=3D%d lengt= h=3D%zu", + ret, length); + return -1; } bioc->usage +=3D length; trace_loadvm_handle_cmd_packaged_received(ret); =20 QEMUFile *packf =3D qemu_fopen_channel_input(QIO_CHANNEL(bioc)); =20 - ret =3D qemu_loadvm_state_main(packf, mis, &local_err); + ret =3D qemu_loadvm_state_main(packf, mis, errp); trace_loadvm_handle_cmd_packaged_main(ret); - if (ret < 0) { - error_report_err(local_err); - } qemu_fclose(packf); object_unref(OBJECT(bioc)); =20 @@ -2282,12 +2279,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) break; =20 case MIG_CMD_PACKAGED: - ret =3D loadvm_handle_cmd_packaged(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + return loadvm_handle_cmd_packaged(mis, errp); =20 case MIG_CMD_POSTCOPY_ADVISE: ret =3D loadvm_postcopy_handle_advise(mis, len); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462755; cv=none; d=zohomail.com; s=zohoarc; b=jQO2A7b8EqstNwzSc6ULLRXkfSEzHLcIRH4H2jjTFxCnc8XVyPGNlwpi30QDtExq4gH0Y/HFhSE/4jTE7+Lgzxvs4VnMZRduH2oz+5ou+ZgCORumYQOANEmj2rv5qeMTL8YZ8DdEhxGEaeOOk+RKliaKd380sZS/ZnNEtnDN+tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462755; 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=nkUUws7w7tC36qdn1F3CcV98uafmnqqiPf8sF1W5du8=; b=ZxnDEeGE081dbOxrIMAr8hlnIPt+q7kznRIz8foiwz4pbmBBdOfvDyevlzsTi1dmYxuQHTiztJW1I/vtK3soxbDGF4NYDWHvwUqFJVnp4mICM886yMIBe35dPMPxor7XyYMJqSk2IByEgDRN2WE8YK5vVwl6NBVFOWfVXAX1+d4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462755319378.2403998174052; Thu, 4 Feb 2021 10:19:15 -0800 (PST) Received: from localhost ([::1]:54414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jDl-0005LU-W6 for importer@patchew.org; Thu, 04 Feb 2021 13:19:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iI6-0007R9-PZ for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iI3-0005MF-R4 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-TRcHkzuPPOCaUfmVN0ONdg-1; Thu, 04 Feb 2021 12:19:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28BEC835E23; Thu, 4 Feb 2021 17:19:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA61860937; Thu, 4 Feb 2021 17:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459175; 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=nkUUws7w7tC36qdn1F3CcV98uafmnqqiPf8sF1W5du8=; b=dSAZS8fQvZt8wb/FEzzmVEveU1BQSaTp+Jr6vkYphCxsOYpoJj+HQyNPEQ8XMEwm64/pNQ x/Ht95J/A2loL72ONC+0r+13ZYm6G3Gz0YIrOZIDYIkS+msrEKVfCSBeBnW4oKnQWD3cPM vZBDecTN8EK5GpQAxNKlRpjYhYDqSMc= X-MC-Unique: TRcHkzuPPOCaUfmVN0ONdg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 10/33] migration: push Error **errp into loadvm_postcopy_handle_advise() Date: Thu, 4 Feb 2021 17:18:44 +0000 Message-Id: <20210204171907.901471-11-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index d9170b4364..b0eb250d1c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1644,38 +1644,41 @@ enum LoadVMExitCodes { * quickly. */ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis, - uint16_t len) + uint16_t len, + Error **errp) { PostcopyState ps =3D postcopy_state_set(POSTCOPY_INCOMING_ADVISE); uint64_t remote_pagesize_summary, local_pagesize_summary, remote_tps; - Error *local_err =3D NULL; =20 trace_loadvm_postcopy_handle_advise(); if (ps !=3D POSTCOPY_INCOMING_NONE) { - error_report("CMD_POSTCOPY_ADVISE in wrong postcopy state (%d)", p= s); + error_setg(errp, + "CMD_POSTCOPY_ADVISE in wrong postcopy state (%d)", ps); return -1; } =20 switch (len) { case 0: if (migrate_postcopy_ram()) { - error_report("RAM postcopy is enabled but have 0 byte advise"); - return -EINVAL; + error_setg(errp, "RAM postcopy is enabled but have 0 byte advi= se"); + return -1; } return 0; case 8 + 8: if (!migrate_postcopy_ram()) { - error_report("RAM postcopy is disabled but have 16 byte advise= "); - return -EINVAL; + error_setg(errp, + "RAM postcopy is disabled but have 16 byte advise"); + return -1; } break; default: - error_report("CMD_POSTCOPY_ADVISE invalid length (%d)", len); - return -EINVAL; + error_setg(errp, "CMD_POSTCOPY_ADVISE invalid length (%d)", len); + return -1; } =20 if (!postcopy_ram_supported_by_host(mis)) { postcopy_state_set(POSTCOPY_INCOMING_NONE); + error_setg(errp, "Postcopy RAM not supported by host"); return -1; } =20 @@ -1697,9 +1700,9 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis, * also fails when passed to an older qemu that doesn't * do huge pages. */ - error_report("Postcopy needs matching RAM page sizes (s=3D%" PRIx64 - " d=3D%" PRIx= 64 ")", - remote_pagesize_summary, local_pagesize_summary); + error_setg(errp, "Postcopy needs matching RAM page sizes " + "(s=3D%" PRIx64 " d=3D%" PRIx64 ")", + remote_pagesize_summary, local_pagesize_summary); return -1; } =20 @@ -1709,17 +1712,18 @@ static int loadvm_postcopy_handle_advise(MigrationI= ncomingState *mis, * Again, some differences could be dealt with, but for now keep it * simple. */ - error_report("Postcopy needs matching target page sizes (s=3D%d d= =3D%zd)", - (int)remote_tps, qemu_target_page_size()); + error_setg(errp, + "Postcopy needs matching target page sizes (s=3D%d d=3D= %zd)", + (int)remote_tps, qemu_target_page_size()); return -1; } =20 - if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_ADVISE, &local_err)) { - error_report_err(local_err); + if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_ADVISE, errp)) { return -1; } =20 if (ram_postcopy_incoming_init(mis)) { + error_setg(errp, "Postcopy RAM incoming init failed"); return -1; } =20 @@ -2282,12 +2286,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_handle_cmd_packaged(mis, errp); =20 case MIG_CMD_POSTCOPY_ADVISE: - ret =3D loadvm_postcopy_handle_advise(mis, len); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + return loadvm_postcopy_handle_advise(mis, len, errp); =20 case MIG_CMD_POSTCOPY_LISTEN: ret =3D loadvm_postcopy_handle_listen(mis); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461200; cv=none; d=zohomail.com; s=zohoarc; b=BCGYEyvMuABhvVnPb0qXspfRZfkYjzm9nii794rDJ91qA8C1bkNeoUTfY6mMkcMz4JpFq8sFNOEZ+BH3iztddQCa0KT7DAFfqjv/MeFZDtk1apBk4r5nV14t1nDR5LtE3br8s5Deu4yNF7ql7dMJLVM0BvDZcdG890qk2xeM7Yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461200; 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=qpnFJrKmjfx8jC3liGyK8aQBDBkIsy6KWZI/dHoaB18=; b=iJDRJO7qrjDK2EXoNhAtctYv8IHAahjchW4iEkteQkKB5lXhqgO/GLpci8l/f+lruDcnROaWXvLVfrJtsThld1k68i5UUgJQZCDo50BjsY3wOkq96fsI8rka/dvG4A2kSlxUD4oiWbuoctKFxBM7E8irPOc1skgOJ+Jw9WOLVDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461200948509.27374155997563; Thu, 4 Feb 2021 09:53:20 -0800 (PST) Received: from localhost ([::1]:45870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7ioh-0001L9-Oh for importer@patchew.org; Thu, 04 Feb 2021 12:53:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIC-0007h8-QT for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iI9-0005UY-VA for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-Y1Ghtud-O621OgYoYU8CuA-1; Thu, 04 Feb 2021 12:19:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E4AE107ACE3; Thu, 4 Feb 2021 17:19:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76CD160CFA; Thu, 4 Feb 2021 17:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459181; 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=qpnFJrKmjfx8jC3liGyK8aQBDBkIsy6KWZI/dHoaB18=; b=Ea6fqtn1oM6KQwzZRtMEqV9Dx1O41cYgBywOzghShy7T0s8Hzz/wyaS+pXOgGaj//y41yG qacX7gxyBpSB6jGd4XL9qcv1pWx96S5p1WFBXhCuurANF/YYPJDMFCldqydhb2ExZgGIUL bhqNn9nHYi3d8rrk3xJNehYghxUh7cE= X-MC-Unique: Y1Ghtud-O621OgYoYU8CuA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 11/33] migration: push Error **errp into ram_postcopy_incoming_init() Date: Thu, 4 Feb 2021 17:18:45 +0000 Message-Id: <20210204171907.901471-12-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/postcopy-ram.c | 8 ++++++-- migration/postcopy-ram.h | 2 +- migration/ram.c | 6 +++--- migration/ram.h | 2 +- migration/savevm.c | 3 +-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index ab482adef1..54b748757a 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -446,6 +446,7 @@ out: */ static int init_range(RAMBlock *rb, void *opaque) { + Error **errp =3D opaque; const char *block_name =3D qemu_ram_get_idstr(rb); void *host_addr =3D qemu_ram_get_host_addr(rb); ram_addr_t offset =3D qemu_ram_get_offset(rb); @@ -459,6 +460,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=3D%zu", + block_name, length); return -1; } =20 @@ -507,9 +510,10 @@ 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; } =20 diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 6d2b3cf124..7458ac1199 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -27,7 +27,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *m= is); * 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); =20 /* * At the end of a migration where postcopy_ram_incoming_init was called. diff --git a/migration/ram.c b/migration/ram.c index 7811cde643..f6180e8f4f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3156,7 +3156,7 @@ static int ram_load_cleanup(void *opaque) /** * ram_postcopy_incoming_init: allocate postcopy data structures * - * Returns 0 for success and negative if there was one error + * Returns 0 for success and -1 if there was one error * * @mis: current migration incoming state * @@ -3164,9 +3164,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); } =20 /** diff --git a/migration/ram.h b/migration/ram.h index 011e85414e..1cea36ba51 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -61,7 +61,7 @@ void ram_postcopy_migrated_memory_release(MigrationState = *ms); int ram_postcopy_send_discard_bitmap(MigrationState *ms); /* For incoming postcopy discard */ int ram_discard_range(const char *block_name, uint64_t start, size_t lengt= h); -int ram_postcopy_incoming_init(MigrationIncomingState *mis); +int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp); =20 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); =20 diff --git a/migration/savevm.c b/migration/savevm.c index b0eb250d1c..c505526406 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1722,8 +1722,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis, return -1; } =20 - if (ram_postcopy_incoming_init(mis)) { - error_setg(errp, "Postcopy RAM incoming init failed"); + if (ram_postcopy_incoming_init(mis, errp)) { return -1; } =20 --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612460976; cv=none; d=zohomail.com; s=zohoarc; b=WY3sVxL9IbCOK8ZX8GrfA1GVdNqYT7OSxr5Rp8hFOhlMbUFEvVUeGrggMPkpi7auWSYGhRNjxE+bVSOxlqJn9wdiLN9aW9o1SlPYOX0JzfZe+FWX5FLaDrTeqUEuXUQQvHonNofEL//6awFX7uK+z/zOmaRSV2VGt0zSKHx7d4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612460976; 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=+Bp/ykzT35hp7/WS7WOcWfE7pOcZUPRsrVWHHW+DBlg=; b=GoZAuFXCMIe6n49bWU1RZWMG16ewqX6GTa2u+vSb01b8D5Ymjjq25Qg4iNSNeIx87r1K9Cv2ZFMYByRz7ieAldR9+TldqAHVfHCHLv9SZcUB5NQ3jeQoo3PC99nwRJKWk4vnesch/H2XVUSq9SAKFN+EX66Jiunt1lM6RBmSYrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612460976319485.93311885578294; Thu, 4 Feb 2021 09:49:36 -0800 (PST) Received: from localhost ([::1]:37572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7il4-0005Rr-Qu for importer@patchew.org; Thu, 04 Feb 2021 12:49:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIC-0007gR-GZ for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iI9-0005UR-HF for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-DBXTFUmnM8GEtrtXjPZnDA-1; Thu, 04 Feb 2021 12:19:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B285100C67E; Thu, 4 Feb 2021 17:19:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9D8260CFA; Thu, 4 Feb 2021 17:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459180; 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=+Bp/ykzT35hp7/WS7WOcWfE7pOcZUPRsrVWHHW+DBlg=; b=CC34vmvdbeoN3rf179wofDxAXTAtWS/qVeHPZUqrWLT3vFvYf73EGBu3YdvQnxOZgMVcVs XkqvP/O430cC9dg1AQ+K83kZod4wL+sPY34AhSM6C1ip+tfG1XpnmyeJGGXAMq/xxEGaZD eYsCn4Q/h0VzdINcwcRjO6klsFXc+C8= X-MC-Unique: DBXTFUmnM8GEtrtXjPZnDA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 12/33] migration: push Error **errp into loadvm_postcopy_handle_listen() Date: Thu, 4 Feb 2021 17:18:46 +0000 Message-Id: <20210204171907.901471-13-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index c505526406..447596383f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1909,14 +1909,15 @@ static void *postcopy_ram_listen_thread(void *opaqu= e) } =20 /* After this message we must be able to immediately receive postcopy data= */ -static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) +static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis, + Error **errp) { PostcopyState ps =3D postcopy_state_set(POSTCOPY_INCOMING_LISTENING); trace_loadvm_postcopy_handle_listen(); - Error *local_err =3D NULL; =20 if (ps !=3D POSTCOPY_INCOMING_ADVISE && ps !=3D POSTCOPY_INCOMING_DISC= ARD) { - error_report("CMD_POSTCOPY_LISTEN in wrong postcopy state (%d)", p= s); + error_setg(errp, + "CMD_POSTCOPY_LISTEN in wrong postcopy state (%d)", ps); return -1; } if (ps =3D=3D POSTCOPY_INCOMING_ADVISE) { @@ -1937,12 +1938,12 @@ static int loadvm_postcopy_handle_listen(MigrationI= ncomingState *mis) if (migrate_postcopy_ram()) { if (postcopy_ram_incoming_setup(mis)) { postcopy_ram_incoming_cleanup(mis); + error_setg(errp, "Failed to setup incoming postcoyp RAM blocks= "); return -1; } } =20 - if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, &local_err)) { - error_report_err(local_err); + if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, errp)) { return -1; } =20 @@ -2288,12 +2289,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_handle_advise(mis, len, errp); =20 case MIG_CMD_POSTCOPY_LISTEN: - ret =3D loadvm_postcopy_handle_listen(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + return loadvm_postcopy_handle_listen(mis, errp); =20 case MIG_CMD_POSTCOPY_RUN: ret =3D loadvm_postcopy_handle_run(mis); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461412; cv=none; d=zohomail.com; s=zohoarc; b=LncVdyxfl3B143iyFuRG1OGEzu4zeTumAc3Ip3ZLuMYtaawdL2Lc4o8qzGJQF7FASxo9QXW4lz3vpSh3e9+24Yzm3aVKc2VxpkViOZJAK7esyvz6ts0amjdmsx3wwATpK9AgcyNdCY3YyrwbJff/rrD7xafZuVEUekhtKdILxYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461412; 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=MC30QHI0ippvuMz2I/UVpcjhBn0MYHqiPQJ8FyiwUx0=; b=FyhGc9Z1/lEiuuW3t7bfbP6duz8Sj+Fp0GFmXTi4wbp5XW5Va3bnF3HBAGFycdfMZ+UrVm6VTYkZchFwTp0DLSMHYZfEW4+GHsivc/K2b8NzAn3rZX9kvHHNJoGBDAAp179TalLLZazRxG7HGATiBol5H6IqtJevDMZknJk0VHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461412310412.1252544041124; Thu, 4 Feb 2021 09:56:52 -0800 (PST) Received: from localhost ([::1]:54554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7is7-0005Ae-7D for importer@patchew.org; Thu, 04 Feb 2021 12:56:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iID-0007ix-ED for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIB-0005W0-R0 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-mnw-7be7Mi-zJ2zeD7NXPg-1; Thu, 04 Feb 2021 12:19:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CA01835E23; Thu, 4 Feb 2021 17:19:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5581360CFA; Thu, 4 Feb 2021 17:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459183; 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=MC30QHI0ippvuMz2I/UVpcjhBn0MYHqiPQJ8FyiwUx0=; b=J08cebKlebfr9xTMZCzx8iEkY0vqALEiuE6Rxn1M352D/lCotanmDkbDnOqWgykXYXm/Nb mnWlstrVIKEY5uAWppct+51/eq8UhbvntwWeFANhYLyEw7vzZsY7iVWpgxlHsolfZ9NwjF bDzPOB/tKsKmEDUgwRmV0f2waFRwueA= X-MC-Unique: mnw-7be7Mi-zJ2zeD7NXPg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 13/33] migration: push Error **errp into loadvm_postcopy_handle_run() Date: Thu, 4 Feb 2021 17:18:47 +0000 Message-Id: <20210204171907.901471-14-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 447596383f..fa7883ae5e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1998,13 +1998,13 @@ static void loadvm_postcopy_handle_run_bh(void *opa= que) } =20 /* After all discards we can start running and asking for pages */ -static int loadvm_postcopy_handle_run(MigrationIncomingState *mis) +static int loadvm_postcopy_handle_run(MigrationIncomingState *mis, Error *= *errp) { PostcopyState ps =3D postcopy_state_get(); =20 trace_loadvm_postcopy_handle_run(); if (ps !=3D POSTCOPY_INCOMING_LISTENING) { - error_report("CMD_POSTCOPY_RUN in wrong postcopy state (%d)", ps); + error_setg(errp, "CMD_POSTCOPY_RUN in wrong postcopy state (%d)", = ps); return -1; } =20 @@ -2292,12 +2292,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_handle_listen(mis, errp); =20 case MIG_CMD_POSTCOPY_RUN: - ret =3D loadvm_postcopy_handle_run(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + return loadvm_postcopy_handle_run(mis, errp); =20 case MIG_CMD_POSTCOPY_RAM_DISCARD: ret =3D loadvm_postcopy_ram_handle_discard(mis, len); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462906; cv=none; d=zohomail.com; s=zohoarc; b=eaICceGPkEmv4TfqT87EBckhHHtqa74ShDwfLxi1wv3dL30zEB/8dR6D3uYFCJa5PVX6FZ8D+1cHX4KUOFwThVWcoMruM0boTI9v3AJRJEjcw/ZVEZjgE+Wdez60eyiybKumQSPrmAvGeOIteAOR0VeVfASyGbmu12reSPrNIRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462906; 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=/pkDdoDqzQ69U1IrrNOKMqEQ+eA28g+rl7dCHf+fRIc=; b=PcC/ktettd3BZhbQarxxouu1IFcq8J1qtxcjMSsW+6csfvJvmx7d/sk+uIED7P4E2u/HTvoLX5CFHA80tczN1tqt1fVOdxhFAbSwlyHDfEwpCmGXwT0vQby4EFvAeEEsbxAWllENDeiv7Apz3FMZt955IBnyuo69GhgmKMXSTA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462906393108.57138486573365; Thu, 4 Feb 2021 10:21:46 -0800 (PST) Received: from localhost ([::1]:34940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jGD-0001ZD-9H for importer@patchew.org; Thu, 04 Feb 2021 13:21:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIG-0007pl-Bn for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIE-0005Wz-EF for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-XlwWW5LSOui8uTShK7UdOQ-1; Thu, 04 Feb 2021 12:19:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F02BC1800D41; Thu, 4 Feb 2021 17:19:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id C899C60CFA; Thu, 4 Feb 2021 17:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459185; 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=/pkDdoDqzQ69U1IrrNOKMqEQ+eA28g+rl7dCHf+fRIc=; b=Bg7U7iLg/80Pt51af847rCFon1Rs8OVcbRH42GWMhE0Q22N/rBGFb6qavBo8JiMD6t+7PF fttsom3hHHj+DmII6JQklF9lE75wbbAm326Kp4k+9+3nbuYIu+KnzSpfcMx3Av4FPROCAe 2R2mv7wWkqTGhDQg+qW4fOSj45Ixbpk= X-MC-Unique: XlwWW5LSOui8uTShK7UdOQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 14/33] migration: push Error **errp into loadvm_postcopy_ram_handle_discard() Date: Thu, 4 Feb 2021 17:18:48 +0000 Message-Id: <20210204171907.901471-15-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index fa7883ae5e..2216c61c6f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1735,7 +1735,8 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis, * There can be 0..many of these messages, each encoding multiple pages. */ static int loadvm_postcopy_ram_handle_discard(MigrationIncomingState *mis, - uint16_t len) + uint16_t len, + Error **errp) { int tmp; char ramid[256]; @@ -1748,7 +1749,8 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, /* 1st discard */ tmp =3D postcopy_ram_prepare_discard(mis); if (tmp) { - return tmp; + error_setg(errp, "Failed to prepare for RAM discard: %d", tmp); + return -1; } break; =20 @@ -1757,8 +1759,9 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, break; =20 default: - error_report("CMD_POSTCOPY_RAM_DISCARD in wrong postcopy state (%d= )", - ps); + error_setg(errp, + "CMD_POSTCOPY_RAM_DISCARD in wrong postcopy state (%d)", + ps); return -1; } /* We're expecting a @@ -1767,29 +1770,29 @@ static int loadvm_postcopy_ram_handle_discard(Migra= tionIncomingState *mis, * then at least 1 16 byte chunk */ if (len < (1 + 1 + 1 + 1 + 2 * 8)) { - error_report("CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", len); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", l= en); return -1; } =20 tmp =3D qemu_get_byte(mis->from_src_file); if (tmp !=3D postcopy_ram_discard_version) { - error_report("CMD_POSTCOPY_RAM_DISCARD invalid version (%d)", tmp); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD invalid version (%d)", = tmp); return -1; } =20 if (!qemu_get_counted_string(mis->from_src_file, ramid)) { - error_report("CMD_POSTCOPY_RAM_DISCARD Failed to read RAMBlock ID"= ); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD Failed to read RAMBlock= ID"); return -1; } tmp =3D qemu_get_byte(mis->from_src_file); if (tmp !=3D 0) { - error_report("CMD_POSTCOPY_RAM_DISCARD missing nil (%d)", tmp); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD missing nil (%d)", tmp); return -1; } =20 len -=3D 3 + strlen(ramid); if (len % 16) { - error_report("CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", len); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", l= en); return -1; } trace_loadvm_postcopy_ram_handle_discard_header(ramid, len); @@ -1801,7 +1804,8 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, len -=3D 16; int ret =3D ram_discard_range(ramid, start_addr, block_length); if (ret) { - return ret; + error_setg(errp, "Failed to discard RAM range %s: %d", ramid, = ret); + return -1; } } trace_loadvm_postcopy_ram_handle_discard_end(); @@ -2295,12 +2299,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_handle_run(mis, errp); =20 case MIG_CMD_POSTCOPY_RAM_DISCARD: - ret =3D loadvm_postcopy_ram_handle_discard(mis, len); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + return loadvm_postcopy_ram_handle_discard(mis, len, errp); =20 case MIG_CMD_POSTCOPY_RESUME: ret =3D loadvm_postcopy_handle_resume(mis); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462432; cv=none; d=zohomail.com; s=zohoarc; b=XEgMBvJaOBNztdd9iE5RrVH3HyZe1YoMya/2TyPfsEnrbxNd+0B7aNhnBf6l5n/Mjz7JJS+oteZNEI/6DDA2Z040cqFe8dTICMROo24JliVrO7hBsNJ8c+O4tsaUj6LG8tArGpbVtYyMHWgcXqDgIC0+Q45HiNWBAsVzHV3dPAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462432; 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=5I0JoPIFAE4pIArB3WQSq5OJU/80mSf2HtxpzVX0jJY=; b=dloqsoVB9+lpXJ/7RAkjL/NIcgZufqAMTwXcZZ2nSofQ0ggmhJEYsi8GW+zR108p9xXOv60VMpRyrYV0w5FhoWAlwUhN6L2nd2MHNeTmNAoVuR/RIytz6tV2ICK9BKjti9BLswtWChqWyByFqOgfBtU2B5YrZElqhZbEn5Zk4uE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462432665823.2811708963393; Thu, 4 Feb 2021 10:13:52 -0800 (PST) Received: from localhost ([::1]:38994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j8Z-0006HH-Hb for importer@patchew.org; Thu, 04 Feb 2021 13:13:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIF-0007oT-Rp for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIE-0005Wo-4n for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-6-FrI1HanwPMWS5HF5FdeeXg-1; Thu, 04 Feb 2021 12:19:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68CE8835E23; Thu, 4 Feb 2021 17:19:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4430260DA1; Thu, 4 Feb 2021 17:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459185; 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=5I0JoPIFAE4pIArB3WQSq5OJU/80mSf2HtxpzVX0jJY=; b=KH2lURiMgaIxVK609J+1opInKYXtmgh03Je8z/4kCDN3k0RzQ1WoEUUR6Jexig0Nnb0b2g 2j7lLMP89q+ZFIu3tlOZso5ewsEfxuOfS5hzF0xChjx2BxZv4tMRmrotQ44nHIKAgvalnv TXyy2Y9KejJom1PzXZN65jJU2YwsbOo= X-MC-Unique: FrI1HanwPMWS5HF5FdeeXg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 15/33] migration: make loadvm_postcopy_handle_resume() void Date: Thu, 4 Feb 2021 17:18:49 +0000 Message-Id: <20210204171907.901471-16-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, 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 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 2216c61c6f..041175162a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2067,12 +2067,12 @@ static void migrate_send_rp_req_pages_pending(Migra= tionIncomingState *mis) } } =20 -static int loadvm_postcopy_handle_resume(MigrationIncomingState *mis) +static void loadvm_postcopy_handle_resume(MigrationIncomingState *mis) { if (mis->state !=3D MIGRATION_STATUS_POSTCOPY_RECOVER) { error_report("%s: illegal resume received", __func__); /* Don't fail the load, only for this. */ - return 0; + return; } =20 /* @@ -2113,8 +2113,6 @@ static int loadvm_postcopy_handle_resume(MigrationInc= omingState *mis) * migrate_send_rp_message_req_pages() is not thread safe, yet. */ qemu_sem_post(&mis->postcopy_pause_sem_fault); - - return 0; } =20 /** @@ -2302,12 +2300,8 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_ram_handle_discard(mis, len, errp); =20 case MIG_CMD_POSTCOPY_RESUME: - ret =3D loadvm_postcopy_handle_resume(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + loadvm_postcopy_handle_resume(mis); + return 0; =20 case MIG_CMD_RECV_BITMAP: ret =3D loadvm_handle_recv_bitmap(mis, len); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461593; cv=none; d=zohomail.com; s=zohoarc; b=UphZpLbKyrtQ4PUyRhF7uyvFhY4nqHjCfebUrtiFZ1Dcq4MuM0EryicTYmuM0deOIZaxFt/CzgXJz6r23AfkP6fz5eaNgpjjSC2Gnw25sCnD7EG6n0mmWGMY7OuZ8A+pketme+kZRhgATgdECRFZ18y/JsQvBsbP5WnoRnQUoG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461593; 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=6Wg9OUvxCd0rY5hWUJhNeKgvNvOFv+dDi/kNb8iMW/g=; b=BcYSjB1D53lU2UBJs/mdvCUNONqVguaD/YH42Lw1tbTlF7PdGw/gTh4LR7zOV/8FK3sjQIoMcK02zIH7Uw1TNuJU9oSifLXo7DYdwDZ8Gl3qGLoc1hT8rMEbxAFh8jjO8K6hSo7BL28472+7caxI5jhP49fbfhc64ZYbvjLPW7w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461593398259.27928821003616; Thu, 4 Feb 2021 09:59:53 -0800 (PST) Received: from localhost ([::1]:35022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7iv2-0000Ne-8W for importer@patchew.org; Thu, 04 Feb 2021 12:59:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIK-0007wi-VD for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIG-0005Xy-Ff for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:52 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-qsZC7Wc_PMuiGt-5--4eoQ-1; Thu, 04 Feb 2021 12:19:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3ECD107ACE6; Thu, 4 Feb 2021 17:19:43 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B328D60937; Thu, 4 Feb 2021 17:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459187; 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=6Wg9OUvxCd0rY5hWUJhNeKgvNvOFv+dDi/kNb8iMW/g=; b=IUvidsTBnep5IgAWf4Y9yMzkE5Bp7WapWnQrRVS9ONcb99jAllQX0WtoWopMI+MPObkJtC 8mtIstYSugoJ7Q0a7YhzIHwIizUEJWE7hQJtKYQIEyd0S2TFhwcIoG+oOekyqf4zjkRUCy i+lLQrEVJLQTu8i8YT67KrL01CMqGgg= X-MC-Unique: qsZC7Wc_PMuiGt-5--4eoQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 16/33] migration: push Error **errp into loadvm_handle_recv_bitmap() Date: Thu, 4 Feb 2021 17:18:50 +0000 Message-Id: <20210204171907.901471-17-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 041175162a..b41c812188 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2173,7 +2173,8 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis, Error **errp) * len (1 byte) + ramblock_name (<255 bytes) */ static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis, - uint16_t len) + uint16_t len, + Error **errp) { QEMUFile *file =3D mis->from_src_file; RAMBlock *rb; @@ -2182,24 +2183,26 @@ static int loadvm_handle_recv_bitmap(MigrationIncom= ingState *mis, =20 cnt =3D qemu_get_counted_string(file, block_name); if (!cnt) { - error_report("%s: failed to read block name", __func__); - return -EINVAL; + error_setg(errp, "%s: failed to read block name", __func__); + return -1; } =20 /* Validate before using the data */ if (qemu_file_get_error(file)) { - return qemu_file_get_error(file); + error_setg(errp, "migration stream has error: %d", + qemu_file_get_error(file)); + return -1; } =20 if (len !=3D cnt + 1) { - error_report("%s: invalid payload length (%d)", __func__, len); - return -EINVAL; + error_setg(errp, "%s: invalid payload length (%d)", __func__, len); + return -1; } =20 rb =3D qemu_ram_block_by_name(block_name); if (!rb) { - error_report("%s: block '%s' not found", __func__, block_name); - return -EINVAL; + error_setg(errp, "%s: block '%s' not found", __func__, block_name); + return -1; } =20 migrate_send_rp_recv_bitmap(mis, block_name); @@ -2304,12 +2307,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return 0; =20 case MIG_CMD_RECV_BITMAP: - ret =3D loadvm_handle_recv_bitmap(mis, len); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - return -1; - } - return ret; + return loadvm_handle_recv_bitmap(mis, len, errp); =20 case MIG_CMD_ENABLE_COLO: ret =3D loadvm_process_enable_colo(mis); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612461869; cv=none; d=zohomail.com; s=zohoarc; b=Qg3haExROc5jCIKu8DNmXuiKnxVdJ8jny79jmi6wrwLvtuqLZNBLJw4gNM4uHFDk7BnIJHJyFzEjR8inO19rkn8ZJwAJEcN64BOjS/fU4ChiETVcG6YFwQJd8lGZNG52Z3FcvbprSng/SprnoJ6ROdJc7UDXM1L76KuauMVrtWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612461869; 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=ZVnyVp/vXRoX3fMFu47nHwcn1eIO/EtcAZZzD8t+gEU=; b=O5HUjHjZuDD4tLkBlP6hELXRPGTwV0GmBDTAqy5iv9FwR0+mIKUg5PpwwgMC+u7m6WLzjFNm2jgFoYX4PrGeiKJiT0N7jvlM/2gVLcaMESC3lnZSamh1EgULeYKIyuhcWz07BiszdkYbkFy14sgHHZ5f8FwbZBTR+qBtnuoJd6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612461869887475.3464793525511; Thu, 4 Feb 2021 10:04:29 -0800 (PST) Received: from localhost ([::1]:43634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7izU-0004Hv-KT for importer@patchew.org; Thu, 04 Feb 2021 13:04:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIM-0007xI-V5 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIG-0005Y1-MD for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-R2JjpCv_NYOTFKFQ8BNXcQ-1; Thu, 04 Feb 2021 12:19:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F64B1936B60; Thu, 4 Feb 2021 17:19:45 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A2D460937; Thu, 4 Feb 2021 17:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459188; 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=ZVnyVp/vXRoX3fMFu47nHwcn1eIO/EtcAZZzD8t+gEU=; b=LZf1VV7s330SQclaAnKFWmyMi9xKDvJlRYUKOUJYinPhNm0eGuGgzr9Jdhrf23LXnvivbt EmrnBBNtBOd1fA0e2qUZyfZR+qm0Zf7JagAtHt1R6RVn0uXuaobl1+PbhXrX9CQtO4j87R QP7z9usDrXYgpHvYSWO8V4uBeQBAX4E= X-MC-Unique: R2JjpCv_NYOTFKFQ8BNXcQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 17/33] migration: push Error **errp into loadvm_process_enable_colo() Date: Thu, 4 Feb 2021 17:18:51 +0000 Message-Id: <20210204171907.901471-18-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/migration/colo.h | 2 +- migration/migration.c | 6 +++--- migration/savevm.c | 25 +++++++++++-------------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 768e1f04c3..1d38191360 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); void *colo_process_incoming_thread(void *opaque); diff --git a/migration/migration.c b/migration/migration.c index 287a18d269..b9cf56e61f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -397,11 +397,11 @@ 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) { if (ram_block_discard_disable(true)) { - error_report("COLO: cannot disable RAM discard"); - return -EBUSY; + error_setg(errp, "COLO: cannot disable RAM discard"); + return -1; } migration_colo_enabled =3D true; return 0; diff --git a/migration/savevm.c b/migration/savevm.c index b41c812188..c59e76b478 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2212,15 +2212,18 @@ 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(); + int ret; + if (migration_incoming_enable_colo(errp) < 0) { + return -1; + } =20 - if (!ret) { - ret =3D colo_init_ram_cache(); - if (ret) { - migration_incoming_disable_colo(); - } + ret =3D colo_init_ram_cache(); + if (ret < 0) { + error_setg(errp, "failed to init colo RAM cache: %d", ret); + migration_incoming_disable_colo(); } return ret; } @@ -2237,7 +2240,6 @@ static int loadvm_process_command(QEMUFile *f, Error = **errp) uint16_t cmd; uint16_t len; uint32_t tmp32; - int ret; =20 cmd =3D qemu_get_be16(f); len =3D qemu_get_be16(f); @@ -2310,12 +2312,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 -1; - } - return ret; + return loadvm_process_enable_colo(mis, errp); } =20 return 0; --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462639; cv=none; d=zohomail.com; s=zohoarc; b=R09sCo7/RD6nStnZE+nR+YbQBmybt6no6owd5NpZO02KqkTF3gH5fS4zmDQ96vAHga5kEsYKJSy+4Cygd0/zbcVphHBzynQ2kurWvp1hn8in8dOBxKIczbpKFqJj0bPhwyNpHg0IuvtvivFMVdJcIm7rRIVNUZ8OZRfvj0yNzTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462639; 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=M29iw9EwaSJdHA7JeLk49yI25blrZMRw6chRaT4FUkI=; b=kUS7xvAan4vwxgrZytNROIgUjC93VMSujYbVh3w+4ro8HAWS/wO8LkI3tIApKf/OQaF03Z1Oov17N9CxgtjUCEpYnp8j+HIwzee5J4MIL6qoCQZCQOfXwya5HHWhb0BGm0CyGXGuClrvWG5wxsDtXQEuwgYeDIuS97YoMPSpYpI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462639972507.44250089229; Thu, 4 Feb 2021 10:17:19 -0800 (PST) Received: from localhost ([::1]:47366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jBu-0001kx-Q2 for importer@patchew.org; Thu, 04 Feb 2021 13:17:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIO-0007xf-S3 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iII-0005YV-Qa for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-DLBzBDtzMMSEH49cohLM_A-1; Thu, 04 Feb 2021 12:19:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D25AA107ACC7; Thu, 4 Feb 2021 17:19:46 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAA9A60937; Thu, 4 Feb 2021 17:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459189; 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=M29iw9EwaSJdHA7JeLk49yI25blrZMRw6chRaT4FUkI=; b=EEZT9xIu5gIIhG5PYM/LeDz8kQkFEVH6j6Xs6NRhFKJbe9syk032ySySMZps/CR9MhQHEt eJBAVKV6Od4m4V3pLmxeZ+KwwBkbIiomwKfie5mOfUo+VcJ2WzkMvuxvB1YwvCwPfcgG7n 1tLKJlz6ItdHbNkA+MHdpMKveLBU6Dk= X-MC-Unique: DLBzBDtzMMSEH49cohLM_A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 18/33] migration: push Error **errp into colo_init_ram_cache() Date: Thu, 4 Feb 2021 17:18:52 +0000 Message-Id: <20210204171907.901471-19-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/ram.c | 11 ++++++----- migration/ram.h | 2 +- migration/savevm.c | 8 +++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index f6180e8f4f..0b8c5f3c86 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3028,7 +3028,7 @@ static void colo_init_ram_state(void) * memory of the secondary VM, it is need to hold the global lock * to call this helper. */ -int colo_init_ram_cache(void) +int colo_init_ram_cache(Error **errp) { RAMBlock *block; =20 @@ -3038,16 +3038,17 @@ int colo_init_ram_cache(void) NULL, 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_errno(errp, errno, + "%s: Can't alloc memory for COLO cache of= block %s," + "size 0x" RAM_ADDR_FMT, __func__, block->= idstr, + block->used_length); RAMBLOCK_FOREACH_NOT_IGNORED(block) { if (block->colo_cache) { qemu_anon_ram_free(block->colo_cache, block->used_= length); block->colo_cache =3D NULL; } } - return -errno; + return -1; } } } diff --git a/migration/ram.h b/migration/ram.h index 1cea36ba51..88b0b6636b 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -74,7 +74,7 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file, int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb); =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 c59e76b478..ace76e32f7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2215,17 +2215,15 @@ static int loadvm_handle_recv_bitmap(MigrationIncom= ingState *mis, static int loadvm_process_enable_colo(MigrationIncomingState *mis, Error **errp) { - int ret; if (migration_incoming_enable_colo(errp) < 0) { return -1; } =20 - ret =3D colo_init_ram_cache(); - if (ret < 0) { - error_setg(errp, "failed to init colo RAM cache: %d", ret); + if (colo_init_ram_cache(errp) < 0) { migration_incoming_disable_colo(); + return -1; } - return ret; + return 0; } =20 /* --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463053; cv=none; d=zohomail.com; s=zohoarc; b=jjJW/BT01zU8tHa/fXBXSb3AnKAhSDhQSdjxqQBXRzrjkAvIxOnMQA1p8cyzQCbhHQmVTQo3KPDWZPtKOw00z+NQeD0QylUuwrrkvl2q5QvH13aEGyU45PS23xWUL2HHw0cCRC+u+ASAdC26l3gZzpwoqOUdRwTM45KLSxaZixs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463053; 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=03rQyzYNbnbeQL60CxRXjxb69PwBp7A6niFqMdrWlDk=; b=NY+T8w4gkaQtp87p+3NWKJWMhVZdKozI2X/bcGAa50ffwzG1XNhUSEOwi9BaJISVTnpcBLar49KX1xS6mF6tmADCAW1hon613c5xPnNw9Wsp7nHlKv5ZVTBtXhPZ6bkPIwlqgA5Sm0mp6gH6laoNXCuFEx1Eu7xIcWfBTzC8Tlo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463053961292.5138832926475; Thu, 4 Feb 2021 10:24:13 -0800 (PST) Received: from localhost ([::1]:43432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jIa-0006AM-QT for importer@patchew.org; Thu, 04 Feb 2021 13:24:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIQ-0007yF-UO for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60191) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIJ-0005a1-R8 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506-2lwIi4wzOGKw-pk_VMtciw-1; Thu, 04 Feb 2021 12:19:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54C5F835E33; Thu, 4 Feb 2021 17:19:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2890260CFA; Thu, 4 Feb 2021 17:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459191; 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=03rQyzYNbnbeQL60CxRXjxb69PwBp7A6niFqMdrWlDk=; b=H7bKFbfA57gKmIGS3yPL6IQqZ4IeBjU25oEc0ezBOL9STB64Cp245yWDPaAo44qPD8CXgS xlngUEN7tTGPHX5C451RmEkYjdBOrxKdp2/CNXkyxoA9/6sdAbyTmOpEePfWAw//iFnb+g gCCXaQGNDGruzZB912hhoKYXoCNumJA= X-MC-Unique: 2lwIi4wzOGKw-pk_VMtciw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 19/33] migration: push Error **errp into check_section_footer() Date: Thu, 4 Feb 2021 17:18:53 +0000 Message-Id: <20210204171907.901471-20-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/savevm.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index ace76e32f7..289a3d55bb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2320,9 +2320,9 @@ static int loadvm_process_command(QEMUFile *f, Error = **errp) * Read a footer off the wire and check that it matches the expected secti= on * * Returns: true if the footer was good - * false if there is a problem (and calls error_report to say why) + * false if there is a problem */ -static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) +static bool check_section_footer(QEMUFile *f, SaveStateEntry *se, Error **= errp) { int ret; uint8_t read_mark; @@ -2337,21 +2337,21 @@ static bool check_section_footer(QEMUFile *f, SaveS= tateEntry *se) =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Read section footer failed: %d", - __func__, ret); + error_setg(errp, "read section footer failed: %d", + ret); return false; } =20 if (read_mark !=3D QEMU_VM_SECTION_FOOTER) { - error_report("Missing section footer for %s", se->idstr); + error_setg(errp, "Missing section footer for %s", se->idstr); return false; } =20 read_section_id =3D qemu_get_be32(f); if (read_section_id !=3D se->load_section_id) { - error_report("Mismatched section id in footer for %s -" - " read 0x%x expected 0x%x", - se->idstr, read_section_id, se->load_section_id); + error_setg(errp, "Mismatched section id in footer for %s -" + " read 0x%x expected 0x%x", + se->idstr, read_section_id, se->load_section_id); return false; } =20 @@ -2418,8 +2418,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis, " device '%s'", instance_id, idstr); return -1; } - if (!check_section_footer(f, se)) { - error_setg(errp, "failed check for device state section footer"); + if (!check_section_footer(f, se, errp)) { return -1; } =20 @@ -2460,8 +2459,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIn= comingState *mis, section_id, se->idstr); return -1; } - if (!check_section_footer(f, se)) { - error_setg(errp, "failed check for device state section footer"); + if (!check_section_footer(f, se, errp)) { return -1; } =20 --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462768; cv=none; d=zohomail.com; s=zohoarc; b=R3TPr4CxOCFOVcyNZml7iGyWuJYN4iBqLC6YuJqQ3TjtkMzSm9j93rMsiBA96GJDMUTAKcrwqmsrAwWPeFCYjDaWP+MhqORiqJm1Gu94Bi9ImcTOkc8L4omH55u0/nicerHSannVqRVj7g0bwReBiobhB6QqYZ5zulw46g6oqEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462768; 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=VCPycQ3R4gHNei3Z8btmXK5WJxMPUe01jew7dJhsMI0=; b=fuB8HtQ4uSSd9fxVurEzVL4j6bzFw9RitkrcKb7t2V/+GziOsNFoKdZKueKCxVFYVH8o3ZjRnFEYSjVgWqEv/4Mv5HlKmFre/zB3RYCkA4QPS0wT+vF1XOb6NGsLXwHwJ9sSc70RW7u/W9mByfzCzhkcvXOBCFYd5e9ZiLAcx9Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 161246276839974.49139737731207; Thu, 4 Feb 2021 10:19:28 -0800 (PST) Received: from localhost ([::1]:55670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jDy-0005rK-Ah for importer@patchew.org; Thu, 04 Feb 2021 13:19:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIT-0007yc-Nv for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIM-0005fA-Lh for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-f-OPw1YQNMK1UuoTb0JVbw-1; Thu, 04 Feb 2021 12:19:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3542835E26; Thu, 4 Feb 2021 17:19:49 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id A031460CFA; Thu, 4 Feb 2021 17:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459192; 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=VCPycQ3R4gHNei3Z8btmXK5WJxMPUe01jew7dJhsMI0=; b=LHjGBOioqJU1cBKC6wTD7+FqVrzLR6zJtuA7kJBL3F/EIN6LMYxrmOToP69WcT1ngwO9i7 UUbtNWXfdz6ygPowgeu8mIifb7dQ5lJlsTp8MB7S7DSdJedNUIJy1+gKY7w8iQUGL8DJTE fGN3Vkt2uv4JQC9Q3bz3u1gzmIA8xWM= X-MC-Unique: f-OPw1YQNMK1UuoTb0JVbw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 20/33] migration: push Error **errp into global_state_store() Date: Thu, 4 Feb 2021 17:18:54 +0000 Message-Id: <20210204171907.901471-21-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/migration/global_state.h | 2 +- migration/global_state.c | 6 +++--- migration/migration.c | 8 ++++++-- migration/savevm.c | 5 ++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/migration/global_state.h b/include/migration/global_st= ate.h index 945eb35d5b..eeade88ef8 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -16,7 +16,7 @@ #include "qapi/qapi-types-run-state.h" =20 void register_global_state(void); -int global_state_store(void); +int global_state_store(Error **errp); void global_state_store_running(void); bool global_state_received(void); RunState global_state_get_runstate(void); diff --git a/migration/global_state.c b/migration/global_state.c index a33947ca32..36fda38aad 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -29,13 +29,13 @@ typedef struct { =20 static GlobalState global_state; =20 -int global_state_store(void) +int global_state_store(Error **errp) { if (!runstate_store((char *)global_state.runstate, sizeof(global_state.runstate))) { - error_report("runstate name too big: %s", global_state.runstate); + error_setg(errp, "runstate name too big: %s", global_state.runstat= e); trace_migrate_state_too_big(); - return -EINVAL; + return -1; } return 0; } diff --git a/migration/migration.c b/migration/migration.c index b9cf56e61f..395a1b10f5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2811,6 +2811,7 @@ static int postcopy_start(MigrationState *ms) int64_t bandwidth =3D migrate_max_postcopy_bandwidth(); bool restart_block =3D false; int cur_state =3D MIGRATION_STATUS_ACTIVE; + Error *local_err =3D NULL; if (!migrate_pause_before_switchover()) { migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_POSTCOPY_ACTIVE); @@ -2821,9 +2822,10 @@ static int postcopy_start(MigrationState *ms) trace_postcopy_start_set_run(); =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); - global_state_store(); + global_state_store(&local_err); ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret < 0) { + error_report_err(local_err); goto fail; } =20 @@ -3030,11 +3032,12 @@ static void migration_completion(MigrationState *s) int current_active_state =3D s->state; =20 if (s->state =3D=3D MIGRATION_STATUS_ACTIVE) { + Error *local_err =3D NULL; qemu_mutex_lock_iothread(); s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_was_running =3D runstate_is_running(); - ret =3D global_state_store(); + ret =3D global_state_store(&local_err); =20 if (!ret) { bool inactivate =3D !migrate_colo_enabled(); @@ -3055,6 +3058,7 @@ static void migration_completion(MigrationState *s) qemu_mutex_unlock_iothread(); =20 if (ret < 0) { + error_report_err(local_err); goto fail; } } else if (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE) { diff --git a/migration/savevm.c b/migration/savevm.c index 289a3d55bb..c18b7e6033 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2828,9 +2828,8 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, =20 saved_vm_running =3D runstate_is_running(); =20 - ret =3D global_state_store(); - if (ret) { - error_setg(errp, "Error saving global state"); + ret =3D global_state_store(errp); + if (ret < 0) { return false; } vm_stop(RUN_STATE_SAVE_VM); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462903; cv=none; d=zohomail.com; s=zohoarc; b=JGav5e9ADd8GfzIetIlFbDrgr17ReaFy+/VG48Qg0rIqg+69nAhpdoqZ8pNg3q76U7tLSOwh25j91ycg2DuQCDV7/pHQh008bxNiQcl9jCv9sqIROpqPmwduUuL7mjWDfQn/7fyJbMvSnuzACFKKPA/6C04WI1KmrHI/i/MLRZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462903; 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=P+dFkQvnpIVQG/XnH90lIcEW7Ht35GJJEArZQe3Yscc=; b=IwNNKr3e7mVViZCZqQ4c+e4PJQApz7J9GINoIyzDvnN748RCvtN+ojaHSf4+p/j8GsZfUZJTS3mz2UhPdx7Y67pYj62c4GxTmt0nkPtGzcdPinPe+iaQDY+qttZ6sI/kYmpWecWnZEFOrqphZyFkMaUMsweUVXG/xDSqC8w2egs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462903413418.9974189420294; Thu, 4 Feb 2021 10:21:43 -0800 (PST) Received: from localhost ([::1]:34660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jGA-0001QW-9r for importer@patchew.org; Thu, 04 Feb 2021 13:21:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIR-0007yO-0L for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIM-0005fU-N1 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:19:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-U_hDiglQP0mhrFvF5uE9mA-1; Thu, 04 Feb 2021 12:19:52 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D076801981; Thu, 4 Feb 2021 17:19:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 198BA60937; Thu, 4 Feb 2021 17:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459193; 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=P+dFkQvnpIVQG/XnH90lIcEW7Ht35GJJEArZQe3Yscc=; b=ioSbs6pAxK6uxMm1olN68XknsE4TGIxhM/9EnCDf/2iRYgqJxU9qy/kKgRA0Aj9sgNPizY EO0aKp4bFekNTeApcrHJ2j39w3JNnzFGOw07TEnDCafMf5ZEXdqth20ATl4MO0VE1nB36y 1lGFOOvWDCgsZbvRRaaFDYKrPsnVv8I= X-MC-Unique: U_hDiglQP0mhrFvF5uE9mA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 21/33] migration: remove error reporting from qemu_fopen_bdrv() callers Date: Thu, 4 Feb 2021 17:18:55 +0000 Message-Id: <20210204171907.901471-22-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This method cannot fail since it merely allocates a single struct, so the only possible failure (ENOMEM) will cause an abort() already. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index c18b7e6033..6a7b930b1c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2861,10 +2861,7 @@ bool save_snapshot(const char *name, bool overwrite,= const char *vmstate, =20 /* save the VM state */ f =3D qemu_fopen_bdrv(bs, 1); - if (!f) { - error_setg(errp, "Could not open VM state file"); - goto the_end; - } + ret =3D qemu_savevm_state(f, errp); vm_state_size =3D qemu_ftell(f); ret2 =3D qemu_fclose(f); @@ -3041,10 +3038,6 @@ bool load_snapshot(const char *name, const char *vms= tate, =20 /* restore the VM state */ f =3D qemu_fopen_bdrv(bs_vm_state, 0); - if (!f) { - error_setg(errp, "Could not open VM state file"); - goto err_drain; - } =20 qemu_system_reset(SHUTDOWN_CAUSE_NONE); mis->from_src_file =3D f; --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462290; cv=none; d=zohomail.com; s=zohoarc; b=ctQS2znp9TaJ/l9hpN5GJD86MKsbsqIp3SZMCaAlic5NE6px7JwuEx6sByG7bgLv9W1vgvUqlsWIenuCREDtsSyGg6x0hOVFuPGQFm6zQ6SzVksroohXL2JiIH8HIGUlZTa3MNJ6LZ3S1kxxy6qALe0wJPIso+q15DyIJMYyraQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462290; 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=8WYJ3HZdayK/AJ9gA6TonVUP3nIEkbEYBNgFqG7V72k=; b=JbMFDxcXLiAffXJQl/hKIB0r0KK178Dh3/S+Mza3u3XRm2tEpTJxCM7cKxEM9OPDkhCY3h4kY1pftzU/dPrh3iDQa0ifJVlN3Ori/ZshJDjUgG5ALL5LTj6BN+/2IYTbnWZDIBUSEOSNsBOmXn8TPUhEv0cqJ7a19crdDRpaIxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462290061984.4763012229153; Thu, 4 Feb 2021 10:11:30 -0800 (PST) Received: from localhost ([::1]:60970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j6D-0003bE-1U for importer@patchew.org; Thu, 04 Feb 2021 13:11:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIb-00080Y-1A for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIO-0005gE-Ky for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-CTirUH6HNjCOpGJLrtDHbA-1; Thu, 04 Feb 2021 12:19:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADF4B100C660; Thu, 4 Feb 2021 17:19:52 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 881CD60CFA; Thu, 4 Feb 2021 17:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459195; 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=8WYJ3HZdayK/AJ9gA6TonVUP3nIEkbEYBNgFqG7V72k=; b=NoP3HqukbAPzIn48jnqKCskiKmSDKgWSLgPevdijJATcok1KwEZ66fLW5K1E6L/epgT+6P 8mLKaJrWqB8xB3MPIFEIVA7EIL74ngemHuZdpilAagr6xgC/0Xx1AN2B2jyu/IXFMBEad4 xq3t9hVreNjlXv4AjEjQ4ivg+OAmcWU= X-MC-Unique: CTirUH6HNjCOpGJLrtDHbA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 22/33] migration: push Error **errp into qemu_savevm_state_iterate() Date: Thu, 4 Feb 2021 17:18:56 +0000 Message-Id: <20210204171907.901471-23-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 8 +++++++- migration/savevm.c | 47 ++++++++++++++++++++++++++----------------- migration/savevm.h | 2 +- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 395a1b10f5..a85d101ad8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3393,6 +3393,8 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) pend_pre, pend_compat, pend_post); =20 if (pending_size && pending_size >=3D s->threshold_size) { + int ret; + Error *local_err =3D NULL; /* Still a significant amount to transfer */ if (!in_postcopy && pend_pre <=3D s->threshold_size && qatomic_read(&s->start_postcopy)) { @@ -3402,7 +3404,11 @@ static MigIterateState migration_iteration_run(Migra= tionState *s) return MIG_ITERATE_SKIP; } /* Just another iteration step */ - qemu_savevm_state_iterate(s->to_dst_file, in_postcopy); + ret =3D qemu_savevm_state_iterate(s->to_dst_file, in_postcopy, + &local_err); + if (ret < 0) { + error_report_err(local_err); + } } else { trace_migration_thread_low_pending(pending_size); migration_completion(s); diff --git a/migration/savevm.c b/migration/savevm.c index 6a7b930b1c..23e4d5a1a2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1220,8 +1220,9 @@ int qemu_savevm_state_resume_prepare(MigrationState *= s) * negative: there was one error, and we have -errno. * 0 : We haven't finished, caller have to go again * 1 : We have finished, we can go to complete phase + * -1 : error reported, go to cleanup phase */ -int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy) +int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy, Error **errp) { SaveStateEntry *se; int ret =3D 1; @@ -1261,11 +1262,13 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool pos= tcopy) save_section_footer(f, se); =20 if (ret < 0) { - error_report("failed to save SaveStateEntry with id(name): %d(= %s)", - se->section_id, se->idstr); + error_setg(errp, + "failed to save SaveStateEntry with id(name): %d(%s= )", + se->section_id, se->idstr); qemu_file_set_error(f, ret); + return -1; } - if (ret <=3D 0) { + if (ret =3D=3D 0) { /* Do not proceed to the next vmstate before this one reported completion of the current stage. This serializes the migrat= ion and reduces the probability that a faster changing state is @@ -1517,7 +1520,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **err= p) { int ret; MigrationState *ms =3D migrate_get_current(); - MigrationStatus status; =20 if (migration_is_running(ms->state)) { error_setg(errp, QERR_MIGRATION_ACTIVE); @@ -1538,34 +1540,43 @@ static int qemu_savevm_state(QEMUFile *f, Error **e= rrp) qemu_savevm_state_setup(f); qemu_mutex_lock_iothread(); =20 - while (qemu_file_get_error(f) =3D=3D 0) { - if (qemu_savevm_state_iterate(f, false) > 0) { + while (1) { + ret =3D qemu_savevm_state_iterate(f, false, errp); + if (ret < 0) { + goto fail; + } + if (ret > 0) { break; } + ret =3D qemu_file_get_error(f); + if (ret !=3D 0) { + error_setg_errno(errp, -ret, "Error while writing VM state"); + goto fail; + } } =20 + qemu_savevm_state_complete_precopy(f, false, false); ret =3D qemu_file_get_error(f); - if (ret =3D=3D 0) { - qemu_savevm_state_complete_precopy(f, false, false); - ret =3D qemu_file_get_error(f); - } - qemu_savevm_state_cleanup(); if (ret !=3D 0) { error_setg_errno(errp, -ret, "Error while writing VM state"); + goto fail; } =20 - if (ret !=3D 0) { - status =3D MIGRATION_STATUS_FAILED; - } else { - status =3D MIGRATION_STATUS_COMPLETED; - } - migrate_set_state(&ms->state, MIGRATION_STATUS_SETUP, status); + qemu_savevm_state_cleanup(); + migrate_set_state(&ms->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_COMPLETED); =20 /* f is outer parameter, it should not stay in global migration state = after * this function finished */ ms->to_dst_file =3D NULL; =20 return ret; + + fail: + qemu_savevm_state_cleanup(); + migrate_set_state(&ms->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_FAILED); + return -1; } =20 void qemu_savevm_live_state(QEMUFile *f) diff --git a/migration/savevm.h b/migration/savevm.h index 1cec83c729..e187640806 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -34,7 +34,7 @@ void qemu_savevm_state_setup(QEMUFile *f); bool qemu_savevm_state_guest_unplug_pending(void); int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_state_header(QEMUFile *f); -int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); +int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy, Error **errp); void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463043; cv=none; d=zohomail.com; s=zohoarc; b=Tp7L+NEUG/DEF8P5FyeLkx1eTqpTfz7lVzJMHEBANXYHHt3peqGQCKAqkkXW4yHIFBx4dojc0fgC/1kWZYaA91OCm54a07FiSP9fdruso38l1F7jXID1OipvrMjpyYngzU3UyXbnLvycPrtVXP9JGKO0vRQ3t5dS4nVMevopm74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463043; 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=9PAMIFGXEZffGzCZZ4pKKkrTnrT0sfVqxuCXEAkrhyw=; b=RS1zTPEXRr22gMiZUXrSA++vf/bQvLTgRN9mFcz02Y7KXDS5VDQDxLfUU0RsvxxMuJeKsQsQ530D+YwUMfiPXx8zeKfQyk2t68J/3IPlQ/VHKRRzszpFeRp1z9zzgI/To1Ga7SZmTaSGA8ZsxtB6fFXZ9s4Ayk45Kvrax1qIDms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463043183106.99949888833225; Thu, 4 Feb 2021 10:24:03 -0800 (PST) Received: from localhost ([::1]:43082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jIP-00061N-Ha for importer@patchew.org; Thu, 04 Feb 2021 13:24:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIY-0007zw-No for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIP-0005gW-RU for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-Om1uMpSCOsmYpvsWzN0oQg-1; Thu, 04 Feb 2021 12:19:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D2B8107ACE3; Thu, 4 Feb 2021 17:19:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 074E650E2F; Thu, 4 Feb 2021 17:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459196; 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=9PAMIFGXEZffGzCZZ4pKKkrTnrT0sfVqxuCXEAkrhyw=; b=Ir9oBIhcOkKf1fF5sVDmIBY9Be5/IuDe3FX52o0omJwp66P2hIMm6gmuGfE64hHlrwZoFS 8YvsMKRxJx9fUKxf1YproUtUJF9hEujuYWpTVmKBa/Dl+i7p5GsDSBJ6zsn7+iIk1fLRCb vdwjpMvJmcrZsgDZhu4t28X4ERoMo2M= X-MC-Unique: Om1uMpSCOsmYpvsWzN0oQg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 23/33] migration: simplify some error reporting in save_snapshot() Date: Thu, 4 Feb 2021 17:18:57 +0000 Message-Id: <20210204171907.901471-24-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Re-arrange code to remove need for a separate 'ret2' variable, accepting the duplicated qemu_fclose() call as resulting in clearer code to follow the flow of. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 23e4d5a1a2..fdf8b6edfb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2788,7 +2788,7 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, { BlockDriverState *bs; QEMUSnapshotInfo sn1, *sn =3D &sn1; - int ret =3D -1, ret2; + int ret =3D -1; QEMUFile *f; int saved_vm_running; uint64_t vm_state_size; @@ -2818,11 +2818,11 @@ bool save_snapshot(const char *name, bool overwrite= , const char *vmstate, return false; } } else { - ret2 =3D bdrv_all_has_snapshot(name, has_devices, devices, err= p); - if (ret2 < 0) { + ret =3D bdrv_all_has_snapshot(name, has_devices, devices, errp= ); + if (ret < 0) { return false; } - if (ret2 =3D=3D 1) { + if (ret =3D=3D 1) { error_setg(errp, "Snapshot '%s' already exists in one or more de= vices", name); @@ -2874,13 +2874,14 @@ bool save_snapshot(const char *name, bool overwrite= , const char *vmstate, f =3D qemu_fopen_bdrv(bs, 1); =20 ret =3D qemu_savevm_state(f, errp); - vm_state_size =3D qemu_ftell(f); - ret2 =3D qemu_fclose(f); if (ret < 0) { + qemu_fclose(f); goto the_end; } - if (ret2 < 0) { - ret =3D ret2; + vm_state_size =3D qemu_ftell(f); + ret =3D qemu_fclose(f); + if (ret < 0) { + error_setg_errno(errp, -ret, "failed to close vmstate file"); goto the_end; } =20 --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462930; cv=none; d=zohomail.com; s=zohoarc; b=jE+LXW3PYL8m1vL7vc/CYba17ZBZO5LNcuRYNwQqxGGdD4hEa1D5kjsjBvzGCL4uTa3quLPGHov4+IXhGbbuJ/OSXFDrVL+iOauCkxVzRfUldfX2ihPqMaIZ8kdHsrJmFs+PQpB44ibYuTgO1d9jm53gHuaNzqRtQA3g6v4B3Qc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462930; 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=3SCajtC8S663UCFTcL7hVo0uTYE9AJdkoFj1Wbl3yA4=; b=HOCV9fT3d04605o3YnVzY4UpceNhRaCtMXOZZoNLhA1t9jUaCqaM++AiGciTZHVRD2n0vXO0qSwZ3XVRyichDDBaC5eSHmG36MQNBKNwwrh+daulCQycPrO7K9EcHK/tHYLRxQjpUkJ9l3KMBfAEmC1bEQdohOiMZ11vAd7KhjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462930249674.3399616626366; Thu, 4 Feb 2021 10:22:10 -0800 (PST) Received: from localhost ([::1]:35808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jGb-0001zZ-4O for importer@patchew.org; Thu, 04 Feb 2021 13:22:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iId-000827-E2 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIT-0005h6-9e for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246--SaQnaJNMpCKOpy_j1O2mg-1; Thu, 04 Feb 2021 12:19:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A5F1835E39; Thu, 4 Feb 2021 17:19:55 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 774EF60937; Thu, 4 Feb 2021 17:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459199; 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=3SCajtC8S663UCFTcL7hVo0uTYE9AJdkoFj1Wbl3yA4=; b=Sy4oYAEbFSEuLhy5uCkw4j7cai8Arh1tJy/2ZMpOWl5wPMW8PN8pvn3u93xykVknkdmIm4 x0VO+pJoWMppqlaEKLySHULdR3d6tk+I/LTJbE8JFhQngg5Dz0NGGHrhVvfyWGStzfnaKj DeO1XDgTHx+iME3N7m/oBKdEAW/14dc= X-MC-Unique: -SaQnaJNMpCKOpy_j1O2mg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 24/33] migration: push Error **errp into qemu_savevm_state_setup() Date: Thu, 4 Feb 2021 17:18:58 +0000 Message-Id: <20210204171907.901471-25-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. In doing this the callers now actually honour the failures that can be reported instead of carrying on as if everything was normal. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 9 ++++++++- migration/savevm.c | 18 ++++++++++++------ migration/savevm.h | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a85d101ad8..e814d47796 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3522,6 +3522,7 @@ static void *migration_thread(void *opaque) int64_t setup_start =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); MigThrError thr_error; bool urgent =3D false; + Error *local_err =3D NULL; =20 rcu_register_thread(); =20 @@ -3556,7 +3557,12 @@ static void *migration_thread(void *opaque) qemu_savevm_send_colo_enable(s->to_dst_file); } =20 - qemu_savevm_state_setup(s->to_dst_file); + if (qemu_savevm_state_setup(s->to_dst_file, &local_err) < 0) { + error_report_err(local_err); + migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_FAILED); + goto out; + } =20 if (qemu_savevm_state_guest_unplug_pending()) { migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, @@ -3609,6 +3615,7 @@ static void *migration_thread(void *opaque) =20 trace_migration_thread_after_loop(); migration_iteration_finish(s); + out: object_unref(OBJECT(s)); rcu_unregister_thread(); return NULL; diff --git a/migration/savevm.c b/migration/savevm.c index fdf8b6edfb..318ba547bc 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1159,10 +1159,9 @@ bool qemu_savevm_state_guest_unplug_pending(void) return false; } =20 -void qemu_savevm_state_setup(QEMUFile *f) +int qemu_savevm_state_setup(QEMUFile *f, Error **errp) { SaveStateEntry *se; - Error *local_err =3D NULL; int ret; =20 trace_savevm_state_setup(); @@ -1180,14 +1179,18 @@ void qemu_savevm_state_setup(QEMUFile *f) ret =3D se->ops->save_setup(f, se->opaque); save_section_footer(f, se); if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to setup device state handler"); qemu_file_set_error(f, ret); - break; + return -1; } } =20 - if (precopy_notify(PRECOPY_NOTIFY_SETUP, &local_err)) { - error_report_err(local_err); + if (precopy_notify(PRECOPY_NOTIFY_SETUP, errp)) { + return -1; } + + return 0; } =20 int qemu_savevm_state_resume_prepare(MigrationState *s) @@ -1537,8 +1540,11 @@ static int qemu_savevm_state(QEMUFile *f, Error **er= rp) =20 qemu_mutex_unlock_iothread(); qemu_savevm_state_header(f); - qemu_savevm_state_setup(f); + ret =3D qemu_savevm_state_setup(f, errp); qemu_mutex_lock_iothread(); + if (ret < 0) { + goto fail; + } =20 while (1) { ret =3D qemu_savevm_state_iterate(f, false, errp); diff --git a/migration/savevm.h b/migration/savevm.h index e187640806..b7133655f2 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -30,7 +30,7 @@ #define QEMU_VM_SECTION_FOOTER 0x7e =20 bool qemu_savevm_state_blocked(Error **errp); -void qemu_savevm_state_setup(QEMUFile *f); +int qemu_savevm_state_setup(QEMUFile *f, Error **errp); bool qemu_savevm_state_guest_unplug_pending(void); int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_state_header(QEMUFile *f); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462059; cv=none; d=zohomail.com; s=zohoarc; b=B37WCbe4xR5MTCui60Qekzkk3ubG6cPvPb5NIgDkReKvcHgB3x2IyFGpO/4pcS7Tj0O7SbtNEU9U2FXDD56sV8GoIqn5qrkk5/g699+qOMlhZYkDUmbS/KBTUKwVFxWY2iIUdKGSB6tDQxOHEl8mGmR8EzZQWo73RYfR55gtQVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462059; 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=Mr8SLq8/bJm/LCm6RE96sfTtiFdrBDO8Fkq699jo0Tk=; b=E5Bp5UA2D2hKgIvVtZoVbQEu14pid+YZaaHZJmB0OO+1+z7vHpxaxK4cmPTpG/yCau8UeRou8e15nsta3QXTSaHsfRRj7UM0PLtfGxgiRE47N39lcfGTgg3vRv0Se1s1kobuBZKBa2nblPlZSEeADUucOGlWWEyqe8FxrEMue8Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462059686890.7797926499179; Thu, 4 Feb 2021 10:07:39 -0800 (PST) Received: from localhost ([::1]:52384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j2Y-0008Fk-KB for importer@patchew.org; Thu, 04 Feb 2021 13:07:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIZ-00080G-QY for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIU-0005hl-B9 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-JHXvTznyMduGG1_UN94bbQ-1; Thu, 04 Feb 2021 12:19:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15DFA100C679; Thu, 4 Feb 2021 17:19:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4CC260DCC; Thu, 4 Feb 2021 17:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459201; 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=Mr8SLq8/bJm/LCm6RE96sfTtiFdrBDO8Fkq699jo0Tk=; b=Y1xPw+MH4fMbCD1KLmkzSH7sHKWLsU8RrAxMUzI0a0Mr4d65CluQhrxUIha6+NJ9cMdfCf 28JE62v9Jam8jeMm/sCtvB1PzrwreQG9/WfPozQXf6KVziAKGF+88D01Cx4ZLTZ13HxMaL 7znX/RO4lCV9Kb06/KzcGb7SkT02ZUw= X-MC-Unique: JHXvTznyMduGG1_UN94bbQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 25/33] migration: push Error **errp into qemu_savevm_state_complete_precopy() Date: Thu, 4 Feb 2021 17:18:59 +0000 Message-Id: <20210204171907.901471-26-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 318ba547bc..3b46fbba32 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1329,7 +1329,8 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) } =20 static -int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postc= opy) +int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postc= opy, + Error **errp) { SaveStateEntry *se; int ret; @@ -1355,6 +1356,8 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUF= ile *f, bool in_postcopy) trace_savevm_section_end(se->idstr, se->section_id, ret); save_section_footer(f, se); if (ret < 0) { + error_setg_errno(errp, -ret, + "failed to complete precopy device state save= "); qemu_file_set_error(f, ret); return -1; } @@ -1450,9 +1453,10 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, = bool iterable_only, cpu_synchronize_all_states(); =20 if (!in_postcopy || iterable_only) { - ret =3D qemu_savevm_state_complete_precopy_iterable(f, in_postcopy= ); - if (ret) { - return ret; + if (qemu_savevm_state_complete_precopy_iterable(f, in_postcopy, + &local_err) < 0) { + error_report_err(local_err); + return -1; } } =20 --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463349; cv=none; d=zohomail.com; s=zohoarc; b=EovVs1+zPboae1w1uIfjVeN4B3pJG+BEvrJUW40H8Ju3dO3TFIjAmbNZC6ca0B9l88AyDEFXq1mcp/1dc75NbkPOj1Gt5defphzDxppiwGFpNkhvPo2erGHuHteryNTn4HcZf/p+P86niJPj7eF1EeNW7CUo4RFpb1Aa/5CrAqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463349; 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=KkQzQEOZtsNbJ5a3pC1X3wjE7y7HyONi/y17NLqswl8=; b=NSf6DGucrfQA3nycwePJVZiTgn41kAXJbKqUf5dbqFVjgDd6au2MmPpDY3R2e8W4O3HKXTsde0BwklS85kOoJmADyyxKsGZEmrggc9GdN2lDX83b2WNC5ydQSm/9VaVGgKbKegpwJvZHuF8BEOgkMQJUtQdo5wQ7cEoP+DaSzgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463349650826.1850905940411; Thu, 4 Feb 2021 10:29:09 -0800 (PST) Received: from localhost ([::1]:60480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jNM-0004pF-Jc for importer@patchew.org; Thu, 04 Feb 2021 13:29:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIl-00086b-8y for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIa-0005jP-Ph for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-509-2wwHEEK8MluV0KvNdo3Asg-1; Thu, 04 Feb 2021 12:19:59 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9380E801968; Thu, 4 Feb 2021 17:19:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 609D160CFA; Thu, 4 Feb 2021 17:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459207; 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=KkQzQEOZtsNbJ5a3pC1X3wjE7y7HyONi/y17NLqswl8=; b=cCJmNhG60xz1Nnqq446ry1h5Zv5NZeXt93/jaMGMZoJUHox0KHwshvfF7cvFxwI0mmvOZ5 GJrkjkBjtP1dhI7J4CHFuotQFq+gSdJTeooFda7duRPG8O9Fg/pzZGk7OJieGCxaFwMxgQ 7RSbpr+F62hDOR5zaD7T9Aw+BwG4lBI= X-MC-Unique: 2wwHEEK8MluV0KvNdo3Asg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 26/33] migration: push Error **errp into qemu_savevm_state_complete_precopy_non_iterable() Date: Thu, 4 Feb 2021 17:19:00 +0000 Message-Id: <20210204171907.901471-27-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/savevm.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 3b46fbba32..95e228a646 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1369,7 +1369,8 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUF= ile *f, bool in_postcopy, static int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, bool in_postcopy, - bool inactivate_disks) + bool inactivate_disks, + Error **errp) { g_autoptr(JSONWriter) vmdesc =3D NULL; int vmdesc_len; @@ -1398,9 +1399,11 @@ int qemu_savevm_state_complete_precopy_non_iterable(= QEMUFile *f, =20 save_section_header(f, se, QEMU_VM_SECTION_FULL); ret =3D vmstate_save(f, se, vmdesc); - if (ret) { + if (ret < 0) { + error_setg_errno(errp, -ret, + "failed to save device state '%s'", se->idstr= ); qemu_file_set_error(f, ret); - return ret; + return -1; } trace_savevm_section_end(se->idstr, se->section_id, 0); save_section_footer(f, se); @@ -1413,10 +1416,10 @@ int qemu_savevm_state_complete_precopy_non_iterable= (QEMUFile *f, * bdrv_invalidate_cache_all() on the other end won't fail. */ ret =3D bdrv_inactivate_all(); if (ret) { - error_report("%s: bdrv_inactivate_all() failed (%d)", - __func__, ret); + error_setg_errno(errp, -ret, + "failed to deactivate disks when completing p= recopy save"); qemu_file_set_error(f, ret); - return ret; + return -1; } } if (!in_postcopy) { @@ -1440,7 +1443,6 @@ int qemu_savevm_state_complete_precopy_non_iterable(Q= EMUFile *f, int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, bool inactivate_disks) { - int ret; Error *local_err =3D NULL; bool in_postcopy =3D migration_in_postcopy(); =20 @@ -1464,10 +1466,11 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f,= bool iterable_only, goto flush; } =20 - ret =3D qemu_savevm_state_complete_precopy_non_iterable(f, in_postcopy, - inactivate_disks= ); - if (ret) { - return ret; + if (qemu_savevm_state_complete_precopy_non_iterable(f, in_postcopy, + inactivate_disks, + &local_err) < 0) { + error_report_err(local_err); + return -1; } =20 flush: --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462666; cv=none; d=zohomail.com; s=zohoarc; b=fMrl4wX5XyYEI9pkqPX1ziZTUN1y4wPZsamgd6foahSSpIhnX1I842XFK8baQmsL+so1FSVPUKNtRk1AobwDyKPXKHQ4eFg3w4qcoYaHdz2rC6Di/iB6bBsiRXgJqIBpqkXl/eJF4EPJdR/3GFGoJN2k/YsEyPXCNhQfw9OlrFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462666; 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=v9FGDJT8xxA3Typ1TVt/j5JdWTpbcLQ/bYcuvLz+xDw=; b=MgJO2srYSvsGx8JI7hhm8m0KHdnNuV95WCVmgbIakChZxiDQzd/gDlMnDjHLXY1NanSsqjUhk/PiVlfPuEApNXyx2FKJFjCgnja31O7zUSWdkhb3WU5zn9tgJcVmbnqm3dRV1Rhbz7JP1CauLDJR53S7btQlplIuEcFEDK67row= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 16124626666282.0189368921229516; Thu, 4 Feb 2021 10:17:46 -0800 (PST) Received: from localhost ([::1]:49450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jCL-00034z-DL for importer@patchew.org; Thu, 04 Feb 2021 13:17:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIj-00084k-0k for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIW-0005iI-9x for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-2H_ekr6EMs-m08GHw5aeHw-1; Thu, 04 Feb 2021 12:20:01 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 361F6100C663; Thu, 4 Feb 2021 17:20:00 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 048F360CCF; Thu, 4 Feb 2021 17:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459203; 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=v9FGDJT8xxA3Typ1TVt/j5JdWTpbcLQ/bYcuvLz+xDw=; b=VGPSw0c9vaVyVAU1U3ppEvUEomHdIAWViJF3MUQxwMYpWD1XYINAXdK9EcOTIa86anKBSA /worukt4osfCleRXKJKcDTS9wvva1s56waXUd+dgqatCagOglVCF66t1mMpCkNvd2qSpgO yUS01rUxNY38zzDUiRtuwGo4fl0bn7E= X-MC-Unique: 2H_ekr6EMs-m08GHw5aeHw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 27/33] migration: push Error **errp into qemu_savevm_state_complete_precopy() Date: Thu, 4 Feb 2021 17:19:01 +0000 Message-Id: <20210204171907.901471-28-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 14 +++++++++++--- migration/savevm.c | 18 +++++++++++------- migration/savevm.h | 3 ++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e814d47796..2ccb1b66b5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2845,7 +2845,11 @@ static int postcopy_start(MigrationState *ms) * Cause any non-postcopiable, but iterative devices to * send out their final data. */ - qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false); + if (qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false, + &local_err) < 0) { + error_report_err(local_err); + goto fail; + } =20 /* * in Finish migrate and with the io-lock held everything should @@ -2898,7 +2902,10 @@ static int postcopy_start(MigrationState *ms) */ qemu_savevm_send_postcopy_listen(fb); =20 - qemu_savevm_state_complete_precopy(fb, false, false); + if (qemu_savevm_state_complete_precopy(fb, false, false, &local_err) <= 0) { + error_report_err(local_err); + goto fail_closefb; + } if (migrate_postcopy_ram()) { qemu_savevm_send_ping(fb, 3); } @@ -3049,7 +3056,8 @@ static void migration_completion(MigrationState *s) if (ret >=3D 0) { qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, - inactivate); + inactivate, + &local_err); } if (inactivate && ret >=3D 0) { s->block_inactive =3D true; diff --git a/migration/savevm.c b/migration/savevm.c index 95e228a646..d6c36e6b6b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1441,7 +1441,8 @@ int qemu_savevm_state_complete_precopy_non_iterable(Q= EMUFile *f, } =20 int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, - bool inactivate_disks) + bool inactivate_disks, + Error **errp) { Error *local_err =3D NULL; bool in_postcopy =3D migration_in_postcopy(); @@ -1456,8 +1457,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, b= ool iterable_only, =20 if (!in_postcopy || iterable_only) { if (qemu_savevm_state_complete_precopy_iterable(f, in_postcopy, - &local_err) < 0) { - error_report_err(local_err); + errp) < 0) { return -1; } } @@ -1468,8 +1468,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, b= ool iterable_only, =20 if (qemu_savevm_state_complete_precopy_non_iterable(f, in_postcopy, inactivate_disks, - &local_err) < 0) { - error_report_err(local_err); + errp) < 0) { return -1; } =20 @@ -1568,7 +1567,9 @@ static int qemu_savevm_state(QEMUFile *f, Error **err= p) } } =20 - qemu_savevm_state_complete_precopy(f, false, false); + if (qemu_savevm_state_complete_precopy(f, false, false, errp) < 0) { + goto fail; + } ret =3D qemu_file_get_error(f); if (ret !=3D 0) { error_setg_errno(errp, -ret, "Error while writing VM state"); @@ -1594,8 +1595,11 @@ static int qemu_savevm_state(QEMUFile *f, Error **er= rp) =20 void qemu_savevm_live_state(QEMUFile *f) { + Error *local_err =3D NULL; /* save QEMU_VM_SECTION_END section */ - qemu_savevm_state_complete_precopy(f, true, false); + if (qemu_savevm_state_complete_precopy(f, true, false, &local_err) < 0= ) { + error_report_err(local_err); + } qemu_put_byte(f, QEMU_VM_EOF); } =20 diff --git a/migration/savevm.h b/migration/savevm.h index b7133655f2..e3120a4fb0 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -38,7 +38,8 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy,= Error **errp); void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, - bool inactivate_disks); + bool inactivate_disks, + Error **errp); void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463062; cv=none; d=zohomail.com; s=zohoarc; b=ZdtRRMLNq2nShqIX+KcISo39DXUHJVjT8ZnBxPLTER5/pJcSYvmzQm8pmaiqp9JiN3BJNniejXALz09jqsvH/kmpCUYndgg0Ujaa0C3yN1+4cNdmK+R0XU29WpKn5OG0AQw4R6srNKw1i3f9ou7JQW0PaF69fyyKGPXjtK+8q94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463062; 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=Gp0dO8OmqkAUGx1QgpVFAjfLM1UQ/3yCU2LGWZbxZEI=; b=OIOZ60NQ4gLHKaI+boc8xCbJRHIt/PK6Pnd/kFxyh1AOzAWvlvivP4qkPGxV46acHVj3CAvKYz54oRVNQbUI3oPrY7Sl5/ueKXlqGcJXqfjJIOyWt5CYSG2+W26FzxJUmFtE/KxYPJ/hUmvWuXacF8/fg0n2Uy82fCjFnqa0kZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463062647616.4733177260892; Thu, 4 Feb 2021 10:24:22 -0800 (PST) Received: from localhost ([::1]:44340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jIj-0006Wo-Hb for importer@patchew.org; Thu, 04 Feb 2021 13:24:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIj-00084d-0j for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIZ-0005jG-Hm for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-464-KHjOfA-yMTGSDjYbDg4Y0w-1; Thu, 04 Feb 2021 12:20:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF495107ACC7; Thu, 4 Feb 2021 17:20:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8135860937; Thu, 4 Feb 2021 17:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459206; 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=Gp0dO8OmqkAUGx1QgpVFAjfLM1UQ/3yCU2LGWZbxZEI=; b=P9Fr4zcLhA2QD7nP+rVV02QY8IzJ4G6UyQjElqAGuS3I8N+d5/bEkWJUkDmvCxSSNOzs+N ylKYkGjw4g9xN5uTT89g5Gegf8/DBWpGKw0EqC7fDokFX38DGSuHP95ShDVi+UWHQbiYZd J4039jpIXyADZK6LnBPRz3jhhceVTIE= X-MC-Unique: KHjOfA-yMTGSDjYbDg4Y0w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 28/33] migration: push Error **errp into qemu_savevm_send_packaged() Date: Thu, 4 Feb 2021 17:19:02 +0000 Message-Id: <20210204171907.901471-29-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 4 +++- migration/savevm.c | 9 +++++---- migration/savevm.h | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 2ccb1b66b5..984276d066 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2927,7 +2927,9 @@ static int postcopy_start(MigrationState *ms) restart_block =3D false; =20 /* Now send that blob */ - if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage= )) { + if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage, + &local_err)) { + error_report_err(local_err); goto fail_closefb; } qemu_fclose(fb); diff --git a/migration/savevm.c b/migration/savevm.c index d6c36e6b6b..deea8854db 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1002,15 +1002,16 @@ void qemu_savevm_send_open_return_path(QEMUFile *f) * * Returns: * 0 on success - * -ve on error + * -1 on error */ -int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len) +int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len, + Error **errp) { uint32_t tmp; =20 if (len > MAX_VM_CMD_PACKAGED_SIZE) { - error_report("%s: Unreasonably large packaged state: %zu", - __func__, len); + error_setg(errp, "unreasonably large packaged state: %zu > %d", + len, MAX_VM_CMD_PACKAGED_SIZE); return -1; } =20 diff --git a/migration/savevm.h b/migration/savevm.h index e3120a4fb0..2d46e848cd 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -46,7 +46,8 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_= size, uint64_t *res_postcopy_only); void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); void qemu_savevm_send_open_return_path(QEMUFile *f); -int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); +int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len, + Error **errp); void qemu_savevm_send_postcopy_advise(QEMUFile *f); void qemu_savevm_send_postcopy_listen(QEMUFile *f); void qemu_savevm_send_postcopy_run(QEMUFile *f); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462454; cv=none; d=zohomail.com; s=zohoarc; b=fcgi+LGNVNqFfn75DQaPSmUBhgxRA+QmrqKHYjrgp/BygHPpID95gz3q3gtQ0g+FE3KGyAY50E6qx65txeFISVaQXnrD99NzycF2ygdCVT+aGTMWSWY0uYSLUW2eS+5TRydT8rrFrxhDJLRbEskYB9GYpPWQ2c6Ty/XDIMRYPI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462454; 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=nU9gbdVdxbA/Vb8LzY88c++3UVYHBPlwcea4+Ts01r8=; b=NPEHtvWRzv48bsMzmH+gahoI8g6eKg0MEiSkdcGRGDziDhLjmnR0IQwRgZtyPL0gL37idSJcL86xfCwP0mYlkGDbCBRWzxzqixoIg68pdTp6ZuvmBMjAVpdQpDr3SBDNN9+YpjIgMWBJKXDrPsau+4unbnjZN9yvF3rDEO3G6zc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 161246245417486.85777645447308; Thu, 4 Feb 2021 10:14:14 -0800 (PST) Received: from localhost ([::1]:41172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7j8v-0007HH-4Y for importer@patchew.org; Thu, 04 Feb 2021 13:14:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iId-00082B-F6 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIY-0005jA-Ou for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-R4Vpfpi_NHSTbYxAPGiT7w-1; Thu, 04 Feb 2021 12:20:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 286B0107ACE4; Thu, 4 Feb 2021 17:20:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 074D860CFA; Thu, 4 Feb 2021 17:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459206; 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=nU9gbdVdxbA/Vb8LzY88c++3UVYHBPlwcea4+Ts01r8=; b=RUTSiQownEvQINJ2H7WP4PNF+3dO/w6f0VUEm8ksfp4/hWjDDTatnfTsfmXtGavwsoR0+t Dc+yRUdLZ3+AQpG1Z/oxCac8saDymXiP0ToLHANH89YOqVG/H89TsSp+5/gAp+3j0y+o6K F84HsZS2KM7mkhTw5QA4IQYba8xNUfk= X-MC-Unique: R4Vpfpi_NHSTbYxAPGiT7w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 29/33] migration: push Error **errp into qemu_savevm_live_state() Date: Thu, 4 Feb 2021 17:19:03 +0000 Message-Id: <20210204171907.901471-30-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/colo.c | 4 +++- migration/savevm.c | 8 ++++---- migration/savevm.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 4a050ac579..a76b72c984 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -470,7 +470,9 @@ static int colo_do_checkpoint_transaction(MigrationStat= e *s, * TODO: We may need a timeout mechanism to prevent COLO process * to be blocked here. */ - qemu_savevm_live_state(s->to_dst_file); + if (qemu_savevm_live_state(s->to_dst_file, &local_err) < 0) { + goto out; + } =20 qemu_fflush(fb); =20 diff --git a/migration/savevm.c b/migration/savevm.c index deea8854db..884d12c6eb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1594,14 +1594,14 @@ static int qemu_savevm_state(QEMUFile *f, Error **e= rrp) return -1; } =20 -void qemu_savevm_live_state(QEMUFile *f) +int qemu_savevm_live_state(QEMUFile *f, Error **errp) { - Error *local_err =3D NULL; /* save QEMU_VM_SECTION_END section */ - if (qemu_savevm_state_complete_precopy(f, true, false, &local_err) < 0= ) { - error_report_err(local_err); + if (qemu_savevm_state_complete_precopy(f, true, false, errp) < 0) { + return -1; } qemu_put_byte(f, QEMU_VM_EOF); + return 0; } =20 int qemu_save_device_state(QEMUFile *f) diff --git a/migration/savevm.h b/migration/savevm.h index 2d46e848cd..7abd75b668 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -59,7 +59,7 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, c= onst char *name, uint64_t *start_list, uint64_t *length_list); void qemu_savevm_send_colo_enable(QEMUFile *f); -void qemu_savevm_live_state(QEMUFile *f); +int qemu_savevm_live_state(QEMUFile *f, Error **errp); int qemu_save_device_state(QEMUFile *f); =20 int qemu_loadvm_state(QEMUFile *f, Error **errp); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463353; cv=none; d=zohomail.com; s=zohoarc; b=Ly0h4p8kyl8aXcMTnPj99acycZnixpDgKVlnJWrFYpcFnpWpLk0O4s/bQ5B5dMTroe4qVoJ1/lh9DTYtUjlZ/4eGCTQMoge5seUXf5LiAi4G95ScZdhvUJdPmdGl/pq9A2Oa7lLzhcWet04qnystOgN34p5tqjKtNQhyEu+k1zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463353; 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=BRaYRd3bi86keHrgnU6pJ7kzGifTS5EX3va68q0833A=; b=HtIC+4BukTyMnxzs1ZXQWV2gbozklBml+EyXv+uzGY24uCoFOQM00f2sejSuJN1Kc5UGM1JKlWEsIuUbktAebjIdAVWhoV0IOXuexFaZT5BstZp3nJyar6gN7RCELdWKzsiQkZJ8EQUNo49reWwy6JayzUw2dsrhpMzqZ4PaVcA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463353363731.2664436367764; Thu, 4 Feb 2021 10:29:13 -0800 (PST) Received: from localhost ([::1]:60866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jNQ-0004yf-6H for importer@patchew.org; Thu, 04 Feb 2021 13:29:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIp-000884-1l for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIf-0005kN-0w for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-21irJaa7PaCluITxgd_tFg-1; Thu, 04 Feb 2021 12:20:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65768100C668; Thu, 4 Feb 2021 17:20:07 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72AA860C9B; Thu, 4 Feb 2021 17:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459211; 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=BRaYRd3bi86keHrgnU6pJ7kzGifTS5EX3va68q0833A=; b=RJDzTX0BTj4DCzSfqkQzJs65CIjBW9bSmUYyYj3mHBd6Q9h4nR18MeqC/noBuQOz6oXBvO tZYjVf4XN0z7JRcE74lnBhm7xwQMv0NRGLJo6L914MqCamoIe4jEPu8npT2XbemIhKhBbN dkINkfif2a/q3oraXXVDylywnhSObh0= X-MC-Unique: 21irJaa7PaCluITxgd_tFg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 30/33] migration: push Error **errp into qemu_save_device_state() Date: Thu, 4 Feb 2021 17:19:04 +0000 Message-Id: <20210204171907.901471-31-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/colo.c | 2 +- migration/savevm.c | 51 ++++++++++++++++++++++++++++------------------ migration/savevm.h | 2 +- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index a76b72c984..fc824a9732 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -459,7 +459,7 @@ static int colo_do_checkpoint_transaction(MigrationStat= e *s, goto out; } /* Note: device state is saved into buffer */ - ret =3D qemu_save_device_state(fb); + ret =3D qemu_save_device_state(fb, &local_err); =20 qemu_mutex_unlock_iothread(); if (ret < 0) { diff --git a/migration/savevm.c b/migration/savevm.c index 884d12c6eb..994a7c7dab 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1604,9 +1604,10 @@ int qemu_savevm_live_state(QEMUFile *f, Error **errp) return 0; } =20 -int qemu_save_device_state(QEMUFile *f) +int qemu_save_device_state(QEMUFile *f, Error **errp) { SaveStateEntry *se; + int ret; =20 if (!migration_in_colo_state()) { qemu_put_be32(f, QEMU_VM_FILE_MAGIC); @@ -1615,7 +1616,6 @@ int qemu_save_device_state(QEMUFile *f) cpu_synchronize_all_states(); =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - int ret; =20 if (se->is_ram) { continue; @@ -1630,8 +1630,9 @@ int qemu_save_device_state(QEMUFile *f) save_section_header(f, se, QEMU_VM_SECTION_FULL); =20 ret =3D vmstate_save(f, se, NULL); - if (ret) { - return ret; + if (ret < 0) { + error_setg_errno(errp, -ret, "failed to save device state"); + return -1; } =20 save_section_footer(f, se); @@ -1639,7 +1640,12 @@ int qemu_save_device_state(QEMUFile *f) =20 qemu_put_byte(f, QEMU_VM_EOF); =20 - return qemu_file_get_error(f); + ret =3D qemu_file_get_error(f); + if (ret < 0) { + error_setg_errno(errp, -ret, "I/O error saving device state"); + return -1; + } + return 0; } =20 static SaveStateEntry *find_se(const char *idstr, uint32_t instance_id) @@ -2959,22 +2965,27 @@ void qmp_xen_save_devices_state(const char *filenam= e, bool has_live, bool live, qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state"); f =3D qemu_fopen_channel_output(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); - ret =3D qemu_save_device_state(f); - if (ret < 0 || qemu_fclose(f) < 0) { + ret =3D qemu_save_device_state(f, errp); + if (ret < 0) { + goto the_end; + } + + if (qemu_fclose(f) < 0) { error_setg(errp, QERR_IO_ERROR); - } else { - /* libxl calls the QMP command "stop" before calling - * "xen-save-devices-state" and in case of migration failure, libxl - * would call "cont". - * So call bdrv_inactivate_all (release locks) here to let the oth= er - * side of the migration take control of the images. - */ - if (live && !saved_vm_running) { - ret =3D bdrv_inactivate_all(); - if (ret) { - error_setg(errp, "%s: bdrv_inactivate_all() failed (%d)", - __func__, ret); - } + goto the_end; + } + + /* libxl calls the QMP command "stop" before calling + * "xen-save-devices-state" and in case of migration failure, libxl + * would call "cont". + * So call bdrv_inactivate_all (release locks) here to let the other + * side of the migration take control of the images. + */ + if (live && !saved_vm_running) { + ret =3D bdrv_inactivate_all(); + if (ret) { + error_setg(errp, "%s: bdrv_inactivate_all() failed (%d)", + __func__, ret); } } =20 diff --git a/migration/savevm.h b/migration/savevm.h index 7abd75b668..a91e097b51 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -60,7 +60,7 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, c= onst char *name, uint64_t *length_list); void qemu_savevm_send_colo_enable(QEMUFile *f); int qemu_savevm_live_state(QEMUFile *f, Error **errp); -int qemu_save_device_state(QEMUFile *f); +int qemu_save_device_state(QEMUFile *f, Error **errp); =20 int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(void); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463198; cv=none; d=zohomail.com; s=zohoarc; b=d+QtZH0kc00WAIwR1K0JxqmZgGIj+MuKr/7gqz95O1Q1MHJq7HmoGvdhgM9Tq29A19xK5MoYK1KCvXKa/n0s+C5Co8MJG4i+IBPvh/5W7/OQAiab8eyx/Mz2Eowkt4k/x8xDK6oS55MXR1u6R3GOXmumG8V2YABxTCTM8rRXdi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463198; 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=H+++6PTcE5kGIUZdCuVpIW6sYzr/KHV4BF+Goa0QGgk=; b=YG/BXyfjF9Nyon5gKKiMO/b37VULQFdqmt6htEWbfeJr0FHj1slgAZ13k5LEUmWHLJ/WWRaxUD0QNWlGgY9zvyN149YNOO1lqxtS8oXhWpxMNcUgbk431roWgb13QZcdvUeJ5B8qfI8iLFj1RUtdQ506N2zDHaY+sta8HzV1eTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463198967988.3688745910241; Thu, 4 Feb 2021 10:26:38 -0800 (PST) Received: from localhost ([::1]:51706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jKv-0001B7-RS for importer@patchew.org; Thu, 04 Feb 2021 13:26:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIj-00084q-1n for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIf-0005kc-5A for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-8ZyeGWu_N56wA-Ze7ZhvsA-1; Thu, 04 Feb 2021 12:20:09 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2CA7107ACF4; Thu, 4 Feb 2021 17:20:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEF3360C05; Thu, 4 Feb 2021 17:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459212; 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=H+++6PTcE5kGIUZdCuVpIW6sYzr/KHV4BF+Goa0QGgk=; b=PfBuj1oeg7Yvx3CwJwHtEuAijkRPJpXLcQVrKOBkhknEN8BS8/DoClx3JYf264kpAfxTd6 fQ+J0K6iHzOWoHIbwejd1+XufEScoTvQNYYmFSCL8EQCC5hV9uv3Eho8fUTgchaPYXQmKU Ht/FJuyn1wr7FGYG37a2zdFbzdxMe/A= X-MC-Unique: 8ZyeGWu_N56wA-Ze7ZhvsA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 31/33] migration: push Error **errp into qemu_savevm_state_resume_prepare() Date: Thu, 4 Feb 2021 17:19:05 +0000 Message-Id: <20210204171907.901471-32-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 9 ++++----- migration/savevm.c | 5 +++-- migration/savevm.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 984276d066..3f0586842d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3165,16 +3165,15 @@ static int postcopy_resume_handshake(MigrationState= *s) static int postcopy_do_resume(MigrationState *s) { int ret; + Error *local_err =3D NULL; =20 /* * Call all the resume_prepare() hooks, so that modules can be * ready for the migration resume. */ - ret =3D qemu_savevm_state_resume_prepare(s); - if (ret) { - error_report("%s: resume_prepare() failure detected: %d", - __func__, ret); - return ret; + if (qemu_savevm_state_resume_prepare(s, &local_err) < 0) { + error_report_err(local_err); + return -1; } =20 /* diff --git a/migration/savevm.c b/migration/savevm.c index 994a7c7dab..1d9790aa5b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1194,7 +1194,7 @@ int qemu_savevm_state_setup(QEMUFile *f, Error **errp) return 0; } =20 -int qemu_savevm_state_resume_prepare(MigrationState *s) +int qemu_savevm_state_resume_prepare(MigrationState *s, Error **errp) { SaveStateEntry *se; int ret; @@ -1212,7 +1212,8 @@ int qemu_savevm_state_resume_prepare(MigrationState *= s) } ret =3D se->ops->resume_prepare(s, se->opaque); if (ret < 0) { - return ret; + error_setg_errno(errp, -ret, "failed state resume prepare"); + return -1; } } =20 diff --git a/migration/savevm.h b/migration/savevm.h index a91e097b51..b0c40e38a7 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -32,7 +32,7 @@ bool qemu_savevm_state_blocked(Error **errp); int qemu_savevm_state_setup(QEMUFile *f, Error **errp); bool qemu_savevm_state_guest_unplug_pending(void); -int qemu_savevm_state_resume_prepare(MigrationState *s); +int qemu_savevm_state_resume_prepare(MigrationState *s, Error **errp); void qemu_savevm_state_header(QEMUFile *f); int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy, Error **errp); void qemu_savevm_state_cleanup(void); --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612463201; cv=none; d=zohomail.com; s=zohoarc; b=UYBeaPg7to/s6jjaFaIoYQ084DLb/NwMjRWxd6r2m0kYW5+nNnqSoVUini0DpZCxZLBsjNd+KTBvisqblBXOMJKVgVCqPGgI11n1/loaTQ9yp8WsU13oUOqLJerLqawxyX0GNBd8vWrARoSyrEsrzCxJ1F+YunNCz8wIDxsm6kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463201; 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=M/Ra0T4DinBmIkwbi8W/oGROJUqRKQWdb+vyzgrP4aA=; b=MtEinc9lIt1rKMIVQL0HejdMfaQAPny1WveckZ9rBT/pDa8oGLwxDd3ntIXzQKcF4bzrnnjY49LGvVUvKJ5HviaQUsZRT80zfReNSn1cgPlt6IYdiQ4qKTN0MjsOM/bRhLF3uW7fVczYlheX8NE4J7YhlfQJKH+rm6jOt70/EOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612463201907133.8687581682267; Thu, 4 Feb 2021 10:26:41 -0800 (PST) Received: from localhost ([::1]:52048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jKy-0001Js-Rh for importer@patchew.org; Thu, 04 Feb 2021 13:26:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIn-00087N-2p for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIi-0005ng-PI for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:20 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-FfjMb1rtOlyClrb4mnO1sA-1; Thu, 04 Feb 2021 12:20:11 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5CF60100C661; Thu, 4 Feb 2021 17:20:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2947860937; Thu, 4 Feb 2021 17:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459215; 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=M/Ra0T4DinBmIkwbi8W/oGROJUqRKQWdb+vyzgrP4aA=; b=iyzpP5kMNgSUq4KfRiLOzU2wDujsebmxCfKGnAv0Wvumubr2bwpKmkkfKVWlFWwDJmic4A NQsUH6PGSOivBGpTncm3vNTXUSOdzMmqiljSPMsDziwvUSRzWU1MyiBgz6yIzwlG4Vumi3 16coFVDbJ3FzeKko99unUYxpEuXalhE= X-MC-Unique: FfjMb1rtOlyClrb4mnO1sA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 32/33] migration: push Error **errp into postcopy_resume_handshake() Date: Thu, 4 Feb 2021 17:19:06 +0000 Message-Id: <20210204171907.901471-33-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3f0586842d..32a61b04bf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3146,7 +3146,7 @@ typedef enum MigThrError { MIG_THR_ERR_FATAL =3D 2, } MigThrError; =20 -static int postcopy_resume_handshake(MigrationState *s) +static int postcopy_resume_handshake(MigrationState *s, Error **errp) { qemu_savevm_send_postcopy_resume(s->to_dst_file); =20 @@ -3158,13 +3158,14 @@ static int postcopy_resume_handshake(MigrationState= *s) return 0; } =20 + error_setg(errp, "postcopy resume handshake failed state %x !=3D %x", + s->state, MIGRATION_STATUS_POSTCOPY_ACTIVE); return -1; } =20 /* Return zero if success, or <0 for error */ static int postcopy_do_resume(MigrationState *s) { - int ret; Error *local_err =3D NULL; =20 /* @@ -3180,10 +3181,9 @@ static int postcopy_do_resume(MigrationState *s) * Last handshake with destination on the resume (destination will * switch to postcopy-active afterwards) */ - ret =3D postcopy_resume_handshake(s); - if (ret) { - error_report("%s: handshake failed: %d", __func__, ret); - return ret; + if (postcopy_resume_handshake(s, &local_err) < 0) { + error_report_err(local_err); + return -1; } =20 return 0; --=20 2.29.2 From nobody Sat May 18 18:57:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612462802; cv=none; d=zohomail.com; s=zohoarc; b=JavRewGQsBFT4r7MLTVhiezdNueoN0fnANawwpRZvx0rEnyPVT5qDIVadL54S4QwSPA3zGdGCL8wsU/rP1duqScwaK5U97qfFaHqGWC+3MqIOHgBmCKgS1hxukYKD7RJBIyP3S9YZD+E8QZbL2ewGqjnsTQx7nx7aOg/UQ5cWMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612462802; 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=uLxlV8YcrZG8wxhPPp1jZ38qGz5MNzYZ0LbczyXAwxU=; b=KIE6/0dwSlpot6zt+8X4d9DI0i6wWoGA2YT9bycDIvN4M0rraWlpQ5lz+u+tneeQIFC/wPU4hFX/NTshEXNVh0Spvpcnr3xUtl6t1zUGCiJ+Sr9KXkdFQ1sO5csdBGHF2qqoA+C/R0EB4rridXvI5QL588WOEaweJYovE1wyjNg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1612462802642495.20937254003104; Thu, 4 Feb 2021 10:20:02 -0800 (PST) Received: from localhost ([::1]:57790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7jEX-0006qd-GX for importer@patchew.org; Thu, 04 Feb 2021 13:20:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7iIq-00088f-Tg for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7iIi-0005n1-Oi for qemu-devel@nongnu.org; Thu, 04 Feb 2021 12:20:24 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-rvs3Qj_VM_OCJsyC16mARQ-1; Thu, 04 Feb 2021 12:20:12 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE4AFBBEE2; Thu, 4 Feb 2021 17:20:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-221.ams2.redhat.com [10.36.112.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id A75E660937; Thu, 4 Feb 2021 17:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612459214; 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=uLxlV8YcrZG8wxhPPp1jZ38qGz5MNzYZ0LbczyXAwxU=; b=V07vEDyu4y/PyorgBXNozAYy5UzI4jglP/Q+pFJMl9wTDJ3Z08AEVjgV+fZuNvoGCY7vVx BWEbY3gIxDuhKpNCFfkxf79IQD6aeakCvA5LLrwi+eWIEtLAFWHDLP51cCWtR0h+VU5ORz Ohq5NdN8Ei/GE4U2GW9js26bvD208fM= X-MC-Unique: rvs3Qj_VM_OCJsyC16mARQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 33/33] migration: push Error **errp into postcopy_do_resume() Date: Thu, 4 Feb 2021 17:19:07 +0000 Message-Id: <20210204171907.901471-34-berrange@redhat.com> In-Reply-To: <20210204171907.901471-1-berrange@redhat.com> References: <20210204171907.901471-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrang=C3=A9 --- migration/migration.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 32a61b04bf..135a26349f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3163,17 +3163,14 @@ static int postcopy_resume_handshake(MigrationState= *s, Error **errp) return -1; } =20 -/* Return zero if success, or <0 for error */ -static int postcopy_do_resume(MigrationState *s) +/* Return zero if success, or -1 for error */ +static int postcopy_do_resume(MigrationState *s, Error **errp) { - Error *local_err =3D NULL; - /* * Call all the resume_prepare() hooks, so that modules can be * ready for the migration resume. */ - if (qemu_savevm_state_resume_prepare(s, &local_err) < 0) { - error_report_err(local_err); + if (qemu_savevm_state_resume_prepare(s, errp) < 0) { return -1; } =20 @@ -3181,8 +3178,7 @@ static int postcopy_do_resume(MigrationState *s) * Last handshake with destination on the resume (destination will * switch to postcopy-active afterwards) */ - if (postcopy_resume_handshake(s, &local_err) < 0) { - error_report_err(local_err); + if (postcopy_resume_handshake(s, errp) < 0) { return -1; } =20 @@ -3196,6 +3192,7 @@ static int postcopy_do_resume(MigrationState *s) */ static MigThrError postcopy_pause(MigrationState *s) { + Error *local_err =3D NULL; assert(s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); =20 while (true) { @@ -3235,7 +3232,7 @@ static MigThrError postcopy_pause(MigrationState *s) qemu_sem_post(&s->postcopy_pause_rp_sem); =20 /* Do the resume logic */ - if (postcopy_do_resume(s) =3D=3D 0) { + if (postcopy_do_resume(s, &local_err) =3D=3D 0) { /* Let's continue! */ trace_postcopy_pause_continued(); return MIG_THR_ERR_RECOVERED; @@ -3245,6 +3242,7 @@ static MigThrError postcopy_pause(MigrationState *s) * pause again. Pause is always better than throwing * data away. */ + error_report_err(local_err); continue; } } else { --=20 2.29.2