From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823859; cv=none; d=zohomail.com; s=zohoarc; b=K50J1bywIR7EmVVAuIavLm3a1z2wPM9PWaRmWu/kBvyA8ccGmDinlNspuKkiZcxze0WZIxpbt2rx1jgn1v3enCxDKslJjBh+xM7U+icHRWaxp0rs+B+QYvaLx0UyMxetRYLhi73ct3dstoS+SbZeQTw3OJCt929++lQO5yqnjDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823859; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2MzhJnSJr5qmsZ5UrL+Y50VJqRIK7PdJYKFIrnd03eA=; b=bldIJJ2YaHHk/0zpjS+F3WRmXg9JPbWbbCQxkfg0Q8rwu91qvjkkOfJS8sQ0aPHFEObIxlmW97mCz9/uYLuTBUlq/0w8RShH1Nln4uuo0Esd9DovOT1pfbbkAmPrgKvRCErJW9sv5BsIlZj99b4YztkGVVfhTkUBo+IHav49y94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622823859121938.8795166225349; Fri, 4 Jun 2021 09:24:19 -0700 (PDT) Received: from localhost ([::1]:53544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCcM-0001oa-Bv for importer2@patchew.org; Fri, 04 Jun 2021 12:24:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAi-0000xO-OU for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAe-0001TU-3F for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-64-aSkzF39aP1O6z6vC3JZZZA-1; Fri, 04 Jun 2021 11:55:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 636118018A7; Fri, 4 Jun 2021 15:55:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D20839A66; Fri, 4 Jun 2021 15:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2MzhJnSJr5qmsZ5UrL+Y50VJqRIK7PdJYKFIrnd03eA=; b=OoJ5VzCAiZRlUJh82lkfMfASAjcmp7t8OzCOnM1SzrVJge8fpq/6EvymfAEdizDqoNV7BO VUnCAzbUzlkXbFkUM5RNc3Ew+slrFrBYsfZb9Yf9LYi6WJW6eazD3dsoWC6penbJL4XJTg HgeFHpmYBo5IRXM5L7WcCOdfWLebQsg= X-MC-Unique: aSkzF39aP1O6z6vC3JZZZA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 01/11] scripts/qemu-ga-client: apply isort rules Date: Fri, 4 Jun 2021 11:55:22 -0400 Message-Id: <20210604155532.1499282-2-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Hint: > ln -s scripts/qmp/qemu-ga-client python/qemu/qmp/qemu_ga_client.py > cd python > isort qemu Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 348d85864c..97f4047a62 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -36,10 +36,11 @@ # See also: https://wiki.qemu.org/Features/QAPI/GuestAgent # =20 -import os -import sys import base64 +import os import random +import sys + =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp @@ -279,9 +280,9 @@ def main(address, cmd, args): =20 =20 if __name__ =3D=3D '__main__': - import sys - import os import optparse + import os + import sys =20 address =3D os.environ['QGA_CLIENT_ADDRESS'] if 'QGA_CLIENT_ADDRESS' i= n os.environ else None =20 --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823491; cv=none; d=zohomail.com; s=zohoarc; b=EvS8emRSTftGdq2Klrwy5tt46aVcXEwubF/+rQHe98bay7Gna1ywtjXvNpdnstqJd4vozTET6dsc8o19ZQmNTFQXl7cEi6mHYwQXnsUUUbqtBZ5AnfYc17MhliIWKDltimNLr9EK4/Woywc3bQ6+mSECYtsH6alT3dMqZLR5RIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823491; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0BGW9H49/s3akhFMjW6DOae1MrwVJce9psBYCikG+W8=; b=iv/r4kKik9iW+PltsZfbtnO/rcIftpMsMkUI0hd8SeHgUsrWiE5OhVugE0cYetWs+dU7OyoqSEnPCNEnh8iGGORulVZsPEB8YzcoGCidonMwcU0TGZ26voP519pbTNTTn1DjQdjzWu9lhDnvYET3KQas96/rXq+0FrpUIdFQZi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162282349109166.9286431823881; Fri, 4 Jun 2021 09:18:11 -0700 (PDT) Received: from localhost ([::1]:33588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCWQ-0004l6-0N for importer2@patchew.org; Fri, 04 Jun 2021 12:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAq-00015N-2c for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAe-0001TS-3S for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-5QdFa-zSN7m2NjS5MGe4CQ-1; Fri, 04 Jun 2021 11:55:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E242E9F92A; Fri, 4 Jun 2021 15:55:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id A72D72BFF6; Fri, 4 Jun 2021 15:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0BGW9H49/s3akhFMjW6DOae1MrwVJce9psBYCikG+W8=; b=E3oDkxTWFVrH3QyFoZCGSDQWnpRiQzAWLXam4P8M0gX+9cNlaAP5m0AFjXm4dfWDrCEj3f emn67HRwOQ9VRrLS9pgIdOKKVgSmQ4F+bvj7DtsevFU97PFRBb4h1OpjmBWePAZynT/Eo6 78NFuiUT904NRAyBlqVZMtKtJ9wYBiI= X-MC-Unique: 5QdFa-zSN7m2NjS5MGe4CQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 02/11] scripts/qemu-ga-client: apply (most) flake8 rules Date: Fri, 4 Jun 2021 11:55:23 -0400 Message-Id: <20210604155532.1499282-3-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" - Line length should be < 80 - You shouldn't perform unscoped imports except at the top of the module Notably, the sys.path hack creates problems with the import rule. This will be fixed later. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 97f4047a62..566bddc89d 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -12,7 +12,8 @@ # Start QEMU with: # # # qemu [...] -chardev socket,path=3D/tmp/qga.sock,server=3Don,wait=3Doff= ,id=3Dqga0 \ -# -device virtio-serial -device virtserialport,chardev=3Dqga0,name=3Dorg= .qemu.guest_agent.0 +# -device virtio-serial \ +# -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 # # Run the script: # @@ -37,6 +38,7 @@ # =20 import base64 +import optparse import os import random import sys @@ -94,9 +96,11 @@ class QemuGuestAgentClient: msgs =3D [] msgs.append('version: ' + info['version']) msgs.append('supported_commands:') - enabled =3D [c['name'] for c in info['supported_commands'] if c['e= nabled']] + enabled =3D [c['name'] for c in info['supported_commands'] + if c['enabled']] msgs.append('\tenabled: ' + ', '.join(enabled)) - disabled =3D [c['name'] for c in info['supported_commands'] if not= c['enabled']] + disabled =3D [c['name'] for c in info['supported_commands'] + if not c['enabled']] msgs.append('\tdisabled: ' + ', '.join(disabled)) =20 return '\n'.join(msgs) @@ -119,11 +123,11 @@ class QemuGuestAgentClient: if ipaddr['ip-address-type'] =3D=3D 'ipv4': addr =3D ipaddr['ip-address'] mask =3D self.__gen_ipv4_netmask(int(ipaddr['prefi= x'])) - msgs.append("\tinet %s netmask %s" % (addr, mask)) + msgs.append(f"\tinet {addr} netmask {mask}") elif ipaddr['ip-address-type'] =3D=3D 'ipv6': addr =3D ipaddr['ip-address'] prefix =3D ipaddr['prefix'] - msgs.append("\tinet6 %s prefixlen %s" % (addr, pr= efix)) + msgs.append(f"\tinet6 {addr} prefixlen {prefix}") if nif['hardware-address'] !=3D '00:00:00:00:00:00': msgs.append("\tether " + nif['hardware-address']) =20 @@ -237,6 +241,8 @@ def _cmd_suspend(client, args): =20 def _cmd_shutdown(client, args): client.shutdown() + + _cmd_powerdown =3D _cmd_shutdown =20 =20 @@ -280,17 +286,15 @@ def main(address, cmd, args): =20 =20 if __name__ =3D=3D '__main__': - import optparse - import os - import sys + address =3D os.environ.get('QGA_CLIENT_ADDRESS') =20 - address =3D os.environ['QGA_CLIENT_ADDRESS'] if 'QGA_CLIENT_ADDRESS' i= n os.environ else None - - usage =3D "%prog [--address=3D|] [a= rgs...]\n" + usage =3D ("%prog [--address=3D|]" + " [args...]\n") usage +=3D ': ' + ', '.join(commands) parser =3D optparse.OptionParser(usage=3Dusage) parser.add_option('--address', action=3D'store', type=3D'string', - default=3Daddress, help=3D'Specify a ip:port pair or= a unix socket path') + default=3Daddress, + help=3D'Specify a ip:port pair or a unix socket path= ') options, args =3D parser.parse_args() =20 address =3D options.address --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823180; cv=none; d=zohomail.com; s=zohoarc; b=Ue9v6Hck1pILsGYMVeYQwP/wJwzt6cGa6gmotWzv2T4dzoQQ2CxQx/kRsx8jHDUZ3lPIzuW0hqM2trAVMgt97NnVlQEXbiyfcBhZMYKPxKvdRWLp2qoI7Zb56r9y8Ap8oG/t7VRk+bqUZcYoNmkyssgQ/gvq5N9USxoilWrAIWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823180; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ycxcFGaMDTWzJx8TIXaLYprHmj4HRWdv/WbRcDaQ+1Y=; b=GKvT8Bc3mvEKUkco77xt9ljeaIxrI29HcD73FdDZM9sZ/Y8yXS8oome43z4SFO2RlorbA6nFkt1l/kEUwNzaG9VbCsWGR1z1vBVIexIT+Fs9Ml88VTkGkzdeJQ0QjsCLv/z3RpTWakLLhKKJwvKCKsFeRX2owNUawedl2QQ3rtU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622823180654753.1257603525754; Fri, 4 Jun 2021 09:13:00 -0700 (PDT) Received: from localhost ([::1]:44628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCRP-000111-BH for importer2@patchew.org; Fri, 04 Jun 2021 12:12:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAm-0000yQ-7J for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAg-0001Tz-Dh for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-444-tvTI1fxOPmWQ31EOet5phA-1; Fri, 04 Jun 2021 11:55:38 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE5849F92D; Fri, 4 Jun 2021 15:55:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A32D39A66; Fri, 4 Jun 2021 15:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ycxcFGaMDTWzJx8TIXaLYprHmj4HRWdv/WbRcDaQ+1Y=; b=icNi5MemOHM40vMQUhsIpxzsbShYituqM31pVXhcptENvki1hb/HboxBxxGkxexIH9cy6z tKZX37FZAvXKA+mZZZCNnbLZleuY4AoVS5CEuU8yc2+SPovw6LXBC5MSTICZ8a9xBfpMG7 iFr9F6wbrVvbUyRszsAVTrmx8tnp++Q= X-MC-Unique: tvTI1fxOPmWQ31EOet5phA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 03/11] scripts/qemu-ga-client: Fix exception handling Date: Fri, 4 Jun 2021 11:55:24 -0400 Message-Id: <20210604155532.1499282-4-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Fixes: 50d189c These error classes aren't available anymore. Fix the bitrot. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 566bddc89d..7aba09f0fe 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -56,8 +56,6 @@ class QemuGuestAgent(qmp.QEMUMonitorProtocol): =20 =20 class QemuGuestAgentClient: - error =3D QemuGuestAgent.error - def __init__(self, address): self.qga =3D QemuGuestAgent(address) self.qga.connect(negotiate=3DFalse) @@ -137,7 +135,7 @@ class QemuGuestAgentClient: self.qga.settimeout(timeout) try: self.qga.ping() - except self.qga.timeout: + except TimeoutError: return False return True =20 @@ -269,11 +267,11 @@ def main(address, cmd, args): =20 try: client =3D QemuGuestAgentClient(address) - except QemuGuestAgent.error as e: + except OSError as err: import errno =20 - print(e) - if e.errno =3D=3D errno.ECONNREFUSED: + print(err) + if err.errno =3D=3D errno.ECONNREFUSED: print('Hint: qemu is not running?') sys.exit(1) =20 --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823114; cv=none; d=zohomail.com; s=zohoarc; b=SNpgYhdjsdG4l6EZfictYFY79Lvyv9X00fLaIs0mtF4FzUKp39qUJ9z0nsTXNmuXAwzt4xzsqCOo9nIt+XUl2z1J33owgvxKycFes98BLvMTQpBlkbmBFHdgwtVogV+Jdln1iNkUqRh4kV0PtdoSDjsm6ipnwKfVmEw/q4+C45I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823114; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+8gjMEkAcHd+SCgPh8/tkLzO/kkWyeLvaW8fzwU8nes=; b=RpcIJ3zrMAEEQ4o+cf9zrJYt/ZVEc/jtj3BCT7BRa9cc3g0jSHFCXD+sp9LLxZ62uZnR2gauYUkKgVG3rTrqQStx5Scdm//vB95S7yTA4qFOZRA1Kk4gCdxOijZhTNoO5CpHhweq1Tq62w/Ce8pI2cYHXVkg/0ih1Xez9SiXHC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622823114424119.16269086096156; Fri, 4 Jun 2021 09:11:54 -0700 (PDT) Received: from localhost ([::1]:40694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCQL-0006QU-Bn for importer2@patchew.org; Fri, 04 Jun 2021 12:11:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAt-0001CG-Rc for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50434) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAi-0001Ug-8N for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-NCvNNU1qMdCdQMUFAJ8WEQ-1; Fri, 04 Jun 2021 11:55:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C288A9F92B; Fri, 4 Jun 2021 15:55:38 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 119FE620DE; Fri, 4 Jun 2021 15:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+8gjMEkAcHd+SCgPh8/tkLzO/kkWyeLvaW8fzwU8nes=; b=jPNjH2P1zbT+n9w1bPWpG5yMBJXwWRzTNPAjRyxYsxqfZFKbXKIkIw/JJF+Kn/uRn6JOan 4tGeC8YOKZ8Wdea4TeUXleBAXezkkLRzJ0ePTxT7pGIZFU0SmENr5HfJejBeODQB6esyDH 3GxV5bRAE2bddahujQeAm6maVYDcw1Q= X-MC-Unique: NCvNNU1qMdCdQMUFAJ8WEQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 04/11] scripts/qemu-ga-client: replace deprecated optparse with argparse Date: Fri, 4 Jun 2021 11:55:25 -0400 Message-Id: <20210604155532.1499282-5-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" optparse isn't supported anymore, it's from the python2 days. Replace it with the mostly similar argparse. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 7aba09f0fe..8eb4015e61 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -37,8 +37,8 @@ # See also: https://wiki.qemu.org/Features/QAPI/GuestAgent # =20 +import argparse import base64 -import optparse import os import random import sys @@ -255,7 +255,7 @@ def _cmd_reboot(client, args): commands =3D [m.replace('_cmd_', '') for m in dir() if '_cmd_' in m] =20 =20 -def main(address, cmd, args): +def send_command(address, cmd, args): if not os.path.exists(address): print('%s not found' % address) sys.exit(1) @@ -283,25 +283,23 @@ def main(address, cmd, args): globals()['_cmd_' + cmd](client, args) =20 =20 -if __name__ =3D=3D '__main__': +def main(): address =3D os.environ.get('QGA_CLIENT_ADDRESS') =20 - usage =3D ("%prog [--address=3D|]" - " [args...]\n") - usage +=3D ': ' + ', '.join(commands) - parser =3D optparse.OptionParser(usage=3Dusage) - parser.add_option('--address', action=3D'store', type=3D'string', - default=3Daddress, - help=3D'Specify a ip:port pair or a unix socket path= ') - options, args =3D parser.parse_args() + parser =3D argparse.ArgumentParser() + parser.add_argument('--address', action=3D'store', + default=3Daddress, + help=3D'Specify a ip:port pair or a unix socket pa= th') + parser.add_argument('command', choices=3Dcommands) + parser.add_argument('args', nargs=3D'*') =20 - address =3D options.address - if address is None: + args =3D parser.parse_args() + if args.address is None: parser.error('address is not specified') sys.exit(1) =20 - if len(args) =3D=3D 0: - parser.error('Less argument') - sys.exit(1) + send_command(args.address, args.command, args.args) =20 - main(address, args[0], args[1:]) + +if __name__ =3D=3D '__main__': + main() --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823342; cv=none; d=zohomail.com; s=zohoarc; b=Rd4FH4yE5Ile4BZlzdYwtWqdqE8jywS6BdCPOS5i3Yopp8AEtwu4lN+92LXCupcWoGrpqyaoPtQ/Qappl1wW+vu0iTpigff29AQcYqh0Z7G/nNnhb2oBN9oKUG+Wd+VO0NCRuQ0URjnQMvUTbL93BkiInd9BtOCgbQ8oUark0pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K8A0QyiFtIa/YHrZEZGqGKLmmdmSltI5sa0lAzhT9UI=; b=Ns5TNQT2PgqaiHlhnXT1PYg7dGrpGcOqA2JORONk7lqsIuY2F9xT/1fuCMD8CDVX+7ciPBdLT5lSosCBb3aPTtv7MjvYfZxxrl5rPZwy7ZOZBlAKonxeLZ3GwXbp/Pi8VCkbmc/CWVR86hWH5ODUY43wpaQ8SKTpnF2HZ5vB7Ew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622823342949525.1951094716151; Fri, 4 Jun 2021 09:15:42 -0700 (PDT) Received: from localhost ([::1]:53364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCU1-0007B2-Nu for importer2@patchew.org; Fri, 04 Jun 2021 12:15:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAo-00012X-49 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAi-0001Um-CC for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-6G2UoYjwM22hXVXtoI_YxQ-1; Fri, 04 Jun 2021 11:55:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA3599F92C; Fri, 4 Jun 2021 15:55:39 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id E997A5B4A4; Fri, 4 Jun 2021 15:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K8A0QyiFtIa/YHrZEZGqGKLmmdmSltI5sa0lAzhT9UI=; b=b+l0KlJgSFZ3YYumnX8MyuATPLG0yZ0JYa6ANwwUZF+YQemhLxxhK9Y8v59rt8Kq1LJcyc +1wWxwo/2L7MEQ/NqVonfjEUk4sEpByoPXdUDXf8Ikc7oIozGKzEzLH9ZO0UndNeUKnncB ilrh9ZcFtIleV7yketLWbVZ3CfsVbN4= X-MC-Unique: 6G2UoYjwM22hXVXtoI_YxQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 05/11] scripts/qemu-ga-client: add module docstring Date: Fri, 4 Jun 2021 11:55:26 -0400 Message-Id: <20210604155532.1499282-6-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Turn that nice usage comment into a docstring. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 65 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 8eb4015e61..e81937e0ea 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -1,41 +1,42 @@ #!/usr/bin/env python3 =20 -# QEMU Guest Agent Client -# +""" +QEMU Guest Agent Client + +Usage: + +Start QEMU with: + +# qemu [...] -chardev socket,path=3D/tmp/qga.sock,server,wait=3Doff,id=3Dq= ga0 \ + -device virtio-serial \ + -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 + +Run the script: + +$ qemu-ga-client --address=3D/tmp/qga.sock [args...] + +or + +$ export QGA_CLIENT_ADDRESS=3D/tmp/qga.sock +$ qemu-ga-client [args...] + +For example: + +$ qemu-ga-client cat /etc/resolv.conf +# Generated by NetworkManager +nameserver 10.0.2.3 +$ qemu-ga-client fsfreeze status +thawed +$ qemu-ga-client fsfreeze freeze +2 filesystems frozen + +See also: https://wiki.qemu.org/Features/QAPI/GuestAgent +""" + # Copyright (C) 2012 Ryota Ozaki # # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. -# -# Usage: -# -# Start QEMU with: -# -# # qemu [...] -chardev socket,path=3D/tmp/qga.sock,server=3Don,wait=3Doff= ,id=3Dqga0 \ -# -device virtio-serial \ -# -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 -# -# Run the script: -# -# $ qemu-ga-client --address=3D/tmp/qga.sock [args...] -# -# or -# -# $ export QGA_CLIENT_ADDRESS=3D/tmp/qga.sock -# $ qemu-ga-client [args...] -# -# For example: -# -# $ qemu-ga-client cat /etc/resolv.conf -# # Generated by NetworkManager -# nameserver 10.0.2.3 -# $ qemu-ga-client fsfreeze status -# thawed -# $ qemu-ga-client fsfreeze freeze -# 2 filesystems frozen -# -# See also: https://wiki.qemu.org/Features/QAPI/GuestAgent -# =20 import argparse import base64 --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622822925; cv=none; d=zohomail.com; s=zohoarc; b=HY847gOHIGZO8Cj+2nzt6Y0FhiL6X3Ssn5SV8jkuXk9wcvrUi6v/6uDuC+ldpvFLODcZWdx1k/fXmiit9hFhRhfp1gV1J1k4/Dg2cBRY8MopxTOF/ZZZxhv/aT0i0QVL8Xesxf1SuVWCbN7JOmZXWELMb4KXNsd27gKoL2YSJbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622822925; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8QZLQkMFCMaEsiD+0Lrc8dRGYjO8zJRP6vlPMh9DRK0=; b=am8lpw+/ojpBBeYv+NHd8hzlrd7gFNdStwSPvB2/IKPe1Xduvm2nUClct+qD3KBlLpRBt+4ZvwKyXppyHJ51bYdz39uh7QjeSHxUTEvhAldSKe7+W8Id3Bc5fRupM1avW0vrB1eQlOu786tAa7TOsaFN11+6s3DRA9XPqQJ8A0U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162282292583965.49963672351566; Fri, 4 Jun 2021 09:08:45 -0700 (PDT) Received: from localhost ([::1]:60388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCNI-0008Tk-HO for importer2@patchew.org; Fri, 04 Jun 2021 12:08:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAr-00019Q-Uj for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAi-0001VS-AJ for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-YbscPlFgNI61E0FhCNpYjg-1; Fri, 04 Jun 2021 11:55:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 941AD9F92B; Fri, 4 Jun 2021 15:55:40 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id D192D50C0A; Fri, 4 Jun 2021 15:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8QZLQkMFCMaEsiD+0Lrc8dRGYjO8zJRP6vlPMh9DRK0=; b=blnMXfBXhZgs6WxRhFEi03KkqnBHqlHCuSyhRTaW75XS/Gzr6Sx2zDM6VdfySUQ5c3SK3I dq/yRem4UEOUwyrZXYHAjlKArX2Mtvz2nhzgpeR8Lu9oGympRo4V4RyDoG/I/4dfjkmYmb 3PcdYCIjE16cAdfTb/mEy1SsoVOwh00= X-MC-Unique: YbscPlFgNI61E0FhCNpYjg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/11] scripts/qemu-ga-client: apply (most) pylint rules Date: Fri, 4 Jun 2021 11:55:27 -0400 Message-Id: <20210604155532.1499282-7-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" I'm only doing a very quick best-effort to preserve this script, to help keep it from breaking further. I think there are pending ideas swirling on the right way to implement better SDKs and better clients, and this script might be a handy reference for those discussions. It presents some interesting design problems, like static type safety when using a dynamic RPC mechanism. I believe it's worth preserving the effort and care that went into making this script by updating it to work with our current infrastructure. However, I am disabling the requirement for docstrings in this file. If you would like to help improve this script, please add docstrings alongside any refactors or rejuvenations you might apply at that time. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index e81937e0ea..ece9f74fa8 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -40,6 +40,7 @@ See also: https://wiki.qemu.org/Features/QAPI/GuestAgent =20 import argparse import base64 +import errno import os import random import sys @@ -49,6 +50,13 @@ sys.path.append(os.path.join(os.path.dirname(__file__), = '..', '..', 'python')) from qemu import qmp =20 =20 +# This script has not seen many patches or careful attention in quite +# some time. If you would like to improve it, please review the design +# carefully and add docstrings at that point in time. Until then: + +# pylint: disable=3Dmissing-docstring + + class QemuGuestAgent(qmp.QEMUMonitorProtocol): def __getattr__(self, name): def wrapper(**kwds): @@ -104,7 +112,8 @@ class QemuGuestAgentClient: =20 return '\n'.join(msgs) =20 - def __gen_ipv4_netmask(self, prefixlen): + @classmethod + def __gen_ipv4_netmask(cls, prefixlen): mask =3D int('1' * prefixlen + '0' * (32 - prefixlen), 2) return '.'.join([str(mask >> 24), str((mask >> 16) & 0xff), @@ -207,10 +216,12 @@ def _cmd_fstrim(client, args): =20 =20 def _cmd_ifconfig(client, args): + assert not args print(client.ifconfig()) =20 =20 def _cmd_info(client, args): + assert not args print(client.info()) =20 =20 @@ -239,6 +250,7 @@ def _cmd_suspend(client, args): =20 =20 def _cmd_shutdown(client, args): + assert not args client.shutdown() =20 =20 @@ -246,10 +258,12 @@ _cmd_powerdown =3D _cmd_shutdown =20 =20 def _cmd_halt(client, args): + assert not args client.shutdown('halt') =20 =20 def _cmd_reboot(client, args): + assert not args client.shutdown('reboot') =20 =20 @@ -269,8 +283,6 @@ def send_command(address, cmd, args): try: client =3D QemuGuestAgentClient(address) except OSError as err: - import errno - print(err) if err.errno =3D=3D errno.ECONNREFUSED: print('Hint: qemu is not running?') --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622822697; cv=none; d=zohomail.com; s=zohoarc; b=K187SHaOaw4vGSghIdfiWW+GL3mEL2B87ydEGitESGBWUNKfely9pMVsKS8gs5cXWzuKmz5smxtwaYXvDMvkDvoMU5W0BJETW4CZi7yE90/TFtTlTWmP+rAGJ7+60L3HQXhPHtFCaxzb9oQE1hCqux7RiP0OdILzfPu9ktgJP/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622822697; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QAeKin8fXiNkWdbPGFedXcvCVPBW5Bzox4Jd8hfMSho=; b=A/zwkWcaGsej2J3q5djam5kwmlWxkkCzzY+9VskSnufOUoXgUXUL3UWbECh1+Fpiz8lSLbqv2pKrZ8GIKvt5URGWdOv1o/ZxzOgu7PM58bO32nx6Zj82jFmiXiiv/ANOMVukXbml4uusFwAHpvnmww/PtTgoPimk30U5OcEzYoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622822697575863.2088525017231; Fri, 4 Jun 2021 09:04:57 -0700 (PDT) Received: from localhost ([::1]:51770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCJb-0002UD-Fv for importer2@patchew.org; Fri, 04 Jun 2021 12:04:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAq-00015a-2v for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAj-0001Vb-JC for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-hJNNA1I0MNKZMIV1oxYLxQ-1; Fri, 04 Jun 2021 11:55:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BC058042AD; Fri, 4 Jun 2021 15:55:41 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB0105B4A4; Fri, 4 Jun 2021 15:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QAeKin8fXiNkWdbPGFedXcvCVPBW5Bzox4Jd8hfMSho=; b=Vg18iCArEuDM5XKjKHQoPkOlqC+stE3z5sSmX3XJ13PSLypuHXrmN3kotFTbkjsiHlhk4g PQPCTp9O/o6eJlAj3xtIwgJTQq689mF/Zd3twiZMUBL4Inf9Bi3CsUJHb1hvgkBLMF4pPn f6cGaabqSDoI6UKrBbW8IsFBZyzlj2A= X-MC-Unique: hJNNA1I0MNKZMIV1oxYLxQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 07/11] python/qmp: Correct type of QMPReturnValue Date: Fri, 4 Jun 2021 11:55:28 -0400 Message-Id: <20210604155532.1499282-8-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It's only a Dict[str, Any] most of the time. It's not actually guaranteed to be anything in particular. Fix this type to be more accurate to the reality we live in. Signed-off-by: John Snow --- A note for Vladimir: I'm not using 'object' here yet because it causes a few regressions in iotests.py type checking that I'm not ready to fix just yet, but it will eventually happen. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 822c793c32..a6e1a7b857 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -35,14 +35,19 @@ ) =20 =20 -# QMPMessage is a QMP Message of any kind. -# e.g. {'yee': 'haw'} -# -# QMPReturnValue is the inner value of return values only. -# {'return': {}} is the QMPMessage, -# {} is the QMPReturnValue. +#: QMPMessage is an entire QMP message of any kind. QMPMessage =3D Dict[str, Any] -QMPReturnValue =3D Dict[str, Any] + +#: QMPReturnValue is the 'return' value of a command. +QMPReturnValue =3D object + +# QMPMessage can be outgoing commands or incoming events/returns. +# QMPReturnValue is usually a dict/json object, but due to QAPI's +# 'returns-whitelist', it can actually be anything. +# +# {'return': {}} is a QMPMessage, +# {} is the QMPReturnValue. + =20 InternetAddrT =3D Tuple[str, int] UnixAddrT =3D str @@ -297,8 +302,8 @@ def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: return resp =20 def cmd(self, name: str, - args: Optional[Dict[str, Any]] =3D None, - cmd_id: Optional[Any] =3D None) -> QMPMessage: + args: Optional[Dict[str, object]] =3D None, + cmd_id: Optional[object] =3D None) -> QMPMessage: """ Build a QMP command and send it to the QMP Monitor. =20 @@ -313,7 +318,7 @@ def cmd(self, name: str, qmp_cmd['id'] =3D cmd_id return self.cmd_obj(qmp_cmd) =20 - def command(self, cmd: str, **kwds: Any) -> QMPReturnValue: + def command(self, cmd: str, **kwds: object) -> QMPReturnValue: """ Build and send a QMP command to the monitor, report errors if any """ --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823343; cv=none; d=zohomail.com; s=zohoarc; b=RhsbN8yrloVrOM9TdeMz3rrvShJ4Ex8luqJ7FssmAgHrdQ7wdaASSiyYorbeACDBUY0yMc30Tv4TM1jkuehuTdHbUPzQNz1cY4xZ/CbwEorGVNbidyEjjaD1NwF4nJ/gOKyoDaS63gfTOxxeHecClsrRQAjl0GB6UnxQtFgHIKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823343; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=54sqjr9wbeFj3idsTg9R70lwcdtZnQkFQTrwyK+XX9Y=; b=Gy75ein6Id7/c4/4s1TcsJN/pIl+XMN4WN4cXexVi6ly3PC7qSA1gnTE6wBFG5AgpZ1ef1Cj6e5oB+MXzFSZbdcNXWhyNdyZs+PODKogHtvCgIzqkd53n9B/f1PtQ5x/mpPtWx0I8qnd51wGVloBX5rRAYebRSaG1YxQgZ/VaCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16228233431531000.746336751737; Fri, 4 Jun 2021 09:15:43 -0700 (PDT) Received: from localhost ([::1]:53322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCU2-000798-16 for importer2@patchew.org; Fri, 04 Jun 2021 12:15:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAt-0001CO-Rk for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAl-0001W9-Vl for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-333-mS07WCrxOeaux6IasYmp2g-1; Fri, 04 Jun 2021 11:55:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 604FF9F93A; Fri, 4 Jun 2021 15:55:42 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id A52B5620DE; Fri, 4 Jun 2021 15:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=54sqjr9wbeFj3idsTg9R70lwcdtZnQkFQTrwyK+XX9Y=; b=KJBGlNk2F5PfXUafhyjsP2Iz1Sqp+oLTRLWghu9HcJJWHDN7PyhCoxe5/xNp5JCDJ2qamx 5OYSVzjXG+tQSPNml6u4WlbQOJ8s3TiGDOeCWVAGhJLgA9OtFw5PWrbehvyLiWSRwKEkhA /7PEoIkbZAIA91ay+uP38lZ8SAzwgAQ= X-MC-Unique: mS07WCrxOeaux6IasYmp2g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 08/11] scripts/qemu-ga-client: add mypy type hints Date: Fri, 4 Jun 2021 11:55:29 -0400 Message-Id: <20210604155532.1499282-9-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This script is in slightly rough shape, but it still works. A lot of care went into its initial development. In good faith, I'm updating it to the latest Python coding standards. If there is in interest in this script, though, I'll be asking for a contributor to take care of it further. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 89 +++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index ece9f74fa8..a7d0ef8347 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -44,10 +44,18 @@ import errno import os import random import sys +from typing import ( + Any, + Callable, + Dict, + Optional, + Sequence, +) =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp +from qemu.qmp import SocketAddrT =20 =20 # This script has not seen many patches or careful attention in quite @@ -58,18 +66,18 @@ from qemu import qmp =20 =20 class QemuGuestAgent(qmp.QEMUMonitorProtocol): - def __getattr__(self, name): - def wrapper(**kwds): + def __getattr__(self, name: str) -> Callable[..., Any]: + def wrapper(**kwds: object) -> object: return self.command('guest-' + name.replace('_', '-'), **kwds) return wrapper =20 =20 class QemuGuestAgentClient: - def __init__(self, address): + def __init__(self, address: SocketAddrT): self.qga =3D QemuGuestAgent(address) self.qga.connect(negotiate=3DFalse) =20 - def sync(self, timeout=3D3): + def sync(self, timeout: Optional[float] =3D 3) -> None: # Avoid being blocked forever if not self.ping(timeout): raise EnvironmentError('Agent seems not alive') @@ -79,9 +87,9 @@ class QemuGuestAgentClient: if isinstance(ret, int) and int(ret) =3D=3D uid: break =20 - def __file_read_all(self, handle): + def __file_read_all(self, handle: int) -> bytes: eof =3D False - data =3D '' + data =3D b'' while not eof: ret =3D self.qga.file_read(handle=3Dhandle, count=3D1024) _data =3D base64.b64decode(ret['buf-b64']) @@ -89,7 +97,7 @@ class QemuGuestAgentClient: eof =3D ret['eof'] return data =20 - def read(self, path): + def read(self, path: str) -> bytes: handle =3D self.qga.file_open(path=3Dpath) try: data =3D self.__file_read_all(handle) @@ -97,7 +105,7 @@ class QemuGuestAgentClient: self.qga.file_close(handle=3Dhandle) return data =20 - def info(self): + def info(self) -> str: info =3D self.qga.info() =20 msgs =3D [] @@ -113,14 +121,14 @@ class QemuGuestAgentClient: return '\n'.join(msgs) =20 @classmethod - def __gen_ipv4_netmask(cls, prefixlen): + def __gen_ipv4_netmask(cls, prefixlen: int) -> str: mask =3D int('1' * prefixlen + '0' * (32 - prefixlen), 2) return '.'.join([str(mask >> 24), str((mask >> 16) & 0xff), str((mask >> 8) & 0xff), str(mask & 0xff)]) =20 - def ifconfig(self): + def ifconfig(self) -> str: nifs =3D self.qga.network_get_interfaces() =20 msgs =3D [] @@ -141,7 +149,7 @@ class QemuGuestAgentClient: =20 return '\n'.join(msgs) =20 - def ping(self, timeout): + def ping(self, timeout: Optional[float]) -> bool: self.qga.settimeout(timeout) try: self.qga.ping() @@ -149,37 +157,40 @@ class QemuGuestAgentClient: return False return True =20 - def fsfreeze(self, cmd): + def fsfreeze(self, cmd: str) -> object: if cmd not in ['status', 'freeze', 'thaw']: raise Exception('Invalid command: ' + cmd) - + # Can be int (freeze, thaw) or GuestFsfreezeStatus (status) return getattr(self.qga, 'fsfreeze' + '_' + cmd)() =20 - def fstrim(self, minimum=3D0): - return getattr(self.qga, 'fstrim')(minimum=3Dminimum) + def fstrim(self, minimum: int) -> Dict[str, object]: + # returns GuestFilesystemTrimResponse + ret =3D getattr(self.qga, 'fstrim')(minimum=3Dminimum) + assert isinstance(ret, dict) + return ret =20 - def suspend(self, mode): + def suspend(self, mode: str) -> None: if mode not in ['disk', 'ram', 'hybrid']: raise Exception('Invalid mode: ' + mode) =20 try: getattr(self.qga, 'suspend' + '_' + mode)() # On error exception will raise - except self.qga.timeout: + except TimeoutError: # On success command will timed out return =20 - def shutdown(self, mode=3D'powerdown'): + def shutdown(self, mode: str =3D 'powerdown') -> None: if mode not in ['powerdown', 'halt', 'reboot']: raise Exception('Invalid mode: ' + mode) =20 try: self.qga.shutdown(mode=3Dmode) - except self.qga.timeout: - return + except TimeoutError: + pass =20 =20 -def _cmd_cat(client, args): +def _cmd_cat(client: QemuGuestAgentClient, args: Sequence[str]) -> None: if len(args) !=3D 1: print('Invalid argument') print('Usage: cat ') @@ -187,7 +198,7 @@ def _cmd_cat(client, args): print(client.read(args[0])) =20 =20 -def _cmd_fsfreeze(client, args): +def _cmd_fsfreeze(client: QemuGuestAgentClient, args: Sequence[str]) -> No= ne: usage =3D 'Usage: fsfreeze status|freeze|thaw' if len(args) !=3D 1: print('Invalid argument') @@ -201,13 +212,14 @@ def _cmd_fsfreeze(client, args): ret =3D client.fsfreeze(cmd) if cmd =3D=3D 'status': print(ret) - elif cmd =3D=3D 'freeze': - print("%d filesystems frozen" % ret) - else: - print("%d filesystems thawed" % ret) + return =20 + assert isinstance(ret, int) + verb =3D 'frozen' if cmd =3D=3D 'freeze' else 'thawed' + print(f"{ret:d} filesystems {verb}") =20 -def _cmd_fstrim(client, args): + +def _cmd_fstrim(client: QemuGuestAgentClient, args: Sequence[str]) -> None: if len(args) =3D=3D 0: minimum =3D 0 else: @@ -215,28 +227,25 @@ def _cmd_fstrim(client, args): print(client.fstrim(minimum)) =20 =20 -def _cmd_ifconfig(client, args): +def _cmd_ifconfig(client: QemuGuestAgentClient, args: Sequence[str]) -> No= ne: assert not args print(client.ifconfig()) =20 =20 -def _cmd_info(client, args): +def _cmd_info(client: QemuGuestAgentClient, args: Sequence[str]) -> None: assert not args print(client.info()) =20 =20 -def _cmd_ping(client, args): - if len(args) =3D=3D 0: - timeout =3D 3 - else: - timeout =3D float(args[0]) +def _cmd_ping(client: QemuGuestAgentClient, args: Sequence[str]) -> None: + timeout =3D 3.0 if len(args) =3D=3D 0 else float(args[0]) alive =3D client.ping(timeout) if not alive: print("Not responded in %s sec" % args[0]) sys.exit(1) =20 =20 -def _cmd_suspend(client, args): +def _cmd_suspend(client: QemuGuestAgentClient, args: Sequence[str]) -> Non= e: usage =3D 'Usage: suspend disk|ram|hybrid' if len(args) !=3D 1: print('Less argument') @@ -249,7 +258,7 @@ def _cmd_suspend(client, args): client.suspend(args[0]) =20 =20 -def _cmd_shutdown(client, args): +def _cmd_shutdown(client: QemuGuestAgentClient, args: Sequence[str]) -> No= ne: assert not args client.shutdown() =20 @@ -257,12 +266,12 @@ def _cmd_shutdown(client, args): _cmd_powerdown =3D _cmd_shutdown =20 =20 -def _cmd_halt(client, args): +def _cmd_halt(client: QemuGuestAgentClient, args: Sequence[str]) -> None: assert not args client.shutdown('halt') =20 =20 -def _cmd_reboot(client, args): +def _cmd_reboot(client: QemuGuestAgentClient, args: Sequence[str]) -> None: assert not args client.shutdown('reboot') =20 @@ -270,7 +279,7 @@ def _cmd_reboot(client, args): commands =3D [m.replace('_cmd_', '') for m in dir() if '_cmd_' in m] =20 =20 -def send_command(address, cmd, args): +def send_command(address: str, cmd: str, args: Sequence[str]) -> None: if not os.path.exists(address): print('%s not found' % address) sys.exit(1) @@ -296,7 +305,7 @@ def send_command(address, cmd, args): globals()['_cmd_' + cmd](client, args) =20 =20 -def main(): +def main() -> None: address =3D os.environ.get('QGA_CLIENT_ADDRESS') =20 parser =3D argparse.ArgumentParser() --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823659; cv=none; d=zohomail.com; s=zohoarc; b=V4+dA+OQMKGWwrs+Kfd7Z95rpiNhaUKXn9MgDy2squ80v5vqli390/A4LYnnIW+ATyPHA19VNQETrGQiTOdkP40YAkaYSXZXKrgrRCc6HlIFGi+j2npDagv52OKYwgZeUXaQLcIOsrRMFSGIWz2bLgAD/r5waGwypkY4RyPHGo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823659; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r5vLY16QvF+td5iUGMjYO4zRXpAnwEeyKBzMDgKyfN4=; b=XzmEzydU8viI7Q4Hbo4+oQU+9ncF1Ne+BTPNWQxAUzHaQXfJnPKW4DBVxpC0tr3C8xDZKh8p6w0OO3ZKk9ybJLYwd0qL7THSCby2/MOkgsUBPNjCclZmqX/cXa/bU13nWIg9mP882fSE0HgZXIZh117p/8YV0/qGRZ6uBxxXnDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622823659289912.1764395693963; Fri, 4 Jun 2021 09:20:59 -0700 (PDT) Received: from localhost ([::1]:42072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCZ8-0002CC-0T for importer2@patchew.org; Fri, 04 Jun 2021 12:20:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAu-0001Ef-D2 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAl-0001Vp-V8 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-g24e0QmAMKeRMTxRCM8D1g-1; Fri, 04 Jun 2021 11:55:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C2398042A9; Fri, 4 Jun 2021 15:55:43 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87CA05B4A4; Fri, 4 Jun 2021 15:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r5vLY16QvF+td5iUGMjYO4zRXpAnwEeyKBzMDgKyfN4=; b=Cq5jAD08DOBmpJNYPLl21cgaggt5wWkpZEqeIErfKAK0VhznDOvzMTlY125RQmEaFHzuzJ Rfi7G2pHX8jjRkyluT7cAKw79ysCkIh5IxM/acOh27IXL7GnV4HI+p9cpNo+zk1sj7V9gk Herx7MEwniZGCZGmAyA0xPR3mKujm0o= X-MC-Unique: g24e0QmAMKeRMTxRCM8D1g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 09/11] scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py Date: Fri, 4 Jun 2021 11:55:30 -0400 Message-Id: <20210604155532.1499282-10-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The script itself will be unavailable for a few commits before being restored, with no way to run it right after this commit. This helps move git history into the new file. To prevent linter regressions, though, we do need to immediately touch up the filename to remove dashes (to make the module importable), and remove the executable bit. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client =3D> python/qemu/qmp/qemu_ga_client.py | 2 -- 1 file changed, 2 deletions(-) rename scripts/qmp/qemu-ga-client =3D> python/qemu/qmp/qemu_ga_client.py (= 99%) diff --git a/scripts/qmp/qemu-ga-client b/python/qemu/qmp/qemu_ga_client.py similarity index 99% rename from scripts/qmp/qemu-ga-client rename to python/qemu/qmp/qemu_ga_client.py index a7d0ef8347..d2938ad47c 100755 --- a/scripts/qmp/qemu-ga-client +++ b/python/qemu/qmp/qemu_ga_client.py @@ -52,8 +52,6 @@ Sequence, ) =20 - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp from qemu.qmp import SocketAddrT =20 --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823804; cv=none; d=zohomail.com; s=zohoarc; b=YLoY+cpFkY6acTmy8HHMAycRi8kAAaiOEedCcjw/gJG845YtPm3dWe0G3GMBxwR9TI40ebLeT0EQVkp9RXhEsupK5UuTFdArUGFCTnBkQgEPfoNULUbo66KDWl09zu+PQQ/RvhFRtj4J4QLv5+wgZI6KuV8ukHiIepzj8nKC+2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823804; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pVOVgW4XOJaSUHs2A9nKoYwOQNkUz6BRnI9FXfz8z4Y=; b=FN9qdU0mAQcKoTC8dbYwB2lorDZYoRK1FlXfQY9SlLOZhefZNv1e8nEGKb0ApAERz0rFDreW+bXLP5M+jjU3rmugQhYGLtfi8g7EGtlCsqcLjH3tA3tOXiGioqWgFT2ux87kLpnsifpEn7or72O092vCv6aJP6X7+KYOCFbQdPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622823804267211.5481196495124; Fri, 4 Jun 2021 09:23:24 -0700 (PDT) Received: from localhost ([::1]:50176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCbT-0007wz-H6 for importer2@patchew.org; Fri, 04 Jun 2021 12:23:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAv-0001KD-Rz for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAm-0001Wm-02 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-__L2NlMCNoqZ3Iocs63xNQ-1; Fri, 04 Jun 2021 11:55:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 332AA10CE781; Fri, 4 Jun 2021 15:55:44 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 751835B4A4; Fri, 4 Jun 2021 15:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pVOVgW4XOJaSUHs2A9nKoYwOQNkUz6BRnI9FXfz8z4Y=; b=ITjLixzdQvHC3+AE+hac1HzwPrJP/0CQqxxj/UxnBFIZVOUMIkFCOejXOwZQWTIt6FbMrF qui8NxacR8Na6ETgl5Q3BzPC4aj4ZtZzHs+hHykHCEVMffEJ7LKIYpBv/UzGuX/Rl4jfJe +m2rwrAvMe0g/d2voH3fE0NSUlEehr4= X-MC-Unique: __L2NlMCNoqZ3Iocs63xNQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 10/11] python/qemu-ga-client: add entry point Date: Fri, 4 Jun 2021 11:55:31 -0400 Message-Id: <20210604155532.1499282-11-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Remove the shebang, and add a package-defined entry point instead. Now, it can be accessed using 'qemu-ga-client' from the command line after installing the package. The next commit adds a forwarder shim that allows the running of this script without needing to install the package again. Signed-off-by: John Snow --- python/qemu/qmp/qemu_ga_client.py | 2 -- python/setup.cfg | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) mode change 100755 =3D> 100644 python/qemu/qmp/qemu_ga_client.py diff --git a/python/qemu/qmp/qemu_ga_client.py b/python/qemu/qmp/qemu_ga_cl= ient.py old mode 100755 new mode 100644 index d2938ad47c..67ac0b4211 --- a/python/qemu/qmp/qemu_ga_client.py +++ b/python/qemu/qmp/qemu_ga_client.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - """ QEMU Guest Agent Client =20 diff --git a/python/setup.cfg b/python/setup.cfg index 6b6be8b03c..7f3c59d74e 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -50,6 +50,7 @@ console_scripts =3D qom-list =3D qemu.qmp.qom:QOMList.entry_point qom-tree =3D qemu.qmp.qom:QOMTree.entry_point qom-fuse =3D qemu.qmp.qom_fuse:QOMFuse.entry_point [fuse] + qemu-ga-client =3D qemu.qmp.qemu_ga_client:main =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's --=20 2.31.1 From nobody Mon May 6 04:50:11 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622823983; cv=none; d=zohomail.com; s=zohoarc; b=YPZEWLg/g8plVsC1EjT/G6LjUThtIPg/dIpKgA6j1aev8r5T+b+7f98cq/KdhMNLRRJffXe6U4Gb51pKuhfITcemQNiXpWtAc/PdGNWKyiZKjudPwtvsk9dTSuoqAnMHQELZVsxjJ5b5WUICadeamP3xjVqNdcZQnzeaLnDDU3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622823983; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TzPV9CgOJaFpL4vWMvp4NcJALn7nIyGj2HsGlAmaJnQ=; b=dVNSWie45UFsWC0s1vxGlGTygwo4iSaguUCgXmR+Vf91uskHXGVsVqpIfKEzkLUhNkKyqLMZ0PwrX94t/X2d1KrvXlR3rA94vrbUX6/sahkv809jRatrQsuIVdEdpO+vegvuQwegPBqwwxNKLPnTmKVJlnlI4J50bfA00bw+Ne8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162282398354872.48550693826871; Fri, 4 Jun 2021 09:26:23 -0700 (PDT) Received: from localhost ([::1]:33906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCeM-0007XY-Il for importer2@patchew.org; Fri, 04 Jun 2021 12:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAt-0001CZ-Tw for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCAn-0001XB-Qk for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:55:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-108-WLUVfOIvPVmao6B83HwmXQ-1; Fri, 04 Jun 2021 11:55:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FBFF9F92C; Fri, 4 Jun 2021 15:55:45 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A95B5B4A4; Fri, 4 Jun 2021 15:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TzPV9CgOJaFpL4vWMvp4NcJALn7nIyGj2HsGlAmaJnQ=; b=UCUj5KIqV/0J69I8xfDWOdIkvPtDwv4I+lR+SV6qMcDG+A7bED701C4pQuxSrBmdgUZdWM 9b8+NzQutydaiWxaH0uygAQC5nrrcgqaN1hGJ8NTBe1GgmFfeLNGMxi9T89F/3XC4XTvGP 1dkGXZNavp8hRLXEFzOJuM5sJUBhQGQ= X-MC-Unique: WLUVfOIvPVmao6B83HwmXQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 11/11] scripts/qemu-ga-client: Add forwarder shim Date: Fri, 4 Jun 2021 11:55:32 -0400 Message-Id: <20210604155532.1499282-12-jsnow@redhat.com> In-Reply-To: <20210604155532.1499282-1-jsnow@redhat.com> References: <20210604155532.1499282-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , John Snow , "Niteesh G . S ." , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add a little forwarder shim until we are sure that everyone is comfortable with how to use the tools in their new packaged location. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/qmp/qemu-ga-client diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client new file mode 100755 index 0000000000..102fd2cad9 --- /dev/null +++ b/scripts/qmp/qemu-ga-client @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import qemu_ga_client + + +if __name__ =3D=3D '__main__': + sys.exit(qemu_ga_client.main()) --=20 2.31.1