diff mbox

[5/8] intel_iommu: hmp: allow "-c" for "info iommu"

Message ID 1498554219-4942-6-git-send-email-peterx@redhat.com
State New
Headers show

Commit Message

Peter Xu June 27, 2017, 9:03 a.m. UTC
New parameter "-c" for it to clear statistics. Other platforms can
selectively support this (though none yet).

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hmp-commands-info.hx  | 4 ++--
 hw/i386/intel_iommu.c | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index a39243d..2add941 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -803,8 +803,8 @@  ETEXI
 
     {
         .name       = "iommu",
-        .args_type  = "",
-        .params     = "",
+        .args_type  = "clear_stats:-c",
+        .params     = "[-c]",
         .help       = "Display system IOMMU information",
         .cmd        = hmp_info_iommu,
     },
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 45d0919..72b39f0 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3008,6 +3008,7 @@  static void vtd_info_dump(X86IOMMUState *x86_iommu, Monitor *mon,
                           const QDict *qdict)
 {
     IntelIOMMUState *s = INTEL_IOMMU_DEVICE(x86_iommu);
+    bool clear_stats = qdict_get_try_bool(qdict, "clear_stats", false);
 
     DUMP("Version: %d\n", 1);
     DUMP("Cap: 0x%"PRIx64"\n", s->cap);
@@ -3047,6 +3048,10 @@  static void vtd_info_dump(X86IOMMUState *x86_iommu, Monitor *mon,
     DUMP("Misc: next_frr=%d, context_gen=%d, buggy_eim=%d\n",
          s->next_frcd_reg, s->context_cache_gen, s->buggy_eim);
     DUMP("      iotlb_size=%d\n", g_hash_table_size(s->iotlb));
+
+    if (clear_stats) {
+        vtd_reset_stats(s);
+    }
 }
 #undef DUMP