1 Star 0 Fork 70

mds.lanruo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
migration-dirtyrate-Introduce-domdirtyrate-calc-virs.patch 3.73 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-11-03 20:05 . libvirt: support migration dirtyrate
From f254d3fe1e7b50c850c634adf554e4e384a4abad Mon Sep 17 00:00:00 2001
From: Hao Wang <[email protected]>
Date: Tue, 16 Mar 2021 20:32:47 +0800
Subject: [PATCH 3/7] migration/dirtyrate: Introduce domdirtyrate-calc virsh
api
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduce domdirtyrate-calc virsh api to start calculating domain's
memory dirty rate:
# virsh domdirtyrate-calc <domain> [--seconds <sec>]
cherry-pick from a2ae2dad062e8b23efac132488ce6aaea388de51
Signed-off-by: Hao Wang <[email protected]>
Signed-off-by: Hyman Huang(黄勇) <[email protected]>
Reviewed-by: Michal Privoznik <[email protected]>
---
docs/manpages/virsh.rst | 17 ++++++++++++
tools/virsh-domain.c | 58 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index dc404ddfe8..b44e8f9301 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -1696,6 +1696,23 @@ states other than "ok" or "error" the command also prints number of
seconds elapsed since the control interface entered its current state.
+domdirtyrate-calc
+-----------------
+
+**Syntax:**
+
+::
+
+ domdirtyrate-calc <domain> [--seconds <sec>]
+
+Calculate an active domain's memory dirty rate which may be expected by
+user in order to decide whether it's proper to be migrated out or not.
+The ``seconds`` parameter can be used to calculate dirty rate in a
+specific time which allows 60s at most now and would be default to 1s
+if missing. The calculated dirty rate information is available by calling
+'domstats --dirtyrate'.
+
+
domdisplay
----------
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index b5375ebd3e..0d42496898 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -14399,6 +14399,58 @@ cmdHotpatch(vshControl *ctl,
return true;
}
+/*
+ * "domdirtyrate" command
+ */
+static const vshCmdInfo info_domdirtyrate_calc[] = {
+ {.name = "help",
+ .data = N_("Calculate a vm's memory dirty rate")
+ },
+ {.name = "desc",
+ .data = N_("Calculate memory dirty rate of a domain in order to "
+ "decide whether it's proper to be migrated out or not.\n"
+ "The calculated dirty rate information is available by "
+ "calling 'domstats --dirtyrate'.")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_domdirtyrate_calc[] = {
+ VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+ {.name = "seconds",
+ .type = VSH_OT_INT,
+ .help = N_("calculate memory dirty rate within specified seconds, "
+ "the supported value range from 1 to 60, default to 1.")
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom = NULL;
+ int seconds = 1; /* the default value is 1 */
+ bool ret = false;
+
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0)
+ goto cleanup;
+
+ if (virDomainStartDirtyRateCalc(dom, seconds, 0) < 0)
+ goto cleanup;
+
+ vshPrintExtra(ctl, _("Start to calculate domain's memory "
+ "dirty rate successfully.\n"));
+ ret = true;
+
+ cleanup:
+ virshDomainFree(dom);
+ return ret;
+}
+
+
const vshCmdDef domManagementCmds[] = {
{.name = "attach-device",
.handler = cmdAttachDevice,
@@ -15032,5 +15084,11 @@ const vshCmdDef domManagementCmds[] = {
.info = info_hotpatch,
.flags = 0
},
+ {.name = "domdirtyrate-calc",
+ .handler = cmdDomDirtyRateCalc,
+ .opts = opts_domdirtyrate_calc,
+ .info = info_domdirtyrate_calc,
+ .flags = 0
+ },
{.name = NULL}
};
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdslanruo/libvirt.git
[email protected]:mdslanruo/libvirt.git
mdslanruo
libvirt
libvirt
master

搜索帮助