代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/qemu 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 84780210ac31e430d59b0c6d3d9f522c626b6380 Mon Sep 17 00:00:00 2001
From: Chuan Zheng <zhengchuan@huawei.com>
Date: Sat, 30 Jan 2021 16:23:15 +0800
Subject: [PATCH 13/14] migration: Add compress_level sanity check
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: Chuan Zheng <zhengchuan@huawei.com>
Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
migration/migration.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 07dc059251..f86dd8cccd 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1320,14 +1320,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)) {
+ if (params->has_compress_level && !compress_level_check(params, errp)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
"a value between 0 and 9");
return false;
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。