[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8] arm/kvm: Enable support for KVM_ARM_VCPU_PMU_V3_FILTER
From: |
Shaoqin Huang |
Subject: |
Re: [PATCH v8] arm/kvm: Enable support for KVM_ARM_VCPU_PMU_V3_FILTER |
Date: |
Fri, 29 Mar 2024 11:45:21 +0800 |
User-agent: |
Mozilla Thunderbird |
Hi Daniel,
On 3/25/24 16:55, Daniel P. Berrangé wrote:
On Mon, Mar 25, 2024 at 01:35:58PM +0800, Shaoqin Huang wrote:
Hi Daniel,
Thanks for your reviewing. I see your comments in the v7.
I have some doubts about what you said about the QAPI. Do you want me to
convert the current design into the QAPI parsing like the
IOThreadVirtQueueMapping? And we need to add new json definition in the
qapi/ directory?
I have defined the QAPI for kvm-pmu-filter like below:
+##
+# @FilterAction:
+#
+# The Filter Action
+#
+# @a: Allow
+#
+# @d: Disallow
+#
+# Since: 9.0
+##
+{ 'enum': 'FilterAction',
+ 'data': [ 'a', 'd' ] }
+
+##
+# @SingleFilter:
+#
+# Lazy
+#
+# @action: the action
+#
+# @start: the start
+#
+# @end: the end
+#
+# Since: 9.0
+##
+
+{ 'struct': 'SingleFilter',
+ 'data': { 'action': 'FilterAction', 'start': 'int', 'end': 'int' } }
+
+##
+# @KVMPMUFilter:
+#
+# Lazy
+#
+# @filter: the filter
+#
+# Since: 9.0
+##
+
+{ 'struct': 'KVMPMUFilter',
+ 'data': { 'filter': ['SingleFilter'] }}
And I guess I can use it by adding code like below:
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -1206,3 +1206,35 @@ const PropertyInfo
qdev_prop_iothread_vq_mapping_list = {
.set = set_iothread_vq_mapping_list,
.release = release_iothread_vq_mapping_list,
};
+
+/* --- kvm-pmu-filter ---*/
+
+static void get_kvm_pmu_filter(Object *obj, Visitor *v,
+ const char *name, void *opaque, Error **errp)
+{
+ KVMPMUFilter **prop_ptr = object_field_prop_ptr(obj, opaque);
+
+ visit_type_KVMPMUFilter(v, name, prop_ptr, errp);
+}
+
+static void set_kvm_pmu_filter(Object *obj, Visitor *v,
+ const char *name, void *opaque, Error **errp)
+{
+ KVMPMUFilter **prop_ptr = object_field_prop_ptr(obj, opaque);
+ KVMPMUFilter *list;
+
+ printf("running the %s\n", __func__);
+ if (!visit_type_KVMPMUFilter(v, name, &list, errp)) {
+ return;
+ }
+
+ printf("The name is %s\n", name);
+ *prop_ptr = list;
+}
+
+const PropertyInfo qdev_prop_kvm_pmu_filter = {
+ .name = "KVMPMUFilter",
+ .description = "der der",
+ .get = get_kvm_pmu_filter,
+ .set = set_kvm_pmu_filter,
+};
+#define DEFINE_PROP_KVM_PMU_FILTER(_name, _state, _field) \
+ DEFINE_PROP(_name, _state, _field, qdev_prop_kvm_pmu_filter, \
+ KVMPMUFilter *)
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -2439,6 +2441,7 @@ static Property arm_cpu_properties[] = {
mp_affinity, ARM64_AFFINITY_INVALID),
DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID),
DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1),
+ DEFINE_PROP_KVM_PMU_FILTER("kvm-pmu-filter", ARMCPU, kvm_pmu_filter),
DEFINE_PROP_END_OF_LIST()
};
And I guess I can use the new json format input like below:
qemu-system-aarch64 \
-cpu host, '{"filter": [{"action": "a", "start": 0x10, "end": "0x11"}]}'
But it doesn't work. It seems like because the -cpu option doesn't
support json format parameter.
Maybe I'm wrong. So I want to double check with if the -cpu option
support json format nowadays?
If the -cpu option doesn't support json format, how I can use the QAPI
for kvm-pmu-filter property?
Thanks,
Shaoqin
Yes, you would define a type in the qapi dir similar to how is
done for IOThreadVirtQueueMapping, and then you can use that
in the property setter method.
With regards,
Daniel
--
Shaoqin