From: Zeyu Jin <jinzeyu@huawei.com>
To: <quintela@redhat.com>, <dgilbert@redhat.com>
Cc: Ying Fang <fangying1@huawei.com>,
qemu-devel@nongnu.org, Zeyu Jin <jinzeyu@huawei.com>,
zhang.zhanghailiang@huawei.com
Subject: [RFC PATCH 5/6] migration: Add compress_level sanity check
Date: Mon, 9 Nov 2020 17:08:49 +0800 [thread overview]
Message-ID: <20201109090850.2424-6-jinzeyu@huawei.com> (raw)
In-Reply-To: <20201109090850.2424-1-jinzeyu@huawei.com>
Zlib compression has level from 1 to 9. However Zstd compression has level
from 1 to 22 (level >= 20 not recommanded). Let's do sanity check here
to make sure a vaild compress_level is given by user.
Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
migration/migration.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 2c68012029..6fc0c3b532 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1235,16 +1235,40 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
}
}
+static bool compress_level_check(MigrationParameters *params, Error **errp)
+{
+ switch (params->compress_method) {
+ case COMPRESS_METHOD_ZLIB:
+ if (params->compress_level > 9 || params->compress_level < 1) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
+ "a value in the range of 0 to 9 for Zlib method");
+ return false;
+ }
+ break;
+#ifdef CONFIG_ZSTD
+ case COMPRESS_METHOD_ZSTD:
+ if (params->compress_level > 19 || params->compress_level < 1) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
+ "a value in the range of 1 to 19 for Zstd method");
+ return false;
+ }
+ break;
+#endif
+ default:
+ error_setg(errp, "Checking compress_level failed for unknown reason");
+ return false;
+ }
+
+ return true;
+}
+
/*
* Check whether the parameters are valid. Error will be put into errp
* (if provided). Return true if valid, otherwise false.
*/
static bool migrate_params_check(MigrationParameters *params, Error **errp)
{
- if (params->has_compress_level &&
- (params->compress_level > 9)) {
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
- "is invalid, it should be in the range of 0 to 9");
+ if (params->has_compress_level && !compress_level_check(params, errp)) {
return false;
}
--
2.23.0
next prev parent reply other threads:[~2020-11-09 9:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 9:08 [RFC PATCH 0/6] migration: Multi-thread compression with zstd method Zeyu Jin
2020-11-09 9:08 ` [RFC PATCH 1/6] migration: Add multi-thread compress method Zeyu Jin
2020-11-09 15:57 ` Eric Blake
2020-11-10 2:07 ` Zeyu Jin
2020-11-09 9:08 ` [RFC PATCH 2/6] migration: Refactoring multi-thread compress migration Zeyu Jin
2020-11-09 9:08 ` [RFC PATCH 3/6] migration: Add multi-thread compress ops Zeyu Jin
2020-11-09 9:08 ` [RFC PATCH 4/6] migration: Add zstd support in multi-thread compression Zeyu Jin
2020-11-09 9:08 ` Zeyu Jin [this message]
2020-11-09 9:08 ` [RFC PATCH 6/6] doc: Update multi-thread compression doc Zeyu Jin
2020-11-16 1:11 ` [RFC PATCH 0/6] migration: Multi-thread compression with zstd method Zeyu Jin
-- strict thread matches above, loose matches on Subject: below --
2020-11-27 7:42 [RFC PATCH 5/6] migration: Add compress_level sanity check Zeyu Jin
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=20201109090850.2424-6-jinzeyu@huawei.com \
--to=jinzeyu@huawei.com \
--cc=dgilbert@redhat.com \
--cc=fangying1@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhang.zhanghailiang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.