From patchwork Fri Dec 24 11:11:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikta Lapshin X-Patchwork-Id: 12699018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1CD10C433F5 for ; Fri, 24 Dec 2021 11:13:53 +0000 (UTC) Received: from localhost ([::1]:39006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0iWG-0003pr-4x for qemu-devel@archiver.kernel.org; Fri, 24 Dec 2021 06:13:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUP-00018Y-GF for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:48192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUM-0003OU-5B for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=npu6QCAVO0+Gg1boHLcX4oRJpIURmt5HZFLHhVTQCBE=; b=Y7e+mrjlXHs2 U4PWuA+kcxEkAzWb7sSeivDeTC6l1S2b+TOJwW2Tt2bxPj1JOJStQairQqo08OHVBK7VrODR6Bqvb VmALtQHtWyVgfwSj3AXm1wBR5w7cCrQWmCZYyHFq+khFQGWFZQD+rjIloFGaKWDL0Y+CGmDVNi9KN 4vxLA=; Received: from [10.94.3.117] (helo=nun.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1n0iUG-004OwN-VJ; Fri, 24 Dec 2021 14:11:48 +0300 From: Nikita Lapshin To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com, eduardo@habkost.net, crosa@redhat.com, kwolf@redhat.com, hreitz@redhat.com, nikita.lapshin@virtuozzo.com, vsementsov@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 1/6] migration: is_ram changed to is_iterable Date: Fri, 24 Dec 2021 14:11:43 +0300 Message-Id: <20211224111148.345438-2-nikita.lapshin@virtuozzo.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> References: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.231.240.75; envelope-from=nikita.lapshin@virtuozzo.com; helo=relay.sw.ru 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For new migration capabilities upcoming we need to use something like is_ram for this purpose. This member of struction is true not only for RAM so it should be renamed. Signed-off-by: Nikita Lapshin Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/savevm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 0bef031acb..f90fdb2bdd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -248,7 +248,7 @@ typedef struct SaveStateEntry { const VMStateDescription *vmsd; void *opaque; CompatEntry *compat; - int is_ram; + int is_iterable; } SaveStateEntry; typedef struct SaveState { @@ -797,9 +797,9 @@ int register_savevm_live(const char *idstr, se->ops = ops; se->opaque = opaque; se->vmsd = NULL; - /* if this is a live_savem then set is_ram */ + /* if this is a live_savem then set is_iterable */ if (ops->save_setup != NULL) { - se->is_ram = 1; + se->is_iterable = 1; } pstrcat(se->idstr, sizeof(se->idstr), idstr); @@ -1625,7 +1625,7 @@ int qemu_save_device_state(QEMUFile *f) QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { int ret; - if (se->is_ram) { + if (se->is_iterable) { continue; } if ((!se->ops || !se->ops->save_state) && !se->vmsd) { @@ -2428,7 +2428,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) se->load_section_id = section_id; /* Validate if it is a device's state */ - if (xen_enabled() && se->is_ram) { + if (xen_enabled() && se->is_iterable) { error_report("loadvm: %s RAM loading not allowed on Xen", idstr); return -EINVAL; } From patchwork Fri Dec 24 11:11:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikta Lapshin X-Patchwork-Id: 12699019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 472D8C433FE for ; Fri, 24 Dec 2021 11:13:53 +0000 (UTC) Received: from localhost ([::1]:38996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0iWG-0003pW-8o for qemu-devel@archiver.kernel.org; Fri, 24 Dec 2021 06:13:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUQ-00018a-TY for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:48186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUM-0003OV-7M for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=znwnfv7R77s7s4VebADjDiwiaRtlNq5ELCcua3CtUrQ=; b=qgzxeCTchrPh Qe0CqYplG4RtpIdWr+if03+JT8Wq3O4zUoMXAf2owUmvkOSLKuN1wUS0vmItaneLLArrI6sinVxTM OfWyCUtFAiFMHP+M9kFwVyruX98BkMbChgRoop2kWeFyLZFmeo7q8QcFSfBD1Te8PMnLuAw2XK5tf 3NAVg=; Received: from [10.94.3.117] (helo=nun.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1n0iUG-004OwN-Vr; Fri, 24 Dec 2021 14:11:48 +0300 From: Nikita Lapshin To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com, eduardo@habkost.net, crosa@redhat.com, kwolf@redhat.com, hreitz@redhat.com, nikita.lapshin@virtuozzo.com, vsementsov@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 2/6] migration: should_skip() implemented Date: Fri, 24 Dec 2021 14:11:44 +0300 Message-Id: <20211224111148.345438-3-nikita.lapshin@virtuozzo.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> References: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.231.240.75; envelope-from=nikita.lapshin@virtuozzo.com; helo=relay.sw.ru 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For next changes it is convenient to make all decisions about sections skipping in one function. Signed-off-by: Nikita Lapshin Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/savevm.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index f90fdb2bdd..ba644083ab 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -943,6 +943,15 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, return vmstate_save_state(f, se->vmsd, se->opaque, vmdesc); } +static bool should_skip(SaveStateEntry *se) +{ + if (se->ops->is_active && !se->ops->is_active(se->opaque)) { + return true; + } + + return false; +} + /* * Write the header for device section (QEMU_VM_SECTION START/END/PART/FULL) */ @@ -1207,10 +1216,8 @@ void qemu_savevm_state_setup(QEMUFile *f) if (!se->ops || !se->ops->save_setup) { continue; } - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } + if (should_skip(se)) { + continue; } save_section_header(f, se, QEMU_VM_SECTION_START); @@ -1238,10 +1245,8 @@ int qemu_savevm_state_resume_prepare(MigrationState *s) if (!se->ops || !se->ops->resume_prepare) { continue; } - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } + if (should_skip(se)) { + continue; } ret = se->ops->resume_prepare(s, se->opaque); if (ret < 0) { @@ -1268,8 +1273,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy) if (!se->ops || !se->ops->save_live_iterate) { continue; } - if (se->ops->is_active && - !se->ops->is_active(se->opaque)) { + if (should_skip(se)) { continue; } if (se->ops->is_active_iterate && @@ -1336,10 +1340,8 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) if (!se->ops || !se->ops->save_live_complete_postcopy) { continue; } - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } + if (should_skip(se)) { + continue; } trace_savevm_section_start(se->idstr, se->section_id); /* Section type */ @@ -1373,10 +1375,8 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy) continue; } - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } + if (should_skip(se)) { + continue; } trace_savevm_section_start(se->idstr, se->section_id); @@ -1521,10 +1521,8 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t threshold_size, if (!se->ops || !se->ops->save_live_pending) { continue; } - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } + if (should_skip(se)) { + continue; } se->ops->save_live_pending(f, se->opaque, threshold_size, res_precopy_only, res_compatible, From patchwork Fri Dec 24 11:11:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikta Lapshin X-Patchwork-Id: 12699020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3082DC4332F for ; Fri, 24 Dec 2021 11:13:53 +0000 (UTC) Received: from localhost ([::1]:39074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0iWG-0003sV-0k for qemu-devel@archiver.kernel.org; Fri, 24 Dec 2021 06:13:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUP-00018Z-Rm for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:48176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUM-0003OR-7K for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=Yee3Ax2klg8vh7BdC/9EFRNijNMHc9EKU3OOmfpV7Xc=; b=JU+gPCBuBLpu Ypmg0/9zs0XS78HZmD1uJjps/QL+jrEqVVuJ5o+r65zIItXIqpGsZ+mGvAEEj3ZNz4bf8J9V5DjjI E6OA5JTUxwSADFcDRReEwO54EicjV5nsJUhQpc+oSm3cXxWUb1Qd1u2plY1g5p6gWfLh/dj7OhMZS ZYaPs=; Received: from [10.94.3.117] (helo=nun.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1n0iUH-004OwN-0C; Fri, 24 Dec 2021 14:11:49 +0300 From: Nikita Lapshin To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com, eduardo@habkost.net, crosa@redhat.com, kwolf@redhat.com, hreitz@redhat.com, nikita.lapshin@virtuozzo.com, vsementsov@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 3/6] migration: Add no-ram capability Date: Fri, 24 Dec 2021 14:11:45 +0300 Message-Id: <20211224111148.345438-4-nikita.lapshin@virtuozzo.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> References: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.231.240.75; envelope-from=nikita.lapshin@virtuozzo.com; helo=relay.sw.ru 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This capability disable RAM section in migration stream. Signed-off-by: Nikita Lapshin Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/migration.c | 9 +++++++++ migration/migration.h | 1 + migration/ram.c | 6 ++++++ qapi/migration.json | 8 +++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3de11ae921..006447d00a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2610,6 +2610,15 @@ bool migrate_background_snapshot(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]; } +bool migrate_no_ram(void) +{ + MigrationState *s; + + s = migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_NO_RAM]; +} + /* migration thread support */ /* * Something bad happened to the RP stream, mark an error diff --git a/migration/migration.h b/migration/migration.h index 8130b703eb..43f7bf8eba 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -358,6 +358,7 @@ int migrate_decompress_threads(void); bool migrate_use_events(void); bool migrate_postcopy_blocktime(void); bool migrate_background_snapshot(void); +bool migrate_no_ram(void); /* Sending on the return path - generic and then for each message type */ void migrate_send_rp_shut(MigrationIncomingState *mis, diff --git a/migration/ram.c b/migration/ram.c index 57efa67f20..aa3583d0bc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4339,6 +4339,11 @@ static int ram_resume_prepare(MigrationState *s, void *opaque) return 0; } +static bool ram_is_active(void* opaque) +{ + return !migrate_no_ram(); +} + static SaveVMHandlers savevm_ram_handlers = { .save_setup = ram_save_setup, .save_live_iterate = ram_save_iterate, @@ -4351,6 +4356,7 @@ static SaveVMHandlers savevm_ram_handlers = { .load_setup = ram_load_setup, .load_cleanup = ram_load_cleanup, .resume_prepare = ram_resume_prepare, + .is_active = ram_is_active, }; static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host, diff --git a/qapi/migration.json b/qapi/migration.json index bbfd48cf0b..d53956852c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -452,6 +452,8 @@ # procedure starts. The VM RAM is saved with running VM. # (since 6.0) # +# @no-ram: If enabled, migration stream won't contain any ram in it. (since 7.0) +# # Features: # @unstable: Members @x-colo and @x-ignore-shared are experimental. # @@ -465,8 +467,7 @@ 'block', 'return-path', 'pause-before-switchover', 'multifd', 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, - 'validate-uuid', 'background-snapshot'] } - + 'validate-uuid', 'background-snapshot', 'no-ram'] } ## # @MigrationCapabilityStatus: # @@ -519,7 +520,8 @@ # {"state": false, "capability": "compress"}, # {"state": true, "capability": "events"}, # {"state": false, "capability": "postcopy-ram"}, -# {"state": false, "capability": "x-colo"} +# {"state": false, "capability": "x-colo"}, +# {"state": false, "capability": "no-ram"} # ]} # ## From patchwork Fri Dec 24 11:11:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikta Lapshin X-Patchwork-Id: 12699022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03FDEC433F5 for ; Fri, 24 Dec 2021 11:17:44 +0000 (UTC) Received: from localhost ([::1]:46970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0iZz-0000zo-67 for qemu-devel@archiver.kernel.org; Fri, 24 Dec 2021 06:17:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUO-00018W-IG for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:57 -0500 Received: from relay.sw.ru ([185.231.240.75]:48180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUL-0003OP-OD for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=BCZPOz7PNvWKMmFA73SNdrDpoTzMi0IKzZ/uQSMBGGc=; b=efuiodMQD5EQ bv2+/SZNPv8WVruP/XBiYTQlfPHKot8Vbq6iOXkOeehXQwprIJRCbGPV2BU7LLvRgNsFXnWDqMWb3 GMnbj0GeYJ2kGoiroOyLq/7P6w8qsn22NnpSON9cX6EaZIgBQ+jLOpshRnDdjX/qvXG9TAfa98022 iaGzc=; Received: from [10.94.3.117] (helo=nun.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1n0iUH-004OwN-2L; Fri, 24 Dec 2021 14:11:49 +0300 From: Nikita Lapshin To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com, eduardo@habkost.net, crosa@redhat.com, kwolf@redhat.com, hreitz@redhat.com, nikita.lapshin@virtuozzo.com, vsementsov@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 4/6] migration: Add ram-only capability Date: Fri, 24 Dec 2021 14:11:46 +0300 Message-Id: <20211224111148.345438-5-nikita.lapshin@virtuozzo.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> References: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.231.240.75; envelope-from=nikita.lapshin@virtuozzo.com; helo=relay.sw.ru 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If this capability is enabled migration stream will have RAM section only. Signed-off-by: Nikita Lapshin --- migration/migration.c | 20 +++++++++++++++++++- migration/migration.h | 1 + migration/savevm.c | 11 ++++++++++- qapi/migration.json | 7 +++++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 006447d00a..4d7ef9d8dc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1257,6 +1257,14 @@ static bool migrate_caps_check(bool *cap_list, return false; } + if (cap_list[MIGRATION_CAPABILITY_NO_RAM] && + cap_list[MIGRATION_CAPABILITY_RAM_ONLY]) { + error_setg(errp, "ram-only and no-ram aren't " + "compatible with each other"); + + return false; + } + return true; } @@ -2619,6 +2627,15 @@ bool migrate_no_ram(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_NO_RAM]; } +bool migrate_ram_only(void) +{ + MigrationState *s; + + s = migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_RAM_ONLY]; +} + /* migration thread support */ /* * Something bad happened to the RP stream, mark an error @@ -3973,7 +3990,8 @@ static void *bg_migration_thread(void *opaque) * save their state to channel-buffer along with devices. */ cpu_synchronize_all_states(); - if (qemu_savevm_state_complete_precopy_non_iterable(fb, false, false)) { + if (!migrate_ram_only() && + qemu_savevm_state_complete_precopy_non_iterable(fb, false, false)) { goto fail; } /* diff --git a/migration/migration.h b/migration/migration.h index 43f7bf8eba..d5a077e00d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -359,6 +359,7 @@ bool migrate_use_events(void); bool migrate_postcopy_blocktime(void); bool migrate_background_snapshot(void); bool migrate_no_ram(void); +bool migrate_ram_only(void); /* Sending on the return path - generic and then for each message type */ void migrate_send_rp_shut(MigrationIncomingState *mis, diff --git a/migration/savevm.c b/migration/savevm.c index ba644083ab..e41ca76000 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -249,6 +249,7 @@ typedef struct SaveStateEntry { void *opaque; CompatEntry *compat; int is_iterable; + bool is_ram; } SaveStateEntry; typedef struct SaveState { @@ -802,6 +803,10 @@ int register_savevm_live(const char *idstr, se->is_iterable = 1; } + if (!strcmp("ram", idstr)) { + se->is_ram = true; + } + pstrcat(se->idstr, sizeof(se->idstr), idstr); if (instance_id == VMSTATE_INSTANCE_ID_ANY) { @@ -949,6 +954,10 @@ static bool should_skip(SaveStateEntry *se) return true; } + if (migrate_ram_only() && !se->is_ram) { + return true; + } + return false; } @@ -1486,7 +1495,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, } } - if (iterable_only) { + if (iterable_only || migrate_ram_only()) { goto flush; } diff --git a/qapi/migration.json b/qapi/migration.json index d53956852c..626fc59d14 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -454,6 +454,8 @@ # # @no-ram: If enabled, migration stream won't contain any ram in it. (since 7.0) # +# @ram-only: If enabled, only RAM sections will be sent. (since 7.0) +# # Features: # @unstable: Members @x-colo and @x-ignore-shared are experimental. # @@ -467,7 +469,7 @@ 'block', 'return-path', 'pause-before-switchover', 'multifd', 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, - 'validate-uuid', 'background-snapshot', 'no-ram'] } + 'validate-uuid', 'background-snapshot', 'no-ram', 'ram-only'] } ## # @MigrationCapabilityStatus: # @@ -521,7 +523,8 @@ # {"state": true, "capability": "events"}, # {"state": false, "capability": "postcopy-ram"}, # {"state": false, "capability": "x-colo"}, -# {"state": false, "capability": "no-ram"} +# {"state": false, "capability": "no-ram"}, +# {"state": false, "capability": "ram-only"} # ]} # ## From patchwork Fri Dec 24 11:11:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikta Lapshin X-Patchwork-Id: 12699021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF6ADC433EF for ; Fri, 24 Dec 2021 11:17:43 +0000 (UTC) Received: from localhost ([::1]:46926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0iZy-0000xz-KQ for qemu-devel@archiver.kernel.org; Fri, 24 Dec 2021 06:17:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUP-00018X-Dx for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:48188) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUL-0003OS-OA for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=tCvifQSnLlWrMvmJBaFd5pcx1Ud1JDyXCYHoGHkKti8=; b=sbjo1RF0rdJG g/gNAiiMrNvqf1SyBNOnNSL8n7+c2Tbav11SaTIGvQ2myuSiCo7f/L0os56GJ/JnSp+OCuJZ1A0pm bpsoJD3uTjLz3XZJOEOE6qRBlkYQqXPTDVQY9Ou6jLH4buR4I3DxCzZnJVv5tSvBI2ZdfLEp+5KND eHh40=; Received: from [10.94.3.117] (helo=nun.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1n0iUH-004OwN-4E; Fri, 24 Dec 2021 14:11:49 +0300 From: Nikita Lapshin To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com, eduardo@habkost.net, crosa@redhat.com, kwolf@redhat.com, hreitz@redhat.com, nikita.lapshin@virtuozzo.com, vsementsov@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 5/6] migration: analyze-migration script changed Date: Fri, 24 Dec 2021 14:11:47 +0300 Message-Id: <20211224111148.345438-6-nikita.lapshin@virtuozzo.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> References: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.231.240.75; envelope-from=nikita.lapshin@virtuozzo.com; helo=relay.sw.ru 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This script is used for RAM capabilities test. But it cannot work in case of no vm description in migration stream. So new flag is added to allow work this script with ram-only migration stream. Signed-off-by: Nikita Lapshin --- scripts/analyze-migration.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py index b82a1b0c58..80077a09bc 100755 --- a/scripts/analyze-migration.py +++ b/scripts/analyze-migration.py @@ -495,7 +495,7 @@ def __init__(self, filename): self.filename = filename self.vmsd_desc = None - def read(self, desc_only = False, dump_memory = False, write_memory = False): + def read(self, ram_only, desc_only = False, dump_memory = False, write_memory = False): # Read in the whole file file = MigrationFile(self.filename) @@ -509,7 +509,8 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False): if data != self.QEMU_VM_FILE_VERSION: raise Exception("Invalid version number %d" % data) - self.load_vmsd_json(file) + if not ram_only: + self.load_vmsd_json(file) # Read sections self.sections = collections.OrderedDict() @@ -518,7 +519,10 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False): return ramargs = {} - ramargs['page_size'] = self.vmsd_desc['page_size'] + if ram_only: + ramargs['page_size'] = 4096 + else: + ramargs['page_size'] = self.vmsd_desc['page_size'] ramargs['dump_memory'] = dump_memory ramargs['write_memory'] = write_memory self.section_classes[('ram',0)][1] = ramargs @@ -579,6 +583,7 @@ def default(self, o): parser.add_argument("-m", "--memory", help='dump RAM contents as well', action='store_true') parser.add_argument("-d", "--dump", help='what to dump ("state" or "desc")', default='state') parser.add_argument("-x", "--extract", help='extract contents into individual files', action='store_true') +parser.add_argument("--ram-only", help='parse migration dump containing only RAM', action='store_true') args = parser.parse_args() jsonenc = JSONEncoder(indent=4, separators=(',', ': ')) @@ -586,14 +591,14 @@ def default(self, o): if args.extract: dump = MigrationDump(args.file) - dump.read(desc_only = True) + dump.read(desc_only = True, ram_only = args.ram_only) print("desc.json") f = open("desc.json", "w") f.truncate() f.write(jsonenc.encode(dump.vmsd_desc)) f.close() - dump.read(write_memory = True) + dump.read(write_memory = True, ram_only = args.ram_only) dict = dump.getDict() print("state.json") f = open("state.json", "w") @@ -602,12 +607,12 @@ def default(self, o): f.close() elif args.dump == "state": dump = MigrationDump(args.file) - dump.read(dump_memory = args.memory) + dump.read(dump_memory = args.memory, ram_only = args.ram_only) dict = dump.getDict() print(jsonenc.encode(dict)) elif args.dump == "desc": dump = MigrationDump(args.file) - dump.read(desc_only = True) + dump.read(desc_only = True, ram_only = args.ram_only) print(jsonenc.encode(dump.vmsd_desc)) else: raise Exception("Please specify either -x, -d state or -d desc") From patchwork Fri Dec 24 11:11:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikta Lapshin X-Patchwork-Id: 12699023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49603C433EF for ; Fri, 24 Dec 2021 11:19:39 +0000 (UTC) Received: from localhost ([::1]:52222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0ibq-0004Z7-89 for qemu-devel@archiver.kernel.org; Fri, 24 Dec 2021 06:19:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUR-00018b-AF for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:48200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0iUM-0003OQ-6E for qemu-devel@nongnu.org; Fri, 24 Dec 2021 06:11:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=JiHOn090187soNjUgeM1lAwziV2eS+k5CJ/SAjifh4I=; b=IXWhr1dABt7Z NDFHyvWGg+phUM4UArnIiMNRA1WbC2uAc6k0ftVyLoFpkaC1LvT1gpUWau5mbeOMX+PLAscV7+Y3Y REXV31+udxapZv36152+2lYXI1tj0xBi544pXsZWK8NkrKLPfQG97Jl6jMae3+xtu4CajKifqZkc2 gpzRQ=; Received: from [10.94.3.117] (helo=nun.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1n0iUH-004OwN-67; Fri, 24 Dec 2021 14:11:49 +0300 From: Nikita Lapshin To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com, eduardo@habkost.net, crosa@redhat.com, kwolf@redhat.com, hreitz@redhat.com, nikita.lapshin@virtuozzo.com, vsementsov@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 6/6] migration: Test for ram capabilities Date: Fri, 24 Dec 2021 14:11:48 +0300 Message-Id: <20211224111148.345438-7-nikita.lapshin@virtuozzo.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> References: <20211224111148.345438-1-nikita.lapshin@virtuozzo.com> MIME-Version: 1.0 Received-SPF: pass client-ip=185.231.240.75; envelope-from=nikita.lapshin@virtuozzo.com; helo=relay.sw.ru 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use scripts/analyze-migration.py to split migration stream into sections and analyze its output. Signed-off-by: Nikita Lapshin --- .../tests/migrate-ram-capabilities-test | 96 +++++++++++++++++++ .../tests/migrate-ram-capabilities-test.out | 5 + 2 files changed, 101 insertions(+) create mode 100755 tests/qemu-iotests/tests/migrate-ram-capabilities-test create mode 100644 tests/qemu-iotests/tests/migrate-ram-capabilities-test.out diff --git a/tests/qemu-iotests/tests/migrate-ram-capabilities-test b/tests/qemu-iotests/tests/migrate-ram-capabilities-test new file mode 100755 index 0000000000..917f888340 --- /dev/null +++ b/tests/qemu-iotests/tests/migrate-ram-capabilities-test @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +# group: rw migration +# +# Tests for 'no-ram' and 'ram-only' capabilities +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import json +import subprocess +import iotests + +img = os.path.join(iotests.test_dir, 'disk.img') + +class TestRamCapabilities(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img('create', '-f', iotests.imgfmt, img, '10M') + self.vm = iotests.VM() + self.vm.launch() + self.vm.qmp('migrate-set-capabilities', capabilities=[ + { + 'capability': 'events', + 'state': True + } + ]) + + def tearDown(self): + self.vm.shutdown() + os.remove(img) + + def check_ram_only(self, output): + str_json = output.decode() + json_obj = json.loads(str_json) + + success = False + for key in json_obj: + self.assertTrue("ram" in key) + success = True + self.assertTrue(success) + + def run_migration(self, capability, tmp_stream): + self.vm.qmp('migrate-set-capabilities', capabilities=[ + { + 'capability': capability, + 'state': True + } + ]) + + self.vm.qmp('migrate', uri='exec:cat>' + tmp_stream) + + while True: + event = self.vm.event_wait('MIGRATION') + + if event['data']['status'] == 'completed': + break + + + def test_no_ram(self): + with iotests.FilePath('tmp_stream') as tmp_stream: + self.run_migration('no-ram', tmp_stream) + output = subprocess.run( + ['../../../scripts/analyze-migration.py', '-f', tmp_stream], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False).stdout + + self.assertFalse('ram' in output.decode()) + + def test_ram_only(self): + with iotests.FilePath('tmp_stream') as tmp_stream: + self.run_migration('ram-only', tmp_stream) + output = subprocess.run( + ['../../../scripts/analyze-migration.py', '-f', tmp_stream, + '--ram-only'], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False).stdout + + self.check_ram_only(output) + +if __name__ == '__main__': + iotests.main(supported_protocols=['file']) diff --git a/tests/qemu-iotests/tests/migrate-ram-capabilities-test.out b/tests/qemu-iotests/tests/migrate-ram-capabilities-test.out new file mode 100644 index 0000000000..fbc63e62f8 --- /dev/null +++ b/tests/qemu-iotests/tests/migrate-ram-capabilities-test.out @@ -0,0 +1,5 @@ +.. +---------------------------------------------------------------------- +Ran 2 tests + +OK