Skip to content

Commit 5288bee

Browse files
committed
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* Boolean statistics for KVM * Fix build on Haiku # gpg: Signature made Tue 19 Jul 2022 10:32:34 BST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "[email protected]" # gpg: Good signature from "Paolo Bonzini <[email protected]>" [full] # gpg: aka "Paolo Bonzini <[email protected]>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: util: Fix broken build on Haiku kvm: add support for boolean statistics monitor: add support for boolean statistics Signed-off-by: Peter Maydell <[email protected]>
2 parents fe16c83 + 3746b8c commit 5288bee

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

accel/kvm/kvm-all.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3769,6 +3769,7 @@ static StatsList *add_kvmstat_entry(struct kvm_stats_desc *pdesc,
37693769
case KVM_STATS_UNIT_BYTES:
37703770
case KVM_STATS_UNIT_CYCLES:
37713771
case KVM_STATS_UNIT_SECONDS:
3772+
case KVM_STATS_UNIT_BOOLEAN:
37723773
break;
37733774
default:
37743775
return stats_list;
@@ -3787,7 +3788,10 @@ static StatsList *add_kvmstat_entry(struct kvm_stats_desc *pdesc,
37873788
stats->name = g_strdup(pdesc->name);
37883789
stats->value = g_new0(StatsValue, 1);;
37893790

3790-
if (pdesc->size == 1) {
3791+
if ((pdesc->flags & KVM_STATS_UNIT_MASK) == KVM_STATS_UNIT_BOOLEAN) {
3792+
stats->value->u.boolean = *stats_data;
3793+
stats->value->type = QTYPE_QBOOL;
3794+
} else if (pdesc->size == 1) {
37913795
stats->value->u.scalar = *stats_data;
37923796
stats->value->type = QTYPE_QNUM;
37933797
} else {
@@ -3835,6 +3839,10 @@ static StatsSchemaValueList *add_kvmschema_entry(struct kvm_stats_desc *pdesc,
38353839
switch (pdesc->flags & KVM_STATS_UNIT_MASK) {
38363840
case KVM_STATS_UNIT_NONE:
38373841
break;
3842+
case KVM_STATS_UNIT_BOOLEAN:
3843+
schema_entry->value->has_unit = true;
3844+
schema_entry->value->unit = STATS_UNIT_BOOLEAN;
3845+
break;
38383846
case KVM_STATS_UNIT_BYTES:
38393847
schema_entry->value->has_unit = true;
38403848
schema_entry->value->unit = STATS_UNIT_BYTES;

linux-headers/linux/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,7 @@ struct kvm_stats_header {
20312031
#define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)
20322032
#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
20332033
#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
2034+
#define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
20342035
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES
20352036

20362037
#define KVM_STATS_BASE_SHIFT 8

monitor/hmp-cmds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,8 @@ static void print_stats_results(Monitor *mon, StatsTarget target,
23422342

23432343
if (stats_value->type == QTYPE_QNUM) {
23442344
monitor_printf(mon, ": %" PRId64 "\n", stats_value->u.scalar);
2345+
} else if (stats_value->type == QTYPE_QBOOL) {
2346+
monitor_printf(mon, ": %s\n", stats_value->u.boolean ? "yes" : "no");
23452347
} else if (stats_value->type == QTYPE_QLIST) {
23462348
uint64List *list;
23472349
int i;

qapi/stats.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
# @bytes: stat reported in bytes.
3939
# @seconds: stat reported in seconds.
4040
# @cycles: stat reported in clock cycles.
41+
# @boolean: stat is a boolean value.
4142
#
4243
# Since: 7.1
4344
##
4445
{ 'enum' : 'StatsUnit',
45-
'data' : [ 'bytes', 'seconds', 'cycles' ] }
46+
'data' : [ 'bytes', 'seconds', 'cycles', 'boolean' ] }
4647

4748
##
4849
# @StatsProvider:
@@ -123,6 +124,7 @@
123124
##
124125
{ 'alternate': 'StatsValue',
125126
'data': { 'scalar': 'uint64',
127+
'boolean': 'bool',
126128
'list': [ 'uint64' ] } }
127129

128130
##

0 commit comments

Comments
 (0)