1 Star 0 Fork 71

章北海/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemu-Do-not-require-TSC-frequency-to-strictly-match-.patch 3.64 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-12-06 15:38 . libvirt update to version 6.2.0-47
From e24914dcbeb169f2608fd03cf6e701697844e065 Mon Sep 17 00:00:00 2001
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
Date: Wed, 30 Nov 2022 09:38:41 +0000
Subject: [PATCH 12/24] qemu: Do not require TSC frequency to strictly match
host Some CPUs provide a way to read exact TSC frequency, while measuring it
is required on other CPUs. However, measuring is never exact and the result
may slightly differ across reboots. For this reason both Linux kernel and
QEMU recently started allowing for guests TSC frequency to fall into +/- 250
ppm tolerance interval around the host TSC frequency.
Let's do the same to avoid unnecessary failures (esp. during migration)
in case the host frequency does not exactly match the frequency
configured in a domain XML.
https://bugzilla.redhat.com/show_bug.cgi?id=1839095
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: tangbin <tangbin_yewu@cmss.chinamobile.com>
(cherry-pick from d8e5b4560006590668d4669f54a46b08ec14c1a2)
---
src/qemu/qemu_process.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 360c4fcbb1..9cbf34a046 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5271,12 +5271,18 @@ qemuProcessStartValidateDisks(virDomainObjPtr vm,
}
+/* 250 parts per million (ppm) is a half of NTP threshold */
+#define TSC_TOLERANCE 250
+
static int
qemuProcessStartValidateTSC(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
size_t i;
unsigned long long freq = 0;
+ unsigned long long tolerance;
+ unsigned long long minFreq;
+ unsigned long long maxFreq;
virHostCPUTscInfoPtr tsc;
g_autoptr(virCPUDef) cpu = NULL;
@@ -5302,23 +5308,34 @@ qemuProcessStartValidateTSC(virQEMUDriverPtr driver,
}
tsc = cpu->tsc;
- VIR_DEBUG("Host TSC frequency %llu Hz, scaling %s",
- tsc->frequency, virTristateBoolTypeToString(tsc->scaling));
+ tolerance = tsc->frequency * TSC_TOLERANCE / 1000000;
+ minFreq = tsc->frequency - tolerance;
+ maxFreq = tsc->frequency + tolerance;
+
+ VIR_DEBUG("Host TSC frequency %llu Hz, scaling %s, tolerance +/- %llu Hz",
+ tsc->frequency, virTristateBoolTypeToString(tsc->scaling),
+ tolerance);
+
+ if (freq > minFreq && freq < maxFreq) {
+ VIR_DEBUG("Requested TSC frequency is within tolerance interval");
+ return 0;
+ }
- if (freq == tsc->frequency || tsc->scaling == VIR_TRISTATE_BOOL_YES)
+ if (tsc->scaling == VIR_TRISTATE_BOOL_YES)
return 0;
if (tsc->scaling == VIR_TRISTATE_BOOL_ABSENT) {
- VIR_DEBUG("TSC frequencies do not match and scaling support is "
- "unknown, QEMU will try and possibly fail later");
+ VIR_DEBUG("Requested TSC frequency falls outside tolerance range and "
+ "scaling support is unknown, QEMU will try and possibly "
+ "fail later");
return 0;
}
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Requested TSC frequency %llu Hz does not match "
- "host (%llu Hz) and TSC scaling is not supported "
- "by the host CPU"),
- freq, tsc->frequency);
+ _("Requested TSC frequency %llu Hz is outside tolerance "
+ "range ([%llu, %llu] Hz) around host frequency %llu Hz "
+ "and TSC scaling is not supported by the host CPU"),
+ freq, minFreq, maxFreq, tsc->frequency);
return -1;
}
--
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