1 Star 0 Fork 71

yoo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemu-Don-t-cache-domCaps-in-virQEMUDriverGetDomainCa.patch 3.28 KB
一键复制 编辑 原始数据 按行查看 历史
From 1fecad527ab391c045551f7b0d472bc2925683b3 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 13 Nov 2020 21:09:33 +0100
Subject: [PATCH 076/108] qemu: Don't cache domCaps in
virQEMUDriverGetDomainCapabilities()
Currently, whenever a domain capabilities is needed (fortunately,
after cleanup done by previous commits it is now only in
virConnectGetDomainCapabilities()), the object is stored in a
cache. But there is no invalidation mechanism for the cache
(except the implicit one - the cache is part of qemuCaps and thus
share its lifetime, but that is not enough). Therefore, if
something changes - for instance new firmware files are
installed, or old are removed these changes are not reflected in
the virConnectGetDomainCapabilities() output.
Originally, the caching was there because domCaps were used
during device XML validation and they were used a lot from our
test suite. But this is no longer the case. And therefore, we
don't need the cache and can construct fresh domCaps on each
virConnectGetDomainCapabilities() call.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1807198
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
(cherry picked from commit 7db61843b05a6e4295b1d2e27a3d86f162ef04a0)
---
src/qemu/qemu_conf.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index da2a1bdfe4..28319a1baf 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1397,11 +1397,8 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
/**
* virQEMUDriverGetDomainCapabilities:
*
- * Get a reference to the virDomainCapsPtr instance from the virQEMUCapsPtr
- * domCapsCache. If there's no domcaps in the cache, create a new instance,
- * add it to the cache, and return a reference.
- *
- * The caller must release the reference with virObjetUnref
+ * Get a reference to the virDomainCapsPtr instance. The caller
+ * must release the reference with virObjetUnref().
*
* Returns: a reference to a virDomainCapsPtr instance or NULL
*/
@@ -1413,15 +1410,19 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
virDomainVirtType virttype)
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+ g_autoptr(virDomainCaps) domCaps = NULL;
+ const char *path = virQEMUCapsGetBinary(qemuCaps);
+
+ if (!(domCaps = virDomainCapsNew(path, machine, arch, virttype)))
+ return NULL;
+
+ if (virQEMUCapsFillDomainCaps(qemuCaps, driver->hostarch,
+ domCaps, driver->privileged,
+ cfg->firmwares,
+ cfg->nfirmwares) < 0)
+ return NULL;
- return virQEMUCapsGetDomainCapsCache(qemuCaps,
- machine,
- arch,
- virttype,
- driver->hostarch,
- driver->privileged,
- cfg->firmwares,
- cfg->nfirmwares);
+ return g_steal_pointer(&domCaps);
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdLUbG/libvirt.git
git@gitee.com:mdLUbG/libvirt.git
mdLUbG
libvirt
libvirt
master

搜索帮助