- 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>
185 lines
7.2 KiB
Diff
185 lines
7.2 KiB
Diff
From e2db7dec8f43ac5ba8eb518a4d6cb6d58f9dee60 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:15 +0800
|
|
Subject: [PATCH] qemu_driver: Add calc_mode for dirtyrate statistics
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Add calc_mode for dirtyrate statistics retured by
|
|
virsh domstats --dirtyrate api, also add vcpu dirtyrate
|
|
if dirty-ring mode was used in last measurement.
|
|
|
|
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>
|
|
---
|
|
src/libvirt-domain.c | 6 ++++
|
|
src/qemu/qemu_driver.c | 22 +++++++++++++--
|
|
src/qemu/qemu_monitor.h | 10 +++++++
|
|
src/qemu/qemu_monitor_json.c | 53 ++++++++++++++++++++++++++++++++++++
|
|
4 files changed, 88 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
|
|
index 8f6ff2fe22..d2b2c89353 100644
|
|
--- a/src/libvirt-domain.c
|
|
+++ b/src/libvirt-domain.c
|
|
@@ -11697,6 +11697,12 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
|
|
* "dirtyrate.megabytes_per_second" - the calculated memory dirty rate in
|
|
* MiB/s as long long. It is produced
|
|
* only if the calc_status is measured.
|
|
+ * "dirtyrate.calc_mode" - the calculation mode used last measurement, either
|
|
+ * of these 3 'page-sampling,dirty-bitmap,dirty-ring'
|
|
+ * values returned.
|
|
+ * "dirtyrate.vcpu.<num>.megabytes_per_second" - the calculated memory dirty
|
|
+ * rate for a virtual cpu as
|
|
+ * unsigned long long.
|
|
*
|
|
* Note that entire stats groups or individual stat fields may be missing from
|
|
* the output in case they are not supported by the given hypervisor, are not
|
|
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
index 9cb14b01ad..77a139c66b 100644
|
|
--- a/src/qemu/qemu_driver.c
|
|
+++ b/src/qemu/qemu_driver.c
|
|
@@ -21723,11 +21723,27 @@ qemuDomainGetStatsDirtyRate(virQEMUDriverPtr driver,
|
|
"dirtyrate.calc_period") < 0)
|
|
return -1;
|
|
|
|
- if ((info.status == VIR_DOMAIN_DIRTYRATE_MEASURED) &&
|
|
- virTypedParamListAddLLong(params, info.dirtyRate,
|
|
- "dirtyrate.megabytes_per_second") < 0)
|
|
+ if (virTypedParamListAddString(params,
|
|
+ qemuMonitorDirtyRateCalcModeTypeToString(info.mode),
|
|
+ "dirtyrate.calc_mode") < 0)
|
|
return -1;
|
|
|
|
+ if (info.status == VIR_DOMAIN_DIRTYRATE_MEASURED) {
|
|
+ if (virTypedParamListAddLLong(params, info.dirtyRate,
|
|
+ "dirtyrate.megabytes_per_second") < 0)
|
|
+ return -1;
|
|
+
|
|
+ if (info.mode == QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_RING) {
|
|
+ size_t i;
|
|
+ for (i = 0; i < info.nvcpus; i++) {
|
|
+ if (virTypedParamListAddULLong(params, info.rates[i].value,
|
|
+ "dirtyrate.vcpu.%d.megabytes_per_second",
|
|
+ info.rates[i].idx) < 0)
|
|
+ return -1;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
|
|
index 1c6b001872..949a04f60f 100644
|
|
--- a/src/qemu/qemu_monitor.h
|
|
+++ b/src/qemu/qemu_monitor.h
|
|
@@ -1464,6 +1464,12 @@ qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon,
|
|
int seconds,
|
|
qemuMonitorDirtyRateCalcMode mode);
|
|
|
|
+typedef struct _qemuMonitorDirtyRateVcpu qemuMonitorDirtyRateVcpu;
|
|
+struct _qemuMonitorDirtyRateVcpu {
|
|
+ int idx; /* virtual cpu index */
|
|
+ unsigned long long value; /* virtual cpu dirty page rate in MB/s */
|
|
+};
|
|
+
|
|
typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo;
|
|
typedef qemuMonitorDirtyRateInfo *qemuMonitorDirtyRateInfoPtr;
|
|
|
|
@@ -1473,6 +1479,10 @@ struct _qemuMonitorDirtyRateInfo {
|
|
int calcTime; /* the period of dirtyrate calculation */
|
|
long long startTime; /* the start time of dirtyrate calculation */
|
|
long long dirtyRate; /* the dirtyrate in MiB/s */
|
|
+ qemuMonitorDirtyRateCalcMode mode; /* calculation mode used in
|
|
+ last measurement */
|
|
+ size_t nvcpus; /* number of virtual cpu */
|
|
+ qemuMonitorDirtyRateVcpu *rates; /* array of dirty page rate */
|
|
};
|
|
|
|
int
|
|
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
|
index 8f040bbe59..e7134d90b6 100644
|
|
--- a/src/qemu/qemu_monitor_json.c
|
|
+++ b/src/qemu/qemu_monitor_json.c
|
|
@@ -9450,12 +9450,46 @@ VIR_ENUM_IMPL(qemuMonitorDirtyRateStatus,
|
|
"measuring",
|
|
"measured");
|
|
|
|
+static int
|
|
+qemuMonitorJSONExtractVcpuDirtyRate(virJSONValue *data,
|
|
+ qemuMonitorDirtyRateInfo *info)
|
|
+{
|
|
+ size_t nvcpus;
|
|
+ size_t i;
|
|
+
|
|
+ nvcpus = virJSONValueArraySize(data);
|
|
+ info->nvcpus = nvcpus;
|
|
+ info->rates = g_new0(qemuMonitorDirtyRateVcpu, nvcpus);
|
|
+
|
|
+ for (i = 0; i < nvcpus; i++) {
|
|
+ virJSONValue *entry = virJSONValueArrayGet(data, i);
|
|
+ if (virJSONValueObjectGetNumberInt(entry, "id",
|
|
+ &info->rates[i].idx) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
+ _("query-dirty-rate reply was missing 'id' data"));
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (virJSONValueObjectGetNumberUlong(entry, "dirty-rate",
|
|
+ &info->rates[i].value) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
+ _("query-dirty-rate reply was missing 'dirty-rate' data"));
|
|
+ return -1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int
|
|
qemuMonitorJSONExtractDirtyRateInfo(virJSONValuePtr data,
|
|
qemuMonitorDirtyRateInfoPtr info)
|
|
{
|
|
const char *statusstr;
|
|
+ const char *modestr;
|
|
int status;
|
|
+ int mode;
|
|
+ virJSONValue *rates = NULL;
|
|
|
|
if (!(statusstr = virJSONValueObjectGetString(data, "status"))) {
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
@@ -9492,6 +9526,25 @@ qemuMonitorJSONExtractDirtyRateInfo(virJSONValuePtr data,
|
|
return -1;
|
|
}
|
|
|
|
+ if ((modestr = virJSONValueObjectGetString(data, "mode"))) {
|
|
+ if ((mode = qemuMonitorDirtyRateCalcModeTypeFromString(modestr)) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("Unknown dirty page rate calculation mode: %s"), modestr);
|
|
+ return -1;
|
|
+ }
|
|
+ info->mode = mode;
|
|
+ } else {
|
|
+ info->mode = QEMU_MONITOR_DIRTYRATE_CALC_MODE_PAGE_SAMPLING;
|
|
+ }
|
|
+
|
|
+ if ((rates = virJSONValueObjectGetArray(data, "vcpu-dirty-rate"))) {
|
|
+ if (qemuMonitorJSONExtractVcpuDirtyRate(rates, info) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
+ _("query-dirty-rate parsing 'vcpu-dirty-rate' in failure"));
|
|
+ return -1;
|
|
+ }
|
|
+ }
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|