From: Wei Yang <richardw.yang@linux.intel.com>
To: quintela@redhat.com, dgilbert@redhat.com
Cc: qemu-devel@nongnu.org, Wei Yang <richardw.yang@linux.intel.com>
Subject: [PATCH 2/2] migration/compress: disable compress if failed to setup
Date: Sat, 12 Oct 2019 10:39:32 +0800 [thread overview]
Message-ID: <20191012023932.1863-3-richardw.yang@linux.intel.com> (raw)
In-Reply-To: <20191012023932.1863-1-richardw.yang@linux.intel.com>
In current logic, if compress_threads_save_setup() returns -1 the whole
migration would fail, while we could handle it gracefully by disable
compress.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
migration/migration.c | 9 +++++++++
migration/migration.h | 1 +
migration/ram.c | 15 ++++++++-------
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 5f7e4d15e9..02b95f4223 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2093,6 +2093,15 @@ bool migrate_use_compression(void)
return s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS];
}
+void migrate_disable_compression(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS] = false;
+}
+
int migrate_compress_level(void)
{
MigrationState *s;
diff --git a/migration/migration.h b/migration/migration.h
index 4f2fe193dc..51368d3a6e 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -309,6 +309,7 @@ bool migrate_use_return_path(void);
uint64_t ram_get_total_transferred_pages(void);
bool migrate_use_compression(void);
+void migrate_disable_compression(void);
int migrate_compress_level(void);
int migrate_compress_threads(void);
int migrate_compress_wait_thread(void);
diff --git a/migration/ram.c b/migration/ram.c
index 96c9b16402..39279161a8 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -533,12 +533,12 @@ static void compress_threads_save_cleanup(void)
comp_param = NULL;
}
-static int compress_threads_save_setup(void)
+static void compress_threads_save_setup(void)
{
int i, thread_count;
if (!migrate_use_compression()) {
- return 0;
+ return;
}
thread_count = migrate_compress_threads();
compress_threads = g_new0(QemuThread, thread_count);
@@ -569,11 +569,14 @@ static int compress_threads_save_setup(void)
do_data_compress, comp_param + i,
QEMU_THREAD_JOINABLE);
}
- return 0;
+ return;
exit:
compress_threads_save_cleanup();
- return -1;
+ migrate_disable_compression();
+ error_report("%s: failed to setup compress threads, compress disabled",
+ __func__);
+ return;
}
/* Multiple fd's */
@@ -3338,9 +3341,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
RAMState **rsp = opaque;
RAMBlock *block;
- if (compress_threads_save_setup()) {
- return -1;
- }
+ compress_threads_save_setup();
/* migration has already setup the bitmap, reuse it. */
if (!migration_in_colo_state()) {
--
2.17.1
next prev parent reply other threads:[~2019-10-12 2:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-12 2:39 [PATCH 0/2] migration/compress: refine the compress case Wei Yang
2019-10-12 2:39 ` [PATCH 1/2] migration/compress: compress QEMUFile is not writable Wei Yang
2019-11-07 11:59 ` Dr. David Alan Gilbert
2019-11-07 12:08 ` Wei Yang
2020-01-27 15:32 ` Juan Quintela
2019-10-12 2:39 ` Wei Yang [this message]
2019-11-07 12:11 ` [PATCH 2/2] migration/compress: disable compress if failed to setup Dr. David Alan Gilbert
2020-01-27 15:13 ` Juan Quintela
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=20191012023932.1863-3-richardw.yang@linux.intel.com \
--to=richardw.yang@linux.intel.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).