]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
tools/kvm_stat: stop ignoring unhandled arguments
authorStefan Raspl <stefan.raspl@de.ibm.com>
Mon, 11 Dec 2017 11:25:27 +0000 (12:25 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Dec 2017 08:25:46 +0000 (09:25 +0100)
Unhandled arguments, which could easily include typos, are simply
ignored. We should be strict to avoid undetected typos.
To reproduce start kvm_stat with an extra argument, e.g.
'kvm_stat -d bnuh5ol' and note that this will actually work.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/kvm/kvm_stat/kvm_stat

index bf65531570f5ce252c97306b9add28653ca22e22..aa3bc47af1d07cceec11b037e7d2990f67805f10 100755 (executable)
@@ -1517,7 +1517,9 @@ Press any other key to refresh statistics immediately.
                          help='restrict statistics to guest by name',
                          callback=cb_guest_to_pid,
                          )
-    (options, _) = optparser.parse_args(sys.argv)
+    options, unkn = optparser.parse_args(sys.argv)
+    if len(unkn) != 1:
+        sys.exit('Error: Extra argument(s): ' + ' '.join(unkn[1:]))
     try:
         # verify that we were passed a valid regex up front
         re.compile(options.fields)