qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: nikita.lapshin@openvz.org
To: qemu-devel@nongnu.org
Cc: den@virtuozzo.com, andrey.drobyshev@virtuozzo.com,
	quintela@redhat.com, dgilbert@redhat.com,
	nikita.lapshin@openvz.org
Subject: [PATCH v3 02/17] migration: should_skip() implemented
Date: Thu, 16 Jun 2022 13:27:56 +0300	[thread overview]
Message-ID: <20220616102811.219007-3-nikita.lapshin@openvz.org> (raw)
In-Reply-To: <20220616102811.219007-1-nikita.lapshin@openvz.org>

From: Nikita Lapshin <nikita.lapshin@openvz.org>

For next changes it is convenient to make all decisions about
sections skipping in one function.

Signed-off-by: Nikita Lapshin <nikita.lapshin@openvz.org>
---
 migration/savevm.c | 54 ++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 02ed94c180..c68f187ef7 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 && 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 &&
@@ -1337,10 +1341,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 */
@@ -1374,10 +1376,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);
 
@@ -1417,6 +1417,9 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
             trace_savevm_section_skip(se->idstr, se->section_id);
             continue;
         }
+        if (should_skip(se)) {
+            continue;
+        }
 
         trace_savevm_section_start(se->idstr, se->section_id);
 
@@ -1522,10 +1525,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,
@@ -1635,6 +1636,9 @@ int qemu_save_device_state(QEMUFile *f)
         if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) {
             continue;
         }
+        if (should_skip(se)) {
+            continue;
+        }
 
         save_section_header(f, se, QEMU_VM_SECTION_FULL);
 
@@ -2542,10 +2546,8 @@ static int qemu_loadvm_state_setup(QEMUFile *f)
         if (!se->ops || !se->ops->load_setup) {
             continue;
         }
-        if (se->ops->is_active) {
-            if (!se->ops->is_active(se->opaque)) {
-                continue;
-            }
+        if (should_skip(se)) {
+            continue;
         }
 
         ret = se->ops->load_setup(f, se->opaque);
-- 
2.31.1



  parent reply	other threads:[~2022-06-16 10:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 10:27 [PATCH v3 00/17] migration/snapshot: External snapshot utility nikita.lapshin
2022-06-16 10:27 ` [PATCH v3 01/17] migration: Implemented new parameter stream_content nikita.lapshin
2022-06-16 10:27 ` nikita.lapshin [this message]
2022-06-16 10:27 ` [PATCH v3 03/17] migration: Add vmstate part of migration stream nikita.lapshin
2022-06-16 10:27 ` [PATCH v3 04/17] migration: Add dirty-bitmaps " nikita.lapshin
2022-06-16 10:27 ` [PATCH v3 05/17] migration: Add block " nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 06/17] migration: Add RAM " nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 07/17] migration: analyze-migration script changed nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 08/17] migration: Test for RAM and vmstate parts nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 09/17] migration/snapshot: Introduce qemu-snapshot tool nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 10/17] migration/snapshot: Build changes for qemu-snapshot-tool nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 11/17] migration/qemu-file: Fix qemu_ftell() for non-writable file nikita.lapshin
2022-06-16 11:20   ` Daniel P. Berrangé
2022-06-16 12:54     ` Nikita
2022-06-16 10:28 ` [PATCH v3 12/17] migration/snapshot: Move RAM_SAVE_FLAG_xxx defines to migration/ram.h nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 13/17] migration/snapshot: Block layer support in qemu-snapshot nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 14/17] migration/snpashot: Implement API for RAMBlock nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 15/17] migration/snapshot: Save part implement nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 16/17] migration/snapshot: Precopy load implemented nikita.lapshin
2022-06-16 10:28 ` [PATCH v3 17/17] migration/snapshot: Postcopy " nikita.lapshin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220616102811.219007-3-nikita.lapshin@openvz.org \
    --to=nikita.lapshin@openvz.org \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=den@virtuozzo.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).