Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3926818imm; Mon, 8 Oct 2018 11:48:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+axYFlZVDfbK4nCoarLBcg2FT36RqrwhlheeXdmjvw/HGe7+UvH9eOAX9JC9f0qddemht X-Received: by 2002:a17:902:3324:: with SMTP id a33-v6mr25187765plc.208.1539024539112; Mon, 08 Oct 2018 11:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024539; cv=none; d=google.com; s=arc-20160816; b=wkYwO2eO5HZjgyGvygUCnRUdzlOoXCOioMJckzk6EvkwJ4ohCYUDYcgrUrPcVbZ6Wp 97BCQzwtMiIbx5BYXxCgjfRos6GqUlyhzBH9mkgCoSLARyglLwObRuuL3eAmz04Mt20u p7WSRo/vZ4dC3uHrWJiORsP5FX/slW63f4f4BRe2mcgBuJd6ao0nJU2UvGqCPpdmOFR7 jp/c0GreWXeBiPR3NLUp7XQnYDOCF9bY9qlWMXs7n1dr8ot2pLbhZ8z9g+nLj00fx03Z JNxLOmhABgFtsJC/B1iSXW+Dkt6ogsrPeCIojUoKqqYoWjyre/xpxu4707dzEwCgr/wl S2wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EVKzDln7XTKoj3V48EUrm4OVqlSv3wrSWNhne0iMtww=; b=OhFQRN1KlNR07DOdPgD6saCf37yQbbZhWuyH7EWPxSIEVjRxQ94uRm2Ga/tEXqp8cv a3sKFSFxCqzLFHJPBnDui5fGimjydHYpMWMp7yoODcPOvtXqTh82xHT1E8wyV9OfBjHq 4is0QUCetm3N8ldU+AU6/RicmkZ07oQ3LhIaZbgjF25VVm/n6UigJmZ7fj9pidHYIbuS P2eErUWQzbCqoj7iytiuUdbHdn0/JW/S/Wqv/uGf+7YGudsHZApx2T9/+IhYk5DqhmQS a2acxJ566XF2IHvH4q1qhgQetvErolRO0O1IpvL6xYOyE++AnJFnbzv0N0Yv4K4cLprj Ghbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="WAqMV/bA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si17769422pgh.244.2018.10.08.11.48.43; Mon, 08 Oct 2018 11:48:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="WAqMV/bA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731690AbeJICBk (ORCPT + 99 others); Mon, 8 Oct 2018 22:01:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbeJICBk (ORCPT ); Mon, 8 Oct 2018 22:01:40 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A51E3204FD; Mon, 8 Oct 2018 18:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024513; bh=JPpA0AvHJZJNT1Zn/rcnJ1UD+QDDahrKh1Lb6i5eKSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WAqMV/bA/SgY5CSuRxPjQOdFTZerXpZ/vXEF7ItBPcgPoeXpWErTQE67SLKMTM4QW nBncHTfqQfzSqq5azmwRMII1Q2ZvwaKiGiuXskPKPj4Vkn9m5fFP9OhdM4wctFx3Hp hdmcWkI1X8xZ1zTJ4pdZrm7sB3iolYMOlbea3xJY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Raspl , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Sasha Levin Subject: [PATCH 4.18 042/168] tools/kvm_stat: fix updates for dead guests Date: Mon, 8 Oct 2018 20:30:22 +0200 Message-Id: <20181008175621.647120346@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Raspl [ Upstream commit 710ab11ad9329d2d4b044405e328c994b19a2aa9 ] With pid filtering active, when a guest is removed e.g. via virsh shutdown, successive updates produce garbage. Therefore, we add code to detect this case and prevent further body updates. Note that when displaying the help dialog via 'h' in this case, once we exit we're stuck with the 'Collecting data...' message till we remove the filter. Signed-off-by: Stefan Raspl Signed-off-by: Radim Krčmář Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/kvm/kvm_stat/kvm_stat | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat @@ -1170,6 +1170,9 @@ class Tui(object): return sorted_items + if not self._is_running_guest(self.stats.pid_filter): + # leave final data on screen + return row = 3 self.screen.move(row, 0) self.screen.clrtobot() @@ -1327,6 +1330,12 @@ class Tui(object): msg = '"' + str(val) + '": Invalid value' self._refresh_header() + def _is_running_guest(self, pid): + """Check if pid is still a running process.""" + if not pid: + return True + return os.path.isdir(os.path.join('/proc/', str(pid))) + def _show_vm_selection_by_guest(self): """Draws guest selection mask. @@ -1354,7 +1363,7 @@ class Tui(object): if not guest or guest == '0': break if guest.isdigit(): - if not os.path.isdir(os.path.join('/proc/', guest)): + if not self._is_running_guest(guest): msg = '"' + guest + '": Not a running process' continue pid = int(guest)