Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6266929rwb; Tue, 9 Aug 2022 12:04:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4FCf3+iSkFCmDuai92qjTdL55BoXNM2Ym63fIUJlscBfnBL2jDjJoVs+KyHM/bIcYaVAup X-Received: by 2002:a17:90a:a404:b0:1ee:e545:288b with SMTP id y4-20020a17090aa40400b001eee545288bmr26458780pjp.142.1660071875359; Tue, 09 Aug 2022 12:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071875; cv=none; d=google.com; s=arc-20160816; b=Hk3XA4KCnx6MgCudY4xgIYzceVGX5CoJcVocr4tatynblEJPGuQmyTvzEuviJCTBfH Ktr9j50fcF+B/eBiPfGN48GNSC33k/obYT5nNqsKJLCT+VcwGlzf1XwCsR7D4Cnc7vaM kfXuizqeBsm3othxa+iLnpsbDzWJaMaqj36D4ai3f9cxxyBbmcIUHJ+owi6oYI+8L+q8 /G6FEs7Hdq+VGiM02uy17raBGNG1f65ggWcIUVl1xRsZ+h1nR0ll7lBkrwWepsWBZ6f6 j0cXkNf3yNXJZTzaAhumg2GMjNEPd04bEQVGuWBwq4xIPDTFIobTRZ3U7hM2+NuBSGcL IPag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ySX82q4fkYgMRmyW+HZunt0XCj62v1/CIdTe+coBj2k=; b=QL4YNj/bykQMShG2MV95KqQDgtTNoPP4hXTr1sElSuD77iFxNIDRKgKIuSnJAgSRLO iP13I7bVJ49wlsetFTLxv0o5xmfyHvxnecIelZoTduaYO690y8X2hOLnUSkohEFDfALo iijwlmSFvBrq2GVub/bHKQ4wf3Yr2LD7sKRdMZ3Ya/gySkLOagl9BHEd+jSD7wWDXdAG Sazv/Bhr6xdJU8ZBzTjuuj0cNb1TjplDFMZqUqfv9TVmFJe1mzhNrtR5JRylm0EhxiwE Z28kOFIf8U5tPE7zkKfm9wvJGPt6+iN7wKBzr2kwf11sxOe5BhEMU6TH91aoMVyyaV7V ZQZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fh3ataau; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a170902d34c00b001708e1bb3b0si3290517plk.419.2022.08.09.12.04.12; Tue, 09 Aug 2022 12:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fh3ataau; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344879AbiHISMw (ORCPT + 99 others); Tue, 9 Aug 2022 14:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345429AbiHISLB (ORCPT ); Tue, 9 Aug 2022 14:11:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE852A729; Tue, 9 Aug 2022 11:04:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 518986103F; Tue, 9 Aug 2022 18:04:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0D8AC43141; Tue, 9 Aug 2022 18:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068261; bh=B6I9ywm6he85dPxmbtWsc9fEdjf0MDmn5OyItYXcUX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fh3ataauM/32RBdX4ttFdIRk2rSzAmddsjy6slcO3xcymeUliqXrACjcytS/RKALz PClo085me1NQ8KS+e/wm+63jX5YYBYS78EizOoA6CG4c8Du7kcOYpwXpbzHimr7Vzn Ywzd/MfpFJPsYBUe4AATNwzC3+FlqUZEqT2zsJc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Klochkov , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 11/23] tools/kvm_stat: fix display of error when multiple processes are found Date: Tue, 9 Aug 2022 20:00:29 +0200 Message-Id: <20220809175513.273395241@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175512.853274191@linuxfoundation.org> References: <20220809175512.853274191@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Klochkov [ Upstream commit 933b5f9f98da29af646b51b36a0753692908ef64 ] Instead of printing an error message, kvm_stat script fails when we restrict statistics to a guest by its name and there are multiple guests with such name: # kvm_stat -g my_vm Traceback (most recent call last): File "/usr/bin/kvm_stat", line 1819, in main() File "/usr/bin/kvm_stat", line 1779, in main options = get_options() File "/usr/bin/kvm_stat", line 1718, in get_options options = argparser.parse_args() File "/usr/lib64/python3.10/argparse.py", line 1825, in parse_args args, argv = self.parse_known_args(args, namespace) File "/usr/lib64/python3.10/argparse.py", line 1858, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File "/usr/lib64/python3.10/argparse.py", line 2067, in _parse_known_args start_index = consume_optional(start_index) File "/usr/lib64/python3.10/argparse.py", line 2007, in consume_optional take_action(action, args, option_string) File "/usr/lib64/python3.10/argparse.py", line 1935, in take_action action(self, namespace, argument_values, option_string) File "/usr/bin/kvm_stat", line 1649, in __call__ ' to specify the desired pid'.format(" ".join(pids))) TypeError: sequence item 0: expected str instance, int found To avoid this, it's needed to convert pids int values to strings before pass them to join(). Signed-off-by: Dmitry Klochkov Message-Id: <20220614121141.160689-1-kdmitry556@gmail.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- tools/kvm/kvm_stat/kvm_stat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index b0bf56c5f120..a1efcfbd8b9e 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat @@ -1646,7 +1646,8 @@ Press any other key to refresh statistics immediately. .format(values)) if len(pids) > 1: sys.exit('Error: Multiple processes found (pids: {}). Use "-p"' - ' to specify the desired pid'.format(" ".join(pids))) + ' to specify the desired pid' + .format(" ".join(map(str, pids)))) namespace.pid = pids[0] argparser = argparse.ArgumentParser(description=description_text, -- 2.35.1