From nobody Mon Feb 9 15:46:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1664887396; cv=none; d=zohomail.com; s=zohoarc; b=it4JvExjBjPN+4xqOaAuNQV5Z4V6QwSx1qWLuocPL48AEnWMvZjY1D5wXwj2wWWCZnDBeVaVqePSHitLazhrWsCYr2enA/APmx5NUTQla/A9soInYCMhOZvretpUB75rHQcSX+v+CBO99UHN80566oBjXHuFwYj2pWBEdp9hfnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664887396; h=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=h5OBUZNH7NOyqSuyiWgAKL7M/7/MeSlkQLE3XtRV5eo=; b=eZPXpD6kiGCNfaYS7I7K75OVeAInjMb94Ea3bYsGBLzMwzqwFX6bxV3ttO2mdG3MJfceved+sHzlncZjzki508D7bYb2q0noTuCvDzbMA6mAx/IXI6Bibb3miDVLUMOyS4lMfbUicrGn/DjbLMWPSH/dU5PPRu+iSExD5QVLeuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664887396922320.3327442595096; Tue, 4 Oct 2022 05:43:16 -0700 (PDT) Received: from localhost ([::1]:59684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofhGU-00036U-Ty for importer@patchew.org; Tue, 04 Oct 2022 08:43:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofhBD-0006mS-9l for qemu-devel@nongnu.org; Tue, 04 Oct 2022 08:37:49 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]:49910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofhB9-0005rM-TO for qemu-devel@nongnu.org; Tue, 04 Oct 2022 08:37:46 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A1BFD1F899; Tue, 4 Oct 2022 12:37:39 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 36118139EF; Tue, 4 Oct 2022 12:37:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OAB3ChMpPGNlRQAAMHmgww (envelope-from ); Tue, 04 Oct 2022 12:37:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1664887059; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h5OBUZNH7NOyqSuyiWgAKL7M/7/MeSlkQLE3XtRV5eo=; b=YiEdGV7EXcYA3GqZwRbPRM8/eioreQQZeZ3B4XcuPk3CRpMpFjlwxNmJXSPwxlAjWYKHz/ C+HRF2VbhQadUks7MvpsX+Qg3n/3jXKEH4ZS7X8NRTDEXwwGDtfdPiEF+JpsLJzOgcwaSN h9IrdMzpkdBwDSQahHwGUB5z5SkPpvI= From: Nikolay Borisov To: dgilbert@redhat.com, berrange@redhat.com Cc: qemu-devel@nongnu.org, jfehlig@suse.com, Claudio.Fontana@suse.com, dfaggioli@suse.com, Nikolay Borisov Subject: [PATCH 03/11] migration: Make migration json writer part of MigrationState struct Date: Tue, 4 Oct 2022 15:37:25 +0300 Message-Id: <20221004123733.2745519-4-nborisov@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221004123733.2745519-1-nborisov@suse.com> References: <20221004123733.2745519-1-nborisov@suse.com> MIME-Version: 1.0 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=2001:67c:2178:6::1d; envelope-from=nborisov@suse.com; helo=smtp-out2.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1664887398541100001 Content-Type: text/plain; charset="utf-8" This is required so that migration stream configuration is written to the migration stream. This would allow analyze-migration to parse enabled capabilities for the migration and adjust its behavior accordingly. This is in preparation for analyze-migration.py to support 'fixed-ram' capability format changes. Signed-off-by: Nikolay Borisov --- migration/migration.c | 5 +++++ migration/migration.h | 3 +++ migration/savevm.c | 38 ++++++++++++++++++++++---------------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 140b0f1a54bd..d0779bbaf862 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1896,6 +1896,8 @@ static void migrate_fd_cleanup(MigrationState *s) g_free(s->hostname); s->hostname =3D NULL; =20 + json_writer_free(s->vmdesc); + qemu_savevm_state_cleanup(); =20 if (s->to_dst_file) { @@ -2154,6 +2156,7 @@ void migrate_init(MigrationState *s) error_free(s->error); s->error =3D NULL; s->hostname =3D NULL; + s->vmdesc =3D NULL; =20 migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_S= ETUP); =20 @@ -4269,6 +4272,8 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) return; } =20 + s->vmdesc =3D json_writer_new(false); + if (multifd_save_setup(&local_err) !=3D 0) { error_report_err(local_err); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, diff --git a/migration/migration.h b/migration/migration.h index cdad8aceaaab..96f27aba2210 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -17,6 +17,7 @@ #include "exec/cpu-common.h" #include "hw/qdev-core.h" #include "qapi/qapi-types-migration.h" +#include "qapi/qmp/json-writer.h" #include "qemu/thread.h" #include "qemu/coroutine_int.h" #include "io/channel.h" @@ -261,6 +262,8 @@ struct MigrationState { =20 int state; =20 + JSONWriter *vmdesc; + /* State related to return path */ struct { /* Protected by qemu_file_lock */ diff --git a/migration/savevm.c b/migration/savevm.c index 48e85c052c2c..174cdbefc29d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1137,13 +1137,18 @@ void qemu_savevm_non_migratable_list(strList **reas= ons) =20 void qemu_savevm_state_header(QEMUFile *f) { + MigrationState *s =3D migrate_get_current(); trace_savevm_state_header(); qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); =20 - if (migrate_get_current()->send_configuration) { + if (s->send_configuration) { qemu_put_byte(f, QEMU_VM_CONFIGURATION); - vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0); + json_writer_start_object(s->vmdesc, NULL); + json_writer_start_object(s->vmdesc, "configuration"); + vmstate_save_state(f, &vmstate_configuration, &savevm_state, s->vm= desc); + json_writer_end_object(s->vmdesc); + } } =20 @@ -1364,15 +1369,16 @@ int qemu_savevm_state_complete_precopy_non_iterable= (QEMUFile *f, bool in_postcopy, bool inactivate_disks) { - g_autoptr(JSONWriter) vmdesc =3D NULL; + MigrationState *s =3D migrate_get_current(); int vmdesc_len; SaveStateEntry *se; int ret; =20 - vmdesc =3D json_writer_new(false); - json_writer_start_object(vmdesc, NULL); - json_writer_int64(vmdesc, "page_size", qemu_target_page_size()); - json_writer_start_array(vmdesc, "devices"); + if (!s->send_configuration) { + json_writer_start_object(s->vmdesc, NULL); + } + json_writer_int64(s->vmdesc, "page_size", qemu_target_page_size()); + json_writer_start_array(s->vmdesc, "devices"); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { =20 if ((!se->ops || !se->ops->save_state) && !se->vmsd) { @@ -1385,12 +1391,12 @@ int qemu_savevm_state_complete_precopy_non_iterable= (QEMUFile *f, =20 trace_savevm_section_start(se->idstr, se->section_id); =20 - json_writer_start_object(vmdesc, NULL); - json_writer_str(vmdesc, "name", se->idstr); - json_writer_int64(vmdesc, "instance_id", se->instance_id); + json_writer_start_object(s->vmdesc, NULL); + json_writer_str(s->vmdesc, "name", se->idstr); + json_writer_int64(s->vmdesc, "instance_id", se->instance_id); =20 save_section_header(f, se, QEMU_VM_SECTION_FULL); - ret =3D vmstate_save(f, se, vmdesc); + ret =3D vmstate_save(f, se, s->vmdesc); if (ret) { qemu_file_set_error(f, ret); return ret; @@ -1398,7 +1404,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(Q= EMUFile *f, trace_savevm_section_end(se->idstr, se->section_id, 0); save_section_footer(f, se); =20 - json_writer_end_object(vmdesc); + json_writer_end_object(s->vmdesc); } =20 if (inactivate_disks) { @@ -1417,14 +1423,14 @@ int qemu_savevm_state_complete_precopy_non_iterable= (QEMUFile *f, qemu_put_byte(f, QEMU_VM_EOF); } =20 - json_writer_end_array(vmdesc); - json_writer_end_object(vmdesc); - vmdesc_len =3D strlen(json_writer_get(vmdesc)); + json_writer_end_array(s->vmdesc); + json_writer_end_object(s->vmdesc); + vmdesc_len =3D strlen(json_writer_get(s->vmdesc)); =20 if (should_send_vmdesc()) { qemu_put_byte(f, QEMU_VM_VMDESCRIPTION); qemu_put_be32(f, vmdesc_len); - qemu_put_buffer(f, (uint8_t *)json_writer_get(vmdesc), vmdesc_len); + qemu_put_buffer(f, (uint8_t *)json_writer_get(s->vmdesc), vmdesc_l= en); } =20 return 0; --=20 2.34.1