1 Star 0 Fork 70

jiangpengjuj/libvirt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemuBuildNumaArgStr-Switch-order-of-if-and-for.patch 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-03-11 20:33 . update patch with openeuler !55
From 6a0f76d72b231bf0baacf70d715aad387476ac98 Mon Sep 17 00:00:00 2001
From: xiaojin Yang <yangxiaojin2@huawei.com>
Date: Fri, 11 Mar 2022 16:03:02 +0800
Subject: [PATCH 7/8] qemuBuildNumaArgStr: Switch order of if() and for()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When building -numa command line there is a for() loop that
builds '-numa memdev=' for each guest NUMA node. And also
records in a local variable whether any of memory-object-*
backends must be used to satisfy desired config. Well, instead of
checking in each iteration whether corresponding capabilities are
set, we can do swap if() and for() and check only once.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Xiaojin Yang <yangxiaojin2@huawei.com>
---
src/qemu/qemu_command.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dae6b5a7f9..f9b6d56209 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7419,11 +7419,11 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
/* using of -numa memdev= cannot be combined with -numa mem=, thus we
* need to check which approach to use */
- for (i = 0; i < ncells; i++) {
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
+ for (i = 0; i < ncells; i++) {
if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv,
&nodeBackends[i])) < 0)
goto cleanup;
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiangpengjuj/libvirt.git
git@gitee.com:jiangpengjuj/libvirt.git
jiangpengjuj
libvirt
libvirt
master

搜索帮助