1 Star 0 Fork 70

jiangpengjuj/libvirt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemuMonitorJSONSetMigrationParams-Take-double-pointe.patch 4.40 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-03-24 14:54 . update patch with openeuler !58
From 3c3f616a826b5c0cd1a01faafa2f1f6c71494e05 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 30 Nov 2020 15:17:34 +0100
Subject: [PATCH 01/16] qemuMonitorJSONSetMigrationParams: Take double pointer
for @params
This allows simplification of the caller as well as will enable a later
refactor of qemuMonitorJSONMakeCommandInternal.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/qemu/qemu_migration_params.c | 9 +++------
src/qemu/qemu_monitor.c | 11 +++--------
src/qemu/qemu_monitor.h | 2 +-
src/qemu/qemu_monitor_json.c | 5 +++--
src/qemu/qemu_monitor_json.h | 2 +-
5 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 6953badcfe..df9d5d205a 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -880,12 +880,9 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
if (!(params = qemuMigrationParamsToJSON(migParams)))
goto cleanup;
- if (virJSONValueObjectKeysNumber(params) > 0) {
- rc = qemuMonitorSetMigrationParams(priv->mon, params);
- params = NULL;
- if (rc < 0)
- goto cleanup;
- }
+ if (virJSONValueObjectKeysNumber(params) > 0 &&
+ qemuMonitorSetMigrationParams(priv->mon, &params) < 0)
+ goto cleanup;
ret = 0;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 9f4432ab3a..58a8741bb8 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2463,22 +2463,17 @@ qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
* @mon: Pointer to the monitor object.
* @params: Migration parameters.
*
- * The @params object is consumed and should not be referenced by the caller
- * after this function returns.
+ * The @params object is consumed and cleared on success and some errors.
*
* Returns 0 on success, -1 on error.
*/
int
qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
- virJSONValuePtr params)
+ virJSONValuePtr *params)
{
- QEMU_CHECK_MONITOR_GOTO(mon, error);
+ QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONSetMigrationParams(mon, params);
-
- error:
- virJSONValueFree(params);
- return -1;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 83a33b5b0f..561417f6c1 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -754,7 +754,7 @@ int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr *params);
int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
- virJSONValuePtr params);
+ virJSONValuePtr *params);
typedef enum {
QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 199b73eafe..03af998cb0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3465,12 +3465,13 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
int
qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
- virJSONValuePtr params)
+ virJSONValuePtr *params)
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
+ virJSONValuePtr par = g_steal_pointer(params);
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", params)))
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", par)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index dd25e5d6e6..af52372a93 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -142,7 +142,7 @@ int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
int qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
virJSONValuePtr *params);
int qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
- virJSONValuePtr params);
+ virJSONValuePtr *params);
int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
qemuMonitorMigrationStatsPtr stats,
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiangpengjuj/libvirt.git
git@gitee.com:jiangpengjuj/libvirt.git
jiangpengjuj
libvirt
libvirt
master

搜索帮助