libvirt/virsh-Add-mode-option-to-domdirtyrate-calc-virsh-api.patch
Jiabo Feng 46011ccf7e libvirt update to version 6.2.0-65:
- remote: fix double free of migration params on error
- qemu: avoid deadlock in qemuDomainObjStopWorker We are dropping the only reference here so that the event loop thread is going to be exited synchronously. In order to avoid deadlocks we need to unlock the VM so that any handler being called can finish execution and thus even loop thread be finished too.
- virsh: add tmm main command word Add tmm command word into virsh tool to call get tmm memory info API. It makes virsh can use tmm main commmand to show tmm memory info on console. This command requires specific kernel and a kernel driver to make sure its regular function. If runnning environment missing the above reliance, this command will show error result on console.
- libvirt: add get tmm memory info API and libvirtd RPC Add the get tmm memory info API into libvirt-host. Also should add the RPC calls into libvirtd for API calling.
- libvirt: support the virtCCA feature Add cvm parameter into the type of LaunchSecurity which is a optional filed for libvirt xml. Its purpose is to pass the cvm parameter through to qemu. Also this patch support virsh edit to save cvm parameter into libvirt temporary xml.
- qemu_driver: Add calc_mode for dirtyrate statistics
- virsh: Add mode option to domdirtyrate-calc virsh api
- qemu: Generate command line for dirty-ring-size
- qemu: support dirty ring feature
- conf: Turn virDomainDef.kvm_features into a struct
- qemu_validate: Allow kvm hint-dedicated on non-passthrough VMs
- virDomainFeaturesKVMDefParse: Remove tautological "if"
- virDomainFeaturesKVMDefParse: Remove tautological "switch"
- virxml: Add virXMLPropUInt
- virxml: Add virXMLPropInt
- virxml: Add virXMLPropTristateSwitch
- virxml: Add virXMLPropTristateBool
- virDomainFeaturesKVMDefParse: Remove ctxt
- virDomainFeaturesDefParse: Factor out KVM parsing into separate function
- internal.h: Introduce and use VIR_IS_POW2()
- hotpatch: if hotpatch_path not in qemu.conf,the hotpatch doesn't antoload

Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
2024-06-13 11:02:43 +08:00

179 lines
6.4 KiB
Diff

From ff93e58df5e280d0d1b89a09999e001a5b4e1f01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?=
<huangy81@chinatelecom.cn>
Date: Sun, 20 Feb 2022 21:28:14 +0800
Subject: [PATCH] virsh: Add mode option to domdirtyrate-calc virsh api
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Extend domdirtyrate-calc virsh api with mode option, either
of these three options "page-sampling,dirty-bitmap,dirty-ring"
can be specified when calculating dirty page rate.
Signed-off-by: Hyman Huang(榛勫媷) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Shaokun Wei <weishaokun@kylinos.cn>
---
docs/manpages/virsh.rst | 7 ++++--
tools/virsh-completer-domain.c | 19 +++++++++++++++
tools/virsh-completer-domain.h | 5 ++++
tools/virsh-domain.c | 42 +++++++++++++++++++++++++++++++++-
tools/virsh-domain.h | 9 ++++++++
5 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index d7c8b2dfb2..c5be6dec8c 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -1704,13 +1704,16 @@ domdirtyrate-calc
::
domdirtyrate-calc <domain> [--seconds <sec>]
+ --mode=[page-sampling | dirty-bitmap | dirty-ring]
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'.
+if missing. These three *page-sampling, dirty-bitmap, dirty-ring* modes
+are mutually exclusive and alternative when specify calculation mode,
+*page-sampling* is the default mode if missing. The calculated dirty
+rate information is available by calling 'domstats --dirtyrate'.
domdisplay
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index 7e155d9ee2..c21fcb1941 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -335,3 +335,22 @@ virshDomainHostnameSourceCompleter(vshControl *ctl G_GNUC_UNUSED,
return ret;
}
+
+
+char **
+virshDomainDirtyRateCalcModeCompleter(vshControl *ctl G_GNUC_UNUSED,
+ const vshCmd *cmd G_GNUC_UNUSED,
+ unsigned int flags)
+{
+ char **ret = NULL;
+ size_t i;
+
+ virCheckFlags(0, NULL);
+
+ ret = g_new0(char *, VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST + 1);
+
+ for (i = 0; i < VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST; i++)
+ ret[i] = g_strdup(virshDomainDirtyRateCalcModeTypeToString(i));
+
+ return ret;
+}
diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h
index b00b05e3bd..95773086f7 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -62,3 +62,8 @@ virshDomainInterfaceAddrSourceCompleter(vshControl *ctl,
char ** virshDomainHostnameSourceCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
+
+char **
+virshDomainDirtyRateCalcModeCompleter(vshControl *ctl,
+ const vshCmd *cmd,
+ unsigned int flags);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 595a210493..c8bd61d5b7 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -14443,15 +14443,29 @@ static const vshCmdOptDef opts_domdirtyrate_calc[] = {
.help = N_("calculate memory dirty rate within specified seconds, "
"the supported value range from 1 to 60, default to 1.")
},
+ {.name = "mode",
+ .type = VSH_OT_STRING,
+ .completer = virshDomainDirtyRateCalcModeCompleter,
+ .help = N_("dirty page rate calculation mode, either of these 3 options "
+ "'page-sampling, dirty-bitmap, dirty-ring' can be specified.")
+ },
{.name = NULL}
};
+VIR_ENUM_IMPL(virshDomainDirtyRateCalcMode,
+ VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST,
+ "page-sampling",
+ "dirty-bitmap",
+ "dirty-ring");
+
static bool
cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
int seconds = 1; /* the default value is 1 */
bool ret = false;
+ const char *modestr = NULL;
+ unsigned int flags = 0;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
@@ -14459,7 +14473,33 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0)
goto cleanup;
- if (virDomainStartDirtyRateCalc(dom, seconds, 0) < 0)
+ if (vshCommandOptStringReq(ctl, cmd, "mode", &modestr) < 0)
+ goto cleanup;
+
+ if (modestr) {
+ int mode = virshDomainDirtyRateCalcModeTypeFromString(modestr);
+
+ if (mode < 0) {
+ vshError(ctl, _("Unknown calculation mode '%s'"), modestr);
+ goto cleanup;
+ }
+
+ switch ((virshDomainDirtyRateCalcMode) mode) {
+ case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING:
+ flags |= VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING;
+ break;
+ case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_BITMAP:
+ flags |= VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP;
+ break;
+ case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING:
+ flags |= VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING;
+ break;
+ case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST:
+ break;
+ }
+ }
+
+ if (virDomainStartDirtyRateCalc(dom, seconds, flags) < 0)
goto cleanup;
vshPrintExtra(ctl, _("Start to calculate domain's memory "
diff --git a/tools/virsh-domain.h b/tools/virsh-domain.h
index 0d59c579d4..ab6147ca7f 100644
--- a/tools/virsh-domain.h
+++ b/tools/virsh-domain.h
@@ -38,4 +38,13 @@ typedef enum {
VIR_ENUM_DECL(virshDomainHostnameSource);
+typedef enum {
+ VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING,
+ VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_BITMAP,
+ VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING,
+ VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST,
+} virshDomainDirtyRateCalcMode;
+
+VIR_ENUM_DECL(virshDomainDirtyRateCalcMode);
+
extern const vshCmdDef domManagementCmds[];
--
2.27.0