1 Star 0 Fork 71

章北海/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemuMonitorJSONMakeCommandInternal-Clear-arguments-w.patch 4.47 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-03-24 14:54 . update patch with openeuler !58
From 18bcc450bbd6db8b124a8e6e218bde9846e5c3d5 Mon Sep 17 00:00:00 2001
From: Yan Wang <wangyan122@huawei.com>
Date: Thu, 24 Mar 2022 12:10:30 +0800
Subject: [PATCH 03/16] :qemuMonitorJSONMakeCommandInternal: Clear @arguments
when stolen
All callers of qemuMonitorJSONMakeCommandInternal will benefit from
making @arguments a double pointer and passing it to
virJSONValueObjectCreate directly which will clear it if it steals the
value.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Yan Wang <wangyan122@huawei.com>
---
src/qemu/qemu_monitor_json.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index ce7f35e2ca..cc6644c9c3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -546,20 +546,18 @@ qemuMonitorJSONTransactionAdd(virJSONValuePtr actions,
*
* Create a JSON object used on the QMP monitor to call a command.
*
- * Note that @arguments is always consumed and should not be referenced after
- * the call to this function.
+ * Note that @arguments is consumed and cleared.
*/
static virJSONValuePtr
qemuMonitorJSONMakeCommandInternal(const char *cmdname,
- virJSONValuePtr arguments)
+ virJSONValuePtr *arguments)
{
virJSONValuePtr ret = NULL;
ignore_value(virJSONValueObjectCreate(&ret,
"s:execute", cmdname,
- "A:arguments", &arguments, NULL));
+ "A:arguments", arguments, NULL));
- virJSONValueFree(arguments);
return ret;
}
@@ -569,7 +567,7 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
...)
{
virJSONValuePtr obj = NULL;
- virJSONValuePtr jargs = NULL;
+ g_autoptr(virJSONValue) jargs = NULL;
va_list args;
va_start(args, cmdname);
@@ -577,7 +575,7 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
if (virJSONValueObjectCreateVArgs(&jargs, args) < 0)
goto cleanup;
- obj = qemuMonitorJSONMakeCommandInternal(cmdname, jargs);
+ obj = qemuMonitorJSONMakeCommandInternal(cmdname, &jargs);
cleanup:
va_end(args);
@@ -3469,9 +3467,8 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValuePtr par = g_steal_pointer(params);
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", par)))
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", params)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
@@ -3998,9 +3995,8 @@ qemuMonitorJSONAddNetdev(qemuMonitorPtr mon,
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValuePtr pr = g_steal_pointer(props);
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("netdev_add", pr)))
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("netdev_add", props)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
@@ -4431,9 +4427,8 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon,
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValuePtr pr = g_steal_pointer(props);
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", pr)))
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
@@ -8812,9 +8807,8 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValuePtr pr = g_steal_pointer(props);
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", pr)))
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", props)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
@@ -8833,9 +8827,8 @@ qemuMonitorJSONBlockdevReopen(qemuMonitorPtr mon,
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValuePtr pr = g_steal_pointer(props);
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", pr)))
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dependent/libvirt.git
git@gitee.com:dependent/libvirt.git
dependent
libvirt
libvirt
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385