From nobody Fri May 3 00:29:35 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=1622680732; cv=none; d=zohomail.com; s=zohoarc; b=bpApG9htaUqsDMTZo6GfbXFpekeDyZSj/uncygHcgMWsyo9fkPHuydaEGG8W4OZ10dCOcBRDOMopDID20NrmC0TPZjT788nU1ZkjckLwLvY1Vagw4L+sWreqMgWhNZ5rT+hDTKVc79A6RKXPW65B8UAvOTF+LFHo88T2s+RUwy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680732; 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=Xe5J7uEXnYUxYup+4J75GPBTU88JI9isFkDu2VPG0pc=; b=E0RKiv3NUqB3O64XTGcnkjQ90OEPIF54G9RB7AEL/SSYa1oVrf+8b738DK8SxTxxRQH1JE8C3o2sQxXWmVpEpyZICmzratk2bAO4lPOAF55Cba2ATMkwgGebupIWZ/Q/chihjrk3QLdVUBVAc/4ges6FxHyh28Xk003UkQb/mfw= 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 1622680732873429.6143677867425; Wed, 2 Jun 2021 17:38:52 -0700 (PDT) Received: from localhost ([::1]:52182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobNr-0006oW-Q1 for importer2@patchew.org; Wed, 02 Jun 2021 20:38:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMW-00047u-31 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMT-0004Th-M7 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:27 -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-361-dGEtUUYLMLOVTWNevWeN1w-1; Wed, 02 Jun 2021 20:37:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86E42803620; Thu, 3 Jun 2021 00:37:21 +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 C981910013D6; Thu, 3 Jun 2021 00:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680644; 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=Xe5J7uEXnYUxYup+4J75GPBTU88JI9isFkDu2VPG0pc=; b=WOIoBeiWEXd/iQmIsinO56Px6mDkcJBo45zA8xGJmfDv5SMPPiHk6a6A4RphyKR6qim6QJ f7DJcIYM0bMixwLb1IoFuD4ayU8FPA7NF5Ud87/rikFN13UT9+7yg73hAXhpjZoveA/hN+ HAlWxR/1V0MjOXFM6eBjdBMYxBDC32s= X-MC-Unique: dGEtUUYLMLOVTWNevWeN1w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 01/19] python/pipenv: Update Pipfile.lock Date: Wed, 2 Jun 2021 20:37:01 -0400 Message-Id: <20210603003719.1321369-2-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" In a previous commit, I added tox to the development requirements of the Python library. I never bothered to add them to the Pipfile, because they aren't needed there. Here, I sync it anyway in its own commit so that when we add new packages later that the diffstats will not confusingly appear to pull in lots of extra packages. Ideally I could tell Pipenv simply not to install these, but it doesn't seem to support that, exactly. The alternative is removing Tox from the development requires, which I'd rather not do. The other alternative is re-specifying all of the dependencies of setup.cfg in the Pipfile, which I'd also rather not do. Picking what feels least-worst here. Signed-off-by: John Snow --- python/Pipfile.lock | 91 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 3 deletions(-) diff --git a/python/Pipfile.lock b/python/Pipfile.lock index 6e344f5fadf..f2a3f91d0fa 100644 --- a/python/Pipfile.lock +++ b/python/Pipfile.lock @@ -22,6 +22,13 @@ } }, "develop": { + "appdirs": { + "hashes": [ + "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d241510= 0fe26e27afdf41", + "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4= 650ca1055ab128" + ], + "version": "=3D=3D1.4.4" + }, "astroid": { "hashes": [ "sha256:4db03ab5fc3340cf619dbc25e42c2cc3755154ce6009469766= d7143d1fc2ee4e", @@ -38,6 +45,20 @@ "markers": "python_version >=3D '3.6'", "version": "=3D=3D88.1" }, + "distlib": { + "hashes": [ + "sha256:106fef6dc37dd8c0e2c0a60d3fca3e77460a48907f335fa284= 20463a6f799736", + "sha256:23e223426b28491b1ced97dc3bbe183027419dfc7982b4fa2f= 05d5f3ff10711c" + ], + "version": "=3D=3D0.3.2" + }, + "filelock": { + "hashes": [ + "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0= f82159d6a6ff59", + "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10d= a9b879fef15836" + ], + "version": "=3D=3D3.0.12" + }, "flake8": { "hashes": [ "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b= 6b1d78057c576b", @@ -54,6 +75,14 @@ "markers": "python_version < '3.8'", "version": "=3D=3D4.0.1" }, + "importlib-resources": { + "hashes": [ + "sha256:54161657e8ffc76596c4ede7080ca68cb02962a2e074a2586b= 695a93a925d36e", + "sha256:e962bff7440364183203d179d7ae9ad90cb1f2b74dcb84300e= 88ecc42dca3351" + ], + "markers": "python_version < '3.7'", + "version": "=3D=3D5.1.4" + }, "isort": { "hashes": [ "sha256:0a943902919f65c5684ac4e0154b1ad4fac6dcaa5d9f3426b7= 32f1c8b5419be6", @@ -132,6 +161,30 @@ ], "version": "=3D=3D0.4.3" }, + "packaging": { + "hashes": [ + "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a23037= 4cc1fd776feae5", + "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21= f051443c20947a" + ], + "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", + "version": "=3D=3D20.9" + }, + "pluggy": { + "hashes": [ + "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604c= f808bfa1c765b0", + "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e= 9ca461a4081d2d" + ], + "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", + "version": "=3D=3D0.13.1" + }, + "py": { + "hashes": [ + "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a= 809035269e1bd3", + "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d= 02d9d58d18818a" + ], + "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", + "version": "=3D=3D1.10.0" + }, "pycodestyle": { "hashes": [ "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808= c17089be302068", @@ -156,18 +209,42 @@ "markers": "python_version ~=3D '3.6'", "version": "=3D=3D2.8.2" }, + "pyparsing": { + "hashes": [ + "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ea= d507bc3246ecc1", + "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb124= 0a85b024efc88b" + ], + "markers": "python_version >=3D '2.6' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", + "version": "=3D=3D2.4.7" + }, "qemu": { "editable": true, "path": "." }, + "six": { + "hashes": [ + "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e= 49de9c60c4c926", + "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771= 326f8aa26e0254" + ], + "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", + "version": "=3D=3D1.16.0" + }, "toml": { "hashes": [ "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894= a5f779cabb4f9b", "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bd= ed2f839ccbe68f" ], - "markers": "python_version >=3D '2.6' and python_version not i= n '3.0, 3.1, 3.2'", + "markers": "python_version >=3D '2.6' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", "version": "=3D=3D0.10.2" }, + "tox": { + "hashes": [ + "sha256:307a81ddb82bd463971a273f33e9533a24ed22185f27db8ce3= 386bff27d324e3", + "sha256:b0b5818049a1c1997599d42012a637a33f24c62ab8187223fd= d318fa8522637b" + ], + "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "=3D=3D3.23.1" + }, "typed-ast": { "hashes": [ "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060= be5dad2c730ace", @@ -201,7 +278,7 @@ "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb= 4530f96fe5ef2f", "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23= c13016b7f5ec65" ], - "markers": "implementation_name =3D=3D 'cpython' and python_ve= rsion < '3.8'", + "markers": "python_version < '3.8' and implementation_name =3D= =3D 'cpython'", "version": "=3D=3D1.4.3" }, "typing-extensions": { @@ -213,6 +290,14 @@ "markers": "python_version < '3.8'", "version": "=3D=3D3.10.0.0" }, + "virtualenv": { + "hashes": [ + "sha256:14fdf849f80dbb29a4eb6caa9875d476ee2a5cf76a5f5415fa= 2f1606010ab467", + "sha256:2b0126166ea7c9c3661f5b8e06773d28f83322de7a3ff7d06f= 0aed18c9de6a76" + ], + "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", + "version": "=3D=3D20.4.7" + }, "wrapt": { "hashes": [ "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec= 1eb88e6d9b97d7" @@ -224,7 +309,7 @@ "sha256:3607921face881ba3e026887d8150cca609d517579abe052ac= 81fc5aeffdbd76", "sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea= 5a63edc3e03098" ], - "markers": "python_version >=3D '3.6'", + "markers": "python_version < '3.10'", "version": "=3D=3D3.4.1" } } --=20 2.31.1 From nobody Fri May 3 00:29:35 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=1622680731; cv=none; d=zohomail.com; s=zohoarc; b=Y67TNbDhXLlGcAftRweVG3YlVS1l6/XT/OTRXmFl93Xyh+7smUZn2N0+0yttcu4hb/yH02VVtlw/jAh+xyu/2hJzPaTK40s9nAtXKPEql0igPQ4memmo+E3AjhcUdbMRtS/DvLfYKKjkecjZ+y5X9PSmBw9cNIMmC3vBVSNmMYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680731; 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=BlML2KWf7Wrpq1uH77fBgwovpRG+a87R9LrvHMGlJ6c=; b=GUORVeh5A8yvbaQNDz/pS+rWmjJksb37AZ26RG/rNsULHJ8zhmT04lmu+5SlmTcvzQVOgpMWhY51OoUIH9jTOS3u8cIisRhhyi2emAz+TdDbZXW2TLsdjBL42iRVGo8jq9CbQArV/ZatL4RYL8roYlf28c4WLFhRIxSexr4PoSg= 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 1622680731156432.09122392442407; Wed, 2 Jun 2021 17:38:51 -0700 (PDT) Received: from localhost ([::1]:52012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobNq-0006hz-1B for importer2@patchew.org; Wed, 02 Jun 2021 20:38:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMW-00047s-1h for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMT-0004Tr-Q0 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:27 -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-411-V0Hsj7jUPVueAuygSmbWOQ-1; Wed, 02 Jun 2021 20:37:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C141180FD62; Thu, 3 Jun 2021 00:37:22 +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 AD2B810013D6; Thu, 3 Jun 2021 00:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680644; 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=BlML2KWf7Wrpq1uH77fBgwovpRG+a87R9LrvHMGlJ6c=; b=Q0OjIaq30PqYDaOHrX+miQoU8oesdCDdr5NsEQJyq42Z3ttx9TfJxpPnmePwpyit3IHrM3 8QSWAOhRTmodlQVBzbO8JYJS8KFmOMJ+F/7WbgCnT5gC/JdgdCQNINjZ6Q6F2LodURwPM7 Em9M2pO1SHNGI/KbetkstnhiXvzC8Qs= X-MC-Unique: V0Hsj7jUPVueAuygSmbWOQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 02/19] python/qmp: Fix type of SocketAddrT Date: Wed, 2 Jun 2021 20:37:02 -0400 Message-Id: <20210603003719.1321369-3-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" In porting the qom tools, qmp-shell, etc; it becomes evident that this type is wrong. This is an integer, not a string. We didn't catch this before because none of QEMUMonitorProtocol's *users* happen to be checked, and the internal logic of this class is otherwise self-consistent. Additionally, mypy was not introspecting into the socket() interface to realize we were passing a bad type for AF_INET. Fixed now. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qmp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 9606248a3d2..5fb970f8a80 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -44,7 +44,7 @@ QMPMessage =3D Dict[str, Any] QMPReturnValue =3D Dict[str, Any] =20 -InternetAddrT =3D Tuple[str, str] +InternetAddrT =3D Tuple[str, int] UnixAddrT =3D str SocketAddrT =3D Union[InternetAddrT, UnixAddrT] =20 --=20 2.31.1 From nobody Fri May 3 00:29:35 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=1622680732; cv=none; d=zohomail.com; s=zohoarc; b=fhBu91QYB3lvqXrdAqhj1CFN4tX+IsT7epg24tTNpsAGvPw5kjmHp2K1AiMY9bXp7vO5eKnDkV56B5rBRjXqhJNE+upUCUYWX9PRiTEJRa0S1lorZRFgz5+VhuLzy2uXr+F4l4IUSwp8tbe6Uvwd173C2MjW4+vSEu6AJOwcmhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680732; 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=diSv2aOelwwD3NmaQRLGaZ5QS8R3qiDmQc3DVTR0XyQ=; b=SGKv9wGzs8YV2yOY9pIZ7MSgVQtEMx/a3JZzLBhobKB9l4Pz6s3YqjJh5vOjBqNlP9/de91IwWBCz+RJBPSVn9ri38xGn64TNkxqtpISYUYgDeVKrOWGHUNlsiH+WBvasgA82PRQUmZDpj/PLmYUXp++8hU38GbHlQaPVOHLTjI= 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 1622680732436187.70419939177646; Wed, 2 Jun 2021 17:38:52 -0700 (PDT) Received: from localhost ([::1]:52066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobNr-0006k0-Aa for importer2@patchew.org; Wed, 02 Jun 2021 20:38:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMW-00048H-PT for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMU-0004Um-CL for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:28 -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-346-v6lq18vSMNilZ8TWuNNUjA-1; Wed, 02 Jun 2021 20:37:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54415343A2; Thu, 3 Jun 2021 00:37:23 +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 92A5B10013D6; Thu, 3 Jun 2021 00:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680645; 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=diSv2aOelwwD3NmaQRLGaZ5QS8R3qiDmQc3DVTR0XyQ=; b=XKCZ7o0CizJUjQaIiqToFj/9ncVS3akSO82UJz6YKFKdfGyb/TsrkPztRactkhqKLHCfid 9h7iEz1ooUAmDtJ9muRB7MAfixKjbHBFf/w8VmsE8918VIr1gSAUldUtguGLWj2K6BB47H Ed0l/mK6wt7YjIyOIwUGYo8diHXg1Kg= X-MC-Unique: v6lq18vSMNilZ8TWuNNUjA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 03/19] python/qmp: add parse_address classmethod Date: Wed, 2 Jun 2021 20:37:03 -0400 Message-Id: <20210603003719.1321369-4-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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 takes the place of qmp-shell's __get_address function. It also allows other utilities to share the same parser and syntax for specifying QMP locations. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 26 ++++++++++++++++++++++++++ scripts/qmp/qmp-shell | 21 ++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 5fb970f8a80..822c793c320 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -92,6 +92,12 @@ def __init__(self, reply: QMPMessage): self.reply =3D reply =20 =20 +class QMPBadPortError(QMPError): + """ + Unable to parse socket address: Port was non-numerical. + """ + + class QEMUMonitorProtocol: """ Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and = then @@ -219,6 +225,26 @@ def __exit__(self, # Implement context manager exit function. self.close() =20 + @classmethod + def parse_address(cls, address: str) -> SocketAddrT: + """ + Parse a string into a QMP address. + + Figure out if the argument is in the port:host form. + If it's not, it's probably a file path. + """ + components =3D address.split(':') + if len(components) =3D=3D 2: + try: + port =3D int(components[1]) + except ValueError: + msg =3D f"Bad port: '{components[1]}' in '{address}'." + raise QMPBadPortError(msg) from None + return (components[0], port) + + # Treat as filepath. + return address + def connect(self, negotiate: bool =3D True) -> Optional[QMPMessage]: """ Connect to the QMP Monitor and perform capabilities negotiation. diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index b4d06096abd..d5ae8a9b212 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -89,8 +89,6 @@ class QMPCompleter(list): class QMPShellError(Exception): pass =20 -class QMPShellBadPort(QMPShellError): - pass =20 class FuzzyJSON(ast.NodeTransformer): '''This extension of ast.NodeTransformer filters literal "true/false/n= ull" @@ -109,7 +107,7 @@ class FuzzyJSON(ast.NodeTransformer): # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address, pretty=3DFalse): - super(QMPShell, self).__init__(self.__get_address(address)) + super(QMPShell, self).__init__(self.parse_address(address)) self._greeting =3D None self._completer =3D None self._pretty =3D pretty @@ -118,21 +116,6 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._histfile =3D os.path.join(os.path.expanduser('~'), '.qmp-shell_history') =20 - def __get_address(self, arg): - """ - Figure out if the argument is in the port:host form, if it's not i= t's - probably a file path. - """ - addr =3D arg.split(':') - if len(addr) =3D=3D 2: - try: - port =3D int(addr[1]) - except ValueError: - raise QMPShellBadPort - return ( addr[0], port ) - # socket path - return arg - def _fill_completion(self): cmds =3D self.cmd('query-commands') if 'error' in cmds: @@ -437,7 +420,7 @@ def main(): =20 if qemu is None: fail_cmdline() - except QMPShellBadPort: + except qmp.QMPBadPortError: die('bad port number in command-line') =20 try: --=20 2.31.1 From nobody Fri May 3 00:29:35 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=1622681017; cv=none; d=zohomail.com; s=zohoarc; b=Ly4DT1trETpDWQHmU6KcXlUqK3/hHNwnl1FBumcEXgKMvkDoTMkBI0Szon5tno5O0/iVbYipFhmt9uhRiCKPDTTJBLPAbER5FpBYY9Lt+rLfBX1E5LUeQPDMyoFpbQmvBIcRG6MXkXvYEnqXO1STI7X3srx9gSemRoJt2CpHuEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681017; 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=sHWibOCfgQKqxWoyLi84+DstXN/gMqe7JQBCkazBMAA=; b=kuHwvHCC2FOrYIal1vF8Wr9iaiPu9KC/OtUBZtp6LXi7bie22i5j0XQxZtJNZqdWE0RABYYig/d+ptdEz+yOJMr7F/WtAaTnztC952b4mB4+7Vu/zOqeBLN4oSZw2cRjuVPx99UU3auNy7aAlopTSWEpa3bToH4rjiuYEGWkKcw= 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 1622681017766634.0058405334061; Wed, 2 Jun 2021 17:43:37 -0700 (PDT) Received: from localhost ([::1]:40168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobSS-0000oo-Mh for importer2@patchew.org; Wed, 02 Jun 2021 20:43:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMZ-0004Cp-Kd for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMX-0004Yx-53 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:31 -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-162-IzWsjS_hP8iz8gAKv-Mkuw-1; Wed, 02 Jun 2021 20:37:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B230107ACE6; Thu, 3 Jun 2021 00:37:24 +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 7BD9310013D6; Thu, 3 Jun 2021 00:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680648; 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=sHWibOCfgQKqxWoyLi84+DstXN/gMqe7JQBCkazBMAA=; b=WGzdEouy9oZUA9kps+fEyg4EgVmf0v4MyrOZUl5dTMv+9dhHwmYYCDVYyi69b0ZGU8cUXD l9CakEKeDSbvMEQHDHsOWrFH5qiIQz7MnoWNNQ+8gp+8S2yugMHd/pk0Div7OjG9LDmBA2 CqVPmNvymxzysmvLf3O8rXYaRhLWIzg= X-MC-Unique: IzWsjS_hP8iz8gAKv-Mkuw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 04/19] python/qmp: Add qom script rewrites Date: Wed, 2 Jun 2021 20:37:04 -0400 Message-Id: <20210603003719.1321369-5-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" Inspired by qom-set, qom-get, qom-tree and qom-list; combine all four of those scripts into a single script. A later addition of qom-fuse as an 'extension' necessitates that some common features are split out and shared between them. Signed-off-by: John Snow --- python/qemu/qmp/qom.py | 262 ++++++++++++++++++++++++++++++++++ python/qemu/qmp/qom_common.py | 178 +++++++++++++++++++++++ 2 files changed, 440 insertions(+) create mode 100644 python/qemu/qmp/qom.py create mode 100644 python/qemu/qmp/qom_common.py diff --git a/python/qemu/qmp/qom.py b/python/qemu/qmp/qom.py new file mode 100644 index 00000000000..7fe1448b5d9 --- /dev/null +++ b/python/qemu/qmp/qom.py @@ -0,0 +1,262 @@ +""" +QEMU Object Model testing tools. + +usage: qom [-h] {set,get,list,tree} ... + +Query and manipulate QOM data + +optional arguments: + -h, --help show this help message and exit + +QOM commands: + {set,get,list,tree} + set Set a QOM property value + get Get a QOM property value + list List QOM properties at a given path + tree Show QOM tree from a given path +""" +## +# Copyright John Snow 2020, for Red Hat, Inc. +# Copyright IBM, Corp. 2011 +# +# Authors: +# John Snow +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Based on ./scripts/qmp/qom-[set|get|tree|list] +## + +import argparse + +from . import QMPResponseError +from .qom_common import QOMCommand + + +class QOMSet(QOMCommand): + """ + QOM Command - Set a property to a given value. + + usage: qom-set [-h] [--socket SOCKET] . + + Set a QOM property value + + positional arguments: + . QOM path and property, separated by a period '= .' + new QOM property value + + optional arguments: + -h, --help show this help message and exit + --socket SOCKET, -s SOCKET + QMP socket path or address (addr:port). May al= so be + set via QMP_SOCKET environment variable. + """ + name =3D 'set' + help =3D 'Set a QOM property value' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + cls.add_path_prop_arg(parser) + parser.add_argument( + 'value', + metavar=3D'', + action=3D'store', + help=3D'new QOM property value' + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.path, self.prop =3D args.path_prop.rsplit('.', 1) + self.value =3D args.value + + def run(self) -> int: + rsp =3D self.qmp.command( + 'qom-set', + path=3Dself.path, + property=3Dself.prop, + value=3Dself.value + ) + print(rsp) + return 0 + + +class QOMGet(QOMCommand): + """ + QOM Command - Get a property's current value. + + usage: qom-get [-h] [--socket SOCKET] . + + Get a QOM property value + + positional arguments: + . QOM path and property, separated by a period '= .' + + optional arguments: + -h, --help show this help message and exit + --socket SOCKET, -s SOCKET + QMP socket path or address (addr:port). May al= so be + set via QMP_SOCKET environment variable. + """ + name =3D 'get' + help =3D 'Get a QOM property value' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + cls.add_path_prop_arg(parser) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + try: + tmp =3D args.path_prop.rsplit('.', 1) + except ValueError as err: + raise ValueError('Invalid format for .') from = err + self.path =3D tmp[0] + self.prop =3D tmp[1] + + def run(self) -> int: + rsp =3D self.qmp.command( + 'qom-get', + path=3Dself.path, + property=3Dself.prop + ) + if isinstance(rsp, dict): + for key, value in rsp.items(): + print(f"{key}: {value}") + else: + print(rsp) + return 0 + + +class QOMList(QOMCommand): + """ + QOM Command - List the properties at a given path. + + usage: qom-list [-h] [--socket SOCKET] + + List QOM properties at a given path + + positional arguments: + QOM path + + optional arguments: + -h, --help show this help message and exit + --socket SOCKET, -s SOCKET + QMP socket path or address (addr:port). May al= so be + set via QMP_SOCKET environment variable. + """ + name =3D 'list' + help =3D 'List QOM properties at a given path' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + parser.add_argument( + 'path', + metavar=3D'', + action=3D'store', + help=3D'QOM path', + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.path =3D args.path + + def run(self) -> int: + rsp =3D self.qom_list(self.path) + for item in rsp: + if item.child: + print(f"{item.name}/") + elif item.link: + print(f"@{item.name}/") + else: + print(item.name) + return 0 + + +class QOMTree(QOMCommand): + """ + QOM Command - Show the full tree below a given path. + + usage: qom-tree [-h] [--socket SOCKET] [] + + Show QOM tree from a given path + + positional arguments: + QOM path + + optional arguments: + -h, --help show this help message and exit + --socket SOCKET, -s SOCKET + QMP socket path or address (addr:port). May al= so be + set via QMP_SOCKET environment variable. + """ + name =3D 'tree' + help =3D 'Show QOM tree from a given path' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + parser.add_argument( + 'path', + metavar=3D'', + action=3D'store', + help=3D'QOM path', + nargs=3D'?', + default=3D'/' + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.path =3D args.path + + def _list_node(self, path: str) -> None: + print(path) + items =3D self.qom_list(path) + for item in items: + if item.child: + continue + try: + rsp =3D self.qmp.command('qom-get', path=3Dpath, + property=3Ditem.name) + print(f" {item.name}: {rsp} ({item.type})") + except QMPResponseError as err: + print(f" {item.name}: ({item.type})") + print('') + for item in items: + if not item.child: + continue + if path =3D=3D '/': + path =3D '' + self._list_node(f"{path}/{item.name}") + + def run(self) -> int: + self._list_node(self.path) + return 0 + + +def main() -> int: + """QOM script main entry point.""" + parser =3D argparse.ArgumentParser( + description=3D'Query and manipulate QOM data' + ) + subparsers =3D parser.add_subparsers( + title=3D'QOM commands', + dest=3D'command' + ) + + for command in QOMCommand.__subclasses__(): + command.register(subparsers) + + args =3D parser.parse_args() + + if args.command is None: + parser.error('Command not specified.') + return 1 + + cmd_class =3D args.cmd_class + assert isinstance(cmd_class, type(QOMCommand)) + return cmd_class.command_runner(args) diff --git a/python/qemu/qmp/qom_common.py b/python/qemu/qmp/qom_common.py new file mode 100644 index 00000000000..f82b16772df --- /dev/null +++ b/python/qemu/qmp/qom_common.py @@ -0,0 +1,178 @@ +""" +QOM Command abstractions. +""" +## +# Copyright John Snow 2020, for Red Hat, Inc. +# Copyright IBM, Corp. 2011 +# +# Authors: +# John Snow +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Based on ./scripts/qmp/qom-[set|get|tree|list] +## + +import argparse +import os +import sys +from typing import ( + Any, + Dict, + List, + Optional, + Type, + TypeVar, +) + +from . import QEMUMonitorProtocol, QMPError + + +# The following is needed only for a type alias. +Subparsers =3D argparse._SubParsersAction # pylint: disable=3Dprotected-a= ccess + + +class ObjectPropertyInfo: + """ + Represents the return type from e.g. qom-list. + """ + def __init__(self, name: str, type_: str, + description: Optional[str] =3D None, + default_value: Optional[object] =3D None): + self.name =3D name + self.type =3D type_ + self.description =3D description + self.default_value =3D default_value + + @classmethod + def make(cls, value: Dict[str, Any]) -> 'ObjectPropertyInfo': + """ + Build an ObjectPropertyInfo from a Dict with an unknown shape. + """ + assert value.keys() >=3D {'name', 'type'} + assert value.keys() <=3D {'name', 'type', 'description', 'default-= value'} + return cls(value['name'], value['type'], + value.get('description'), + value.get('default-value')) + + @property + def child(self) -> bool: + """Is this property a child property?""" + return self.type.startswith('child<') + + @property + def link(self) -> bool: + """Is this property a link property?""" + return self.type.startswith('link<') + + +CommandT =3D TypeVar('CommandT', bound=3D'QOMCommand') + + +class QOMCommand: + """ + Represents a QOM sub-command. + + :param args: Parsed arguments, as returned from parser.parse_args. + """ + name: str + help: str + + def __init__(self, args: argparse.Namespace): + if args.socket is None: + raise QMPError("No QMP socket path or address given") + self.qmp =3D QEMUMonitorProtocol( + QEMUMonitorProtocol.parse_address(args.socket) + ) + self.qmp.connect() + + @classmethod + def register(cls, subparsers: Subparsers) -> None: + """ + Register this command with the argument parser. + + :param subparsers: argparse subparsers object, from "add_subparser= s". + """ + subparser =3D subparsers.add_parser(cls.name, help=3Dcls.help, + description=3Dcls.help) + cls.configure_parser(subparser) + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + """ + Configure a parser with this command's arguments. + + :param parser: argparse parser or subparser object. + """ + default_path =3D os.environ.get('QMP_SOCKET') + parser.add_argument( + '--socket', '-s', + dest=3D'socket', + action=3D'store', + help=3D'QMP socket path or address (addr:port).' + ' May also be set via QMP_SOCKET environment variable.', + default=3Ddefault_path + ) + parser.set_defaults(cmd_class=3Dcls) + + @classmethod + def add_path_prop_arg(cls, parser: argparse.ArgumentParser) -> None: + """ + Add the . positional argument to this command. + + :param parser: The parser to add the argument to. + """ + parser.add_argument( + 'path_prop', + metavar=3D'.', + action=3D'store', + help=3D"QOM path and property, separated by a period '.'" + ) + + def run(self) -> int: + """ + Run this command. + + :return: 0 on success, 1 otherwise. + """ + raise NotImplementedError + + def qom_list(self, path: str) -> List[ObjectPropertyInfo]: + """ + :return: a strongly typed list from the 'qom-list' command. + """ + rsp =3D self.qmp.command('qom-list', path=3Dpath) + # qom-list returns List[ObjectPropertyInfo] + assert isinstance(rsp, list) + return [ObjectPropertyInfo.make(x) for x in rsp] + + @classmethod + def command_runner( + cls: Type[CommandT], + args: argparse.Namespace + ) -> int: + """ + Run a fully-parsed subcommand, with error-handling for the CLI. + + :return: The return code from `.run()`. + """ + try: + cmd =3D cls(args) + return cmd.run() + except QMPError as err: + print(f"{type(err).__name__}: {err!s}", file=3Dsys.stderr) + return -1 + + @classmethod + def entry_point(cls) -> int: + """ + Build this command's parser, parse arguments, and run the command. + + :return: `run`'s return code. + """ + parser =3D argparse.ArgumentParser(description=3Dcls.help) + cls.configure_parser(parser) + args =3D parser.parse_args() + return cls.command_runner(args) --=20 2.31.1 From nobody Fri May 3 00:29:35 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=1622680849; cv=none; d=zohomail.com; s=zohoarc; b=VfgEQalYq5oFdRFcD1QlD9Ch5Vx9bvDdth8rUPFGTuz9WswuIKn5A+fS+UAK/mxYyjfsiPa59tC7Oe7COjj2Kykt2Au25FTYttHymgJFcfwKs4pAcOV8IkKigEpwEgI1PB1ShcLCGZhG282hdZ9KIy3d2/ynQNRFY5zel51ku6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680849; 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=YX5sSv0wT71TtoBak15hJWH9qkpywTYv11UKwHItHfQ=; b=YZMStB+k3ua5HBthw19/gFaRLco2bXAZoEzqpXDvRKyGG7nS+g9D3aspeQPbnRpmHFLFyPufGbo2Ee6uzR1V9Fd6vE1ceYHRTXPHT/PXCu6Ivkcos2mLh2Hz7KXAWuTX7pSsDgwjAVBoLecDDUISv6ZBauMKX2O+tXekBAJxaQw= 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 1622680849420455.4033650848469; Wed, 2 Jun 2021 17:40:49 -0700 (PDT) Received: from localhost ([::1]:59610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobPk-0003KK-DO for importer2@patchew.org; Wed, 02 Jun 2021 20:40:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMX-00048R-Jl for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMW-0004Xy-1D for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:29 -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-430-ipqGIa06NjOw_jnN1hfcnw-1; Wed, 02 Jun 2021 20:37:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3742A803625; Thu, 3 Jun 2021 00:37:25 +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 61DC410013D6; Thu, 3 Jun 2021 00:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680647; 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=YX5sSv0wT71TtoBak15hJWH9qkpywTYv11UKwHItHfQ=; b=XxBrpp1GkU66/jNrMFFpN9tLPR0+dF/AFStw9lp8gbF9g06T6pHLkXg5gNyHBgnShvWnNC jF1VF0ZHzsvc7tzcldVOcvQdLSLYZoMNHD2Hn8dWv7DpIN91HNwvQqqlN3i/WiWeYiGEnM q15CMQ6dnVZ+fQ9wfBVkKJi5VkNXr3o= X-MC-Unique: ipqGIa06NjOw_jnN1hfcnw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 05/19] python/qmp: add qom script entry points Date: Wed, 2 Jun 2021 20:37:05 -0400 Message-Id: <20210603003719.1321369-6-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.371, 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: Eduardo Habkost , John Snow , Markus Armbruster , "Niteesh G . S ." , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add the 'qom', 'qom-set', 'qom-get', 'qom-list', and 'qom-tree' scripts to the qemu.qmp package. When you install this package, these scripts will become available on your command line. (e.g. when inside of a venv, `cd python && pip install .` will add 'qom', 'qom-set', etc to your $PATH.) Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/setup.cfg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/setup.cfg b/python/setup.cfg index 0fcdec6f322..a19029d5388 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -37,6 +37,14 @@ devel =3D pylint >=3D 2.8.0 tox >=3D 3.18.0 =20 +[options.entry_points] +console_scripts =3D + qom =3D qemu.qmp.qom:main + qom-set =3D qemu.qmp.qom:QOMSet.entry_point + qom-get =3D qemu.qmp.qom:QOMGet.entry_point + qom-list =3D qemu.qmp.qom:QOMList.entry_point + qom-tree =3D qemu.qmp.qom:QOMTree.entry_point + [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's exclude =3D __pycache__, --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622680968; cv=none; d=zohomail.com; s=zohoarc; b=O9H3ugu2rymedmTZ8/bFEjnG8FSDp9jLh+v/UgnXMFi51adpjECnKTf9Y6KhrHPe7L6bzl/XPm3fuJaYzQdw4SG1fz6FIwZf1aUrsdOGC0pcT578HdnOJE7jY2TuOzeVw5iGrQGasXaH8ywiLXAqe7rNAGZvm7gfNzw2YeVTBnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680968; 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=6SEUds+azAouFn0nc6tlij/gyGs+FzsX55ejzmZclBI=; b=X5vADjBHqUKtBdX7kdeKLJN0bqlHgW9TSKIzZJxjhv3Gt9BRLX8pPg5ZohwcSfLSbYDeIjKOf6AOoVd7XXTIvlHUnf8dZDYyhDAhZkOkSBvXgKEaqRjk/Ul74qzsv6FPNcKV2OubAb4qco0AjBRNdesws0zCx09zBKFBqtF3kMk= 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 1622680968372278.95322360288844; Wed, 2 Jun 2021 17:42:48 -0700 (PDT) Received: from localhost ([::1]:37930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobRf-0007jq-9u for importer2@patchew.org; Wed, 02 Jun 2021 20:42:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMb-0004KO-KC for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMZ-0004aJ-EW for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:33 -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-386-i4AG26nyO-6Y4PVs9-GYGQ-1; Wed, 02 Jun 2021 20:37:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC069343A2; Thu, 3 Jun 2021 00:37:28 +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 5E17610013D6; Thu, 3 Jun 2021 00:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680650; 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=6SEUds+azAouFn0nc6tlij/gyGs+FzsX55ejzmZclBI=; b=BoMog1gUJ195agW9sn07Ez8uO3fdZ8/9qflDriwmzyIdeMfI75d3To/5Nmp4YiV79nvcT9 ndvgoKsq/gTV2ejylSRhqOMGwyy8ZpLXNu6QKB2XPkDr+DMwHJTfg5/BTv+sl5Of++M2+O seOw68BINk0ighGiun8e1S+gSROWJhU= X-MC-Unique: i4AG26nyO-6Y4PVs9-GYGQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 06/19] scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/ Date: Wed, 2 Jun 2021 20:37:06 -0400 Message-Id: <20210603003719.1321369-7-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.371, 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: Eduardo Habkost , John Snow , Markus Armbruster , "Niteesh G . S ." , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Redirect to the new qom scripts. These forwarders can be deleted eventually when there has been more time for the dust on the Python packaging to settle and people understand how to find these commands. Note: You can run these by setting $PYTHONPATH in your shell and then running "python3 -m qemu.qmp.qom", or you can install the qemu namespace package and use the "qom" or "qom-set" scripts. I've written how to install the package elsewhere, but for the sake of git-blame, cd to ./python, and then do: - pip3 install [--user] [-e] . --user will install to your local user install (will not work inside of a venv), omitting this flag installs to your system-wide packages (outside of a venv) or to your current virtual environment (inside the venv). When installing to a venv or to your system-wide packages, "qom" should be in your $PATH already. If you do a user install, you may need to add ~/.local/bin to your $PATH if you haven't already. -e installs in editable mode: the installed package is effectively just a symlink to this folder; so changes to your git working tree are reflected in the installed package. Note: installing these packages to an environment outside a venv can be dangerous: Many QEMU scripts will begin to prefer the installed version instead of the version directly in the tree. Use with caution. editable mode is recommended when working outside of a venv. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-get | 66 +++------------------------------------ scripts/qmp/qom-list | 63 +++---------------------------------- scripts/qmp/qom-set | 63 +++---------------------------------- scripts/qmp/qom-tree | 74 +++----------------------------------------- 4 files changed, 16 insertions(+), 250 deletions(-) diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get index 666df718320..e4f3e0c0138 100755 --- a/scripts/qmp/qom-get +++ b/scripts/qmp/qom-get @@ -1,69 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMGet =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] . -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -if len(args) > 0: - try: - path, prop =3D args[0].rsplit('.', 1) - except: - usage_error("invalid format for path/property/value") -else: - usage_error("not enough arguments") - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -rsp =3D srv.command('qom-get', path=3Dpath, property=3Dprop) -if type(rsp) =3D=3D dict: - for i in rsp.keys(): - print('%s: %s' % (i, rsp[i])) -else: - print(rsp) +if __name__ =3D=3D '__main__': + sys.exit(QOMGet.entry_point()) diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list index 5074fd939f4..7a071a54e1e 100755 --- a/scripts/qmp/qom-list +++ b/scripts/qmp/qom-list @@ -1,66 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMList =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] [] -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -if len(args) =3D=3D 0: - print('/') - sys.exit(0) - -for item in srv.command('qom-list', path=3Dargs[0]): - if item['type'].startswith('child<'): - print('%s/' % item['name']) - elif item['type'].startswith('link<'): - print('@%s/' % item['name']) - else: - print('%s' % item['name']) +if __name__ =3D=3D '__main__': + sys.exit(QOMList.entry_point()) diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set index 240a78187f9..9ca9e2ba106 100755 --- a/scripts/qmp/qom-set +++ b/scripts/qmp/qom-set @@ -1,66 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMSet =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None -value =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] . -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -if len(args) > 1: - try: - path, prop =3D args[0].rsplit('.', 1) - except: - usage_error("invalid format for path/property/value") - value =3D args[1] -else: - usage_error("not enough arguments") - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -print(srv.command('qom-set', path=3Dpath, property=3Dprop, value=3Dvalue)) +if __name__ =3D=3D '__main__': + sys.exit(QOMSet.entry_point()) diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree index 25b0781323c..7d0ccca3a4d 100755 --- a/scripts/qmp/qom-tree +++ b/scripts/qmp/qom-tree @@ -1,77 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# Copyright (c) 2013 SUSE LINUX Products GmbH -# -# Authors: -# Anthony Liguori -# Andreas Faerber -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMTree =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] [] -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -def list_node(path): - print('%s' % path) - items =3D srv.command('qom-list', path=3Dpath) - for item in items: - if not item['type'].startswith('child<'): - try: - print(' %s: %s (%s)' % (item['name'], srv.command('qom-ge= t', path=3Dpath, property=3Ditem['name']), item['type'])) - except: - print(' %s: (%s)' % (item['name'], item['type= '])) - print('') - for item in items: - if item['type'].startswith('child<'): - list_node((path if (path !=3D '/') else '') + '/' + item['nam= e']) - -if len(args) =3D=3D 0: - path =3D '/' -else: - path =3D args[0] - -list_node(path) +if __name__ =3D=3D '__main__': + sys.exit(QOMTree.entry_point()) --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681125; cv=none; d=zohomail.com; s=zohoarc; b=mwCQ8G9ofGydJ73kvu9WDtfnvMUd0MkXnjk+dXP5I3ze4gj789fXE/OxotWqjwTRa0mKz2Y2IabS7XDAMDQxaxw03PiAtk6SiJ//jgSmIpyY9yuyiq5ML4t1LnZMn8Qj2+ZJ9gbmXSA/IjLgvS6jrRBsxCMqMd2A4O/5eFrtPMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681125; 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=c8ietWCkWS8WfxGhq2NEpGVBBR54iioG8fuy6yqIgCc=; b=LBct3aQh1S9fZ2EQhqBHs4MKQW2sWZQIIV16nKs8XpFOA795KBYROnjLzrfURbGac8lX91InckArGnVXDzEnMhq3TyGJIm5eT9yJ7HhDqtR/a5HztLAtqGo3t9/EFVWqBSm5LlPI7F8h8FHUTT3hGjBe1GUKLgJohmvlKXnSH3s= 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 1622681125121592.0792707772772; Wed, 2 Jun 2021 17:45:25 -0700 (PDT) Received: from localhost ([::1]:46644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobUC-00057t-1A for importer2@patchew.org; Wed, 02 Jun 2021 20:45:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMc-0004Oo-Qu for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMb-0004dD-Am for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:34 -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-77-Guz-1d09MXSoLRuhE4foig-1; Wed, 02 Jun 2021 20:37:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23F62180FD62; Thu, 3 Jun 2021 00:37:30 +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 D185510013D6; Thu, 3 Jun 2021 00:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680652; 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=c8ietWCkWS8WfxGhq2NEpGVBBR54iioG8fuy6yqIgCc=; b=WiLVaKplf5a8r71ErqZbICKfbzbstgt35XY+gChpSgyUNGk0YNMVe1VXIQV9gNg2jLFukI g/AbIZutZt6jPveWAByS1I9TyQPZLGO6O609Q3w5Hs5rikfHPaEi+h5E7e4OeBHPRZaU0K NonZe6mZ2KhF2mi5BLVRkRtM03aRFdw= X-MC-Unique: Guz-1d09MXSoLRuhE4foig-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 07/19] scripts/qom-fuse: apply isort rules Date: Wed, 2 Jun 2021 20:37:07 -0400 Message-Id: <20210603003719.1321369-8-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.371, 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: Eduardo Habkost , John Snow , Markus Armbruster , "Niteesh G . S ." , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Hint: you can use symlinks to create qom_fuse.py in python/qemu/qmp/ and point to scripts/qom-fuse to apply the standard linting rules to this script. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 7c7cff8edfb..62deb9adb12 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -13,14 +13,20 @@ # the COPYING file in the top-level directory. ## =20 -import fuse, stat -from fuse import FUSE, FuseOSError, Operations -import os, posix, sys from errno import * +import os +import posix +import stat +import sys + +import fuse +from fuse import FUSE, FuseOSError, Operations + =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu.qmp import QEMUMonitorProtocol =20 + fuse.fuse_python_api =3D (0, 2) =20 class QOMFS(Operations): --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681226; cv=none; d=zohomail.com; s=zohoarc; b=BrbNPP1LaobYDZoED/jIgTLzdMH9G2r0OY+iCafNIOAyRYarJlD9IssXcD4qMosaFlBPg+tAJxxrU6EkAP8FgBT66uPNDoKmZ+EYftVBes9Hi6afkSVy9iiVQqLbL6gfqe+0EdySEWFJowLjETK2CclN9jbERy65CldmELui6n8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681226; 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=bX8d0F7Ib3W80+qUXuio1botUN0ZFoaGioAqW1Uy4xY=; b=OdjFiW07V8ylmsyg1Wf5xIsyXtjqSNbNymjnUo5sr2rv8qK8XqwKAbqUJSsaO0XTQKr22PzqxqsfytS9873hVEN84xKfVe29pGxeMUFqFZAsgJUaOEUbctRBNFRSahXChnZTDuVCaBeYJW7DsehpjpeHtaUL2kqkpLhC9gZm4rE= 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 1622681226676390.65852035891953; Wed, 2 Jun 2021 17:47:06 -0700 (PDT) Received: from localhost ([::1]:53072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobVp-00012B-Ol for importer2@patchew.org; Wed, 02 Jun 2021 20:47:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMe-0004U6-A5 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMc-0004en-Gu for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:36 -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-52-_ENTU5yVOfqhoRc7zLM45w-1; Wed, 02 Jun 2021 20:37:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 696011009446; Thu, 3 Jun 2021 00:37:31 +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 6A08510013D6; Thu, 3 Jun 2021 00:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680654; 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=bX8d0F7Ib3W80+qUXuio1botUN0ZFoaGioAqW1Uy4xY=; b=jLnw3QQDnxsoeu5z+4Rv+7IcWyYGv9UPGyY4b1aQAbe/xT+8c2E1xeXyLnLwX/Wom0KQr8 HGHWDlDSqHRBGvYV597U+vY+JNlFCt7dmuKgkzUHQxQhse6zbVUtA3rqtdwsb25csMFIOh FRmuYo2PbaROYGIoZT6vls6YqBdSvUE= X-MC-Unique: _ENTU5yVOfqhoRc7zLM45w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 08/19] scripts/qom-fuse: apply flake8 rules Date: Wed, 2 Jun 2021 20:37:08 -0400 Message-Id: <20210603003719.1321369-9-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" flake8 still has one warning because of the sys.path hack, but that will be going away by the end of this patch series. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 81 +++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 62deb9adb12..ca30e928679 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -9,13 +9,12 @@ # Anthony Liguori # Markus Armbruster # -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. ## =20 -from errno import * +from errno import ENOENT, EPERM import os -import posix import stat import sys =20 @@ -29,6 +28,7 @@ from qemu.qmp import QEMUMonitorProtocol =20 fuse.fuse_python_api =3D (0, 2) =20 + class QOMFS(Operations): def __init__(self, qmp): self.qmp =3D qmp @@ -45,7 +45,7 @@ class QOMFS(Operations): =20 def is_object(self, path): try: - items =3D self.qmp.command('qom-list', path=3Dpath) + self.qmp.command('qom-list', path=3Dpath) return True except: return False @@ -85,7 +85,7 @@ class QOMFS(Operations): path =3D '/' try: data =3D self.qmp.command('qom-get', path=3Dpath, property=3Dp= rop) - data +=3D '\n' # make values shell friendly + data +=3D '\n' # make values shell friendly except: raise FuseOSError(EPERM) =20 @@ -104,38 +104,44 @@ class QOMFS(Operations): =20 def getattr(self, path, fh=3DNone): if self.is_link(path): - value =3D { 'st_mode': 0o755 | stat.S_IFLNK, - 'st_ino': self.get_ino(path), - 'st_dev': 0, - 'st_nlink': 2, - 'st_uid': 1000, - 'st_gid': 1000, - 'st_size': 4096, - 'st_atime': 0, - 'st_mtime': 0, - 'st_ctime': 0 } + value =3D { + 'st_mode': 0o755 | stat.S_IFLNK, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 2, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 + } elif self.is_object(path): - value =3D { 'st_mode': 0o755 | stat.S_IFDIR, - 'st_ino': self.get_ino(path), - 'st_dev': 0, - 'st_nlink': 2, - 'st_uid': 1000, - 'st_gid': 1000, - 'st_size': 4096, - 'st_atime': 0, - 'st_mtime': 0, - 'st_ctime': 0 } + value =3D { + 'st_mode': 0o755 | stat.S_IFDIR, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 2, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 + } elif self.is_property(path): - value =3D { 'st_mode': 0o644 | stat.S_IFREG, - 'st_ino': self.get_ino(path), - 'st_dev': 0, - 'st_nlink': 1, - 'st_uid': 1000, - 'st_gid': 1000, - 'st_size': 4096, - 'st_atime': 0, - 'st_mtime': 0, - 'st_ctime': 0 } + value =3D { + 'st_mode': 0o644 | stat.S_IFREG, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 1, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 + } else: raise FuseOSError(ENOENT) return value @@ -146,8 +152,7 @@ class QOMFS(Operations): for item in self.qmp.command('qom-list', path=3Dpath): yield str(item['name']) =20 + if __name__ =3D=3D '__main__': - import os - fuse =3D FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])), sys.argv[1], foreground=3DTrue) --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681079; cv=none; d=zohomail.com; s=zohoarc; b=GRdxNXV+rdDujIYVjiZxiFFmmujm7lPGPj0H/wDmIjC1qcRNLnw90OVRoZUg1FjYCCAe2dSdQGXwd/Q53nBi5fr5wyquBgBFUiYaxsM+Odsoj130aSjXc+BeWXa31jKyLc5AbojUlUfE9KQyaNnUynjMBHWUcxFgtk37zpnbXbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681079; 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=rblE+LPPgTFyHMW8myRMdZGbUuBbsfjrLi2dFr26rG8=; b=fn7suU+c43jBx3BstsWlJXs0Or39s1b3+1BVRLMqB8UATSNDdY8UdybnMd2fSCaof0H44maRclY19/qcWg1P/AkzCAFUCNP9ydLd7mMsY7ciszSm2Babf7MKQuZWelg8a82Gsjf2EqrVcqdza+AFtEqMOUNAFfXjZW2LiGbASls= 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 1622681079516830.8892765651321; Wed, 2 Jun 2021 17:44:39 -0700 (PDT) Received: from localhost ([::1]:44390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobTR-0003dH-VT for importer2@patchew.org; Wed, 02 Jun 2021 20:44:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMe-0004WO-QX for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMd-0004gD-C4 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:36 -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-124-_stiEtBWPheOSUNvJ8dfZA-1; Wed, 02 Jun 2021 20:37:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D57F801817; Thu, 3 Jun 2021 00:37:32 +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 905AD10013D6; Thu, 3 Jun 2021 00:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680654; 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=rblE+LPPgTFyHMW8myRMdZGbUuBbsfjrLi2dFr26rG8=; b=EjEmO5R0PifyOuZSOcr1Pl0rTiujY714HzTPJAI+CaeJefncUCZQ+QbKUzMCWjMANWBZrR wO9YDa4unzr1mXdlbdgUEylLDJ29Nhmb9HUbdxMgZYp4opFApUy8sSobjxeiZtO8K0DYRv IjBAVE/D8npT3iT0apKVw1uUbmjNwxU= X-MC-Unique: _stiEtBWPheOSUNvJ8dfZA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 09/19] python: Add 'fh' to known-good variable names Date: Wed, 2 Jun 2021 20:37:09 -0400 Message-Id: <20210603003719.1321369-10-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" fd and fh are fine: we often use these for "file descriptor" or "file handle" accordingly. It is rarely the case that you need to enforce a more semantically meaningful name beyond "This is the file we are using right now." While we're here: add comments for all of the non-standard pylint names. (And the underscore.) Signed-off-by: John Snow --- python/setup.cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/setup.cfg b/python/setup.cfg index a19029d5388..c9b9445af98 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -78,9 +78,10 @@ good-names=3Di, k, ex, Run, - _, - fd, - c, + _, # By convention: Unused variable + fh, # fh =3D open(...) + fd, # fd =3D os.open(...) + c, # for c in string: ... =20 [pylint.similarities] # Ignore imports when computing similarities. --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622680752; cv=none; d=zohomail.com; s=zohoarc; b=mcb2HGxbDt4VHxKyqHUkzYN8GZNMmZIAcgdKf2ZnpwcUmDOjVvVaijH5eHD7rk3zUeRWNH5NEsRQ8sxNAR9zVpZ/vcNClfcdkiZUUetW8jch3G7DMwMt9z0qJsohdZEcKM9ms7FWUtiQ6Fz2Hsa3+YuNfdav7OPEoQzqZKuYv7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680752; 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=BcShfYPJMCAfGGa/wx/Z1T3yF3nL/JjQVhaObeoPp/s=; b=k/BlyiiEV8YOZAcd0dEUiW5eRqtMlZwBpzQFGZyJNj+NewNLhnk1PB50PvowG2Fz+RBdGudJ5fEVtdqvf1zre8Vcy3hSvDdAZf//QbfcKQIoKrgsbJBN/ezSyspcZ74Ocagct6oCY/hV9GmlZj5wohHqj8g+3BTlBOTvN5peUBU= 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 1622680752928205.16577539813534; Wed, 2 Jun 2021 17:39:12 -0700 (PDT) Received: from localhost ([::1]:53104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobOB-0007T1-Uj for importer2@patchew.org; Wed, 02 Jun 2021 20:39:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMg-0004bW-7I for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMe-0004hU-Ln for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:37 -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-163-_vaTFtLVPM2m_rYnpY0h1Q-1; Wed, 02 Jun 2021 20:37:34 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B802803620; Thu, 3 Jun 2021 00:37:33 +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 74AA210013D6; Thu, 3 Jun 2021 00:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680656; 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=BcShfYPJMCAfGGa/wx/Z1T3yF3nL/JjQVhaObeoPp/s=; b=SnmQHoWhww2/beL42OB2WnGAWTuXYtKXKXtxQlufGpynzWljRw2CQJnRTjfiQi95mSJSdD z3nb2PhDoU6o+4DoYz6x/2XsCF8MpWXMWmhKptONWt+6gVE7PFHHgSjFtbdUMS2EXqqdCz e7PunyJc26pZmG0GQ0pJFF2as8eSaPg= X-MC-Unique: _vaTFtLVPM2m_rYnpY0h1Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 10/19] scripts/qom-fuse: Apply pylint rules Date: Wed, 2 Jun 2021 20:37:10 -0400 Message-Id: <20210603003719.1321369-11-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.371, 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: Eduardo Habkost , John Snow , Markus Armbruster , "Niteesh G . S ." , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) - Catch specific exceptions from QMP - Reraise errors with explicit context - method parameters should match parent's names Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index ca30e928679..805e99c8ecd 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -23,7 +23,7 @@ from fuse import FUSE, FuseOSError, Operations =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp import QEMUMonitorProtocol, QMPResponseError =20 =20 fuse.fuse_python_api =3D (0, 2) @@ -47,7 +47,7 @@ class QOMFS(Operations): try: self.qmp.command('qom-list', path=3Dpath) return True - except: + except QMPResponseError: return False =20 def is_property(self, path): @@ -59,7 +59,7 @@ class QOMFS(Operations): if item['name'] =3D=3D prop: return True return False - except: + except QMPResponseError: return False =20 def is_link(self, path): @@ -73,10 +73,10 @@ class QOMFS(Operations): return True return False return False - except: + except QMPResponseError: return False =20 - def read(self, path, length, offset, fh): + def read(self, path, size, offset, fh): if not self.is_property(path): return -ENOENT =20 @@ -86,13 +86,13 @@ class QOMFS(Operations): try: data =3D self.qmp.command('qom-get', path=3Dpath, property=3Dp= rop) data +=3D '\n' # make values shell friendly - except: - raise FuseOSError(EPERM) + except QMPResponseError as err: + raise FuseOSError(EPERM) from err =20 if offset > len(data): return '' =20 - return bytes(data[offset:][:length], encoding=3D'utf-8') + return bytes(data[offset:][:size], encoding=3D'utf-8') =20 def readlink(self, path): if not self.is_link(path): --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681192; cv=none; d=zohomail.com; s=zohoarc; b=QJ6us4SPG61S8aOgFhkG+7fa0YrlxZwC6CEVRwNVFmYmKBnB3g8NC2+CjBGG+zRaZmmPw2aX3kvF0OEMkfju5B2boJ7Rck8jaJL43dTEen0NfEk8hGz8HycsjHNniqvwyb60BwSMvmG/LgwEHVRnyOZUVMb0qYUOwo8+STOx6HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681192; 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=Sr8cqmpnNLswHNJp+/rgvb1zWcAPkMO89Qs97X6XMLU=; b=je4mVI28d3ih2i/nVDKZEP+XpCYNEgb/gH9d87F1uTpW90NDSjHFZ+IHwxGAY1O8XWdbCGE8tlAzkrCsf4/8rCtyc6lFJ1OB2/Ghmonp5icNCvFIY0eqfYvb94W/BG6y6hHm+Vup0MaDzkEMtCO13i3wDuYmf+nIOySUjmLkGGI= 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 1622681192968903.1456424312228; Wed, 2 Jun 2021 17:46:32 -0700 (PDT) Received: from localhost ([::1]:50796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobVH-0007xe-S4 for importer2@patchew.org; Wed, 02 Jun 2021 20:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMg-0004e4-Ua for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMf-0004hi-AV for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:38 -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-401-x7Qj2u-XMaS8BWSomqM61Q-1; Wed, 02 Jun 2021 20:37:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3210A107ACC7; Thu, 3 Jun 2021 00:37:34 +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 7173310013D6; Thu, 3 Jun 2021 00:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680656; 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=Sr8cqmpnNLswHNJp+/rgvb1zWcAPkMO89Qs97X6XMLU=; b=gb0V5offxtmLFRElg7Sdd9ks9mVAm21jaLOEzIBLCX9Chbb22+owkr1pwztvVcp7PJ5bM5 Pu6QME7OZkCGuxTcCO5ri6NCRu2dzOxMeDYCUU0WvFj+RyqoiXnBiB5stlOndlkrpBqIi7 GEcNrKJUPrPZ5KPG6XDjVmUWnkcJaRg= X-MC-Unique: x7Qj2u-XMaS8BWSomqM61Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 11/19] scripts/qom-fuse: Add docstrings Date: Wed, 2 Jun 2021 20:37:11 -0400 Message-Id: <20210603003719.1321369-12-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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 methods inherited from fuse don't need docstrings; that's up to fusepy to handle. Signed-off-by: John Snow --- scripts/qmp/qom-fuse | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 805e99c8ecd..1fb3008a167 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -1,7 +1,19 @@ #!/usr/bin/env python3 +""" +QEMU Object Model FUSE filesystem tool + +This script offers a simple FUSE filesystem within which the QOM tree +may be browsed, queried and edited using traditional shell tooling. + +This script requires the 'fusepy' python package. + +ENV: + QMP_SOCKET: Path to the QMP server socket + +Usage: + qom-fuse /mount/to/here +""" ## -# QEMU Object Model test tools -# # Copyright IBM, Corp. 2012 # Copyright (C) 2020 Red Hat, Inc. # @@ -30,6 +42,7 @@ fuse.fuse_python_api =3D (0, 2) =20 =20 class QOMFS(Operations): + """QOMFS implements fuse.Operations to provide a QOM filesystem.""" def __init__(self, qmp): self.qmp =3D qmp self.qmp.connect() @@ -37,6 +50,7 @@ class QOMFS(Operations): self.ino_count =3D 1 =20 def get_ino(self, path): + """Get an inode number for a given QOM path.""" if path in self.ino_map: return self.ino_map[path] self.ino_map[path] =3D self.ino_count @@ -44,6 +58,7 @@ class QOMFS(Operations): return self.ino_map[path] =20 def is_object(self, path): + """Is the given QOM path an object?""" try: self.qmp.command('qom-list', path=3Dpath) return True @@ -51,6 +66,7 @@ class QOMFS(Operations): return False =20 def is_property(self, path): + """Is the given QOM path a property?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': path =3D '/' @@ -63,6 +79,7 @@ class QOMFS(Operations): return False =20 def is_link(self, path): + """Is the given QOM path a link?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': path =3D '/' --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622680864; cv=none; d=zohomail.com; s=zohoarc; b=bFIZpMPzfDDi4HOk28EprovNrSkaWcDD7kL5V9XOs6dZROZaLz4Y3nRL5JS2um3lL7JXGtH+luweAaBEwektCoycA9K5xTCJ//J6mJFer/Cvi3wlqq0Y5Tqhsw8PHkwKMghnOncMNixn7RdRe5CrRw9iS4gsFeLDGG7OCxwubaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680864; 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=UiUkSDfo3QLwwNyP90q1EmMLGKGnSTt1tMXAOjQm/P0=; b=lhqma1JdFJCFW0fN9miG6i9Dup0qmpRhGl5Lk6M3/+8DDHZWT0fZOI9KmRoJ6l7j3JvmjCJbQZ5z+MmboJf8K3VECJ1pITHKXg7Q5IIUN1ey2AFHLOHfNnjnE2VuIAWTpBIbSFD8u46uYhZGhGsF7WUS2RnRuPLhsPsxKORh1XU= 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 1622680864629573.9098176733496; Wed, 2 Jun 2021 17:41:04 -0700 (PDT) Received: from localhost ([::1]:60470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobPz-0003vP-Ky for importer2@patchew.org; Wed, 02 Jun 2021 20:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMi-0004k5-IA for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMg-0004it-MN for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:40 -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-265-BrmgCX55NAmGLSmp75seHw-1; Wed, 02 Jun 2021 20:37:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82EB5801106; Thu, 3 Jun 2021 00:37: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 5A27310013D6; Thu, 3 Jun 2021 00:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680658; 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=UiUkSDfo3QLwwNyP90q1EmMLGKGnSTt1tMXAOjQm/P0=; b=cRWty6kEnUSoLq+Hbzee8q4Ybt8RIXW98AWLOgXoXSdEYZIDR5uLFMrTUqR7zEpHMUhXW4 JGk9cfM3yjbvHhkjlLYA72TJEpMoPuxxjwknieYyAFr1BjjJogRyTXxULdQC4vrQh/U4yf 7lorlq88dHO+eUpZHuYwwypxnzYejp0= X-MC-Unique: BrmgCX55NAmGLSmp75seHw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 12/19] scripts/qom-fuse: Convert to QOMCommand Date: Wed, 2 Jun 2021 20:37:12 -0400 Message-Id: <20210603003719.1321369-13-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" Move qom-fuse onto the QOMCommand base established in python/qemu/qmp/qom_common.py. The interface doesn't change incompatibly, "qom-fuse mountpoint" still works as an invocation, and QMP_SOCKET is still used as the environment variable. Signed-off-by: John Snow --- scripts/qmp/qom-fuse | 59 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 1fb3008a167..1676fb78d99 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -7,11 +7,19 @@ may be browsed, queried and edited using traditional shel= l tooling. =20 This script requires the 'fusepy' python package. =20 -ENV: - QMP_SOCKET: Path to the QMP server socket =20 -Usage: - qom-fuse /mount/to/here +usage: qom-fuse [-h] [--socket SOCKET] + +Mount a QOM tree as a FUSE filesystem + +positional arguments: + Mount point + +optional arguments: + -h, --help show this help message and exit + --socket SOCKET, -s SOCKET + QMP socket path or address (addr:port). May also be + set via QMP_SOCKET environment variable. """ ## # Copyright IBM, Corp. 2012 @@ -25,30 +33,56 @@ Usage: # See the COPYING file in the top-level directory. ## =20 +import argparse from errno import ENOENT, EPERM import os import stat import sys +from typing import Dict =20 import fuse from fuse import FUSE, FuseOSError, Operations =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol, QMPResponseError +from qemu.qmp import QMPResponseError +from qemu.qmp.qom_common import QOMCommand =20 =20 fuse.fuse_python_api =3D (0, 2) =20 =20 -class QOMFS(Operations): - """QOMFS implements fuse.Operations to provide a QOM filesystem.""" - def __init__(self, qmp): - self.qmp =3D qmp - self.qmp.connect() - self.ino_map =3D {} +class QOMFuse(QOMCommand, Operations): + """ + QOMFuse implements both fuse.Operations and QOMCommand. + + Operations implements the FS, and QOMCommand implements the CLI comman= d. + """ + name =3D 'fuse' + help =3D 'Mount a QOM tree as a FUSE filesystem' + fuse: FUSE + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + parser.add_argument( + 'mount', + metavar=3D'', + action=3D'store', + help=3D"Mount point", + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.mount =3D args.mount + self.ino_map: Dict[str, int] =3D {} self.ino_count =3D 1 =20 + def run(self) -> int: + print(f"Mounting QOMFS to '{self.mount}'", file=3Dsys.stderr) + self.fuse =3D FUSE(self, self.mount, foreground=3DTrue) + return 0 + def get_ino(self, path): """Get an inode number for a given QOM path.""" if path in self.ino_map: @@ -171,5 +205,4 @@ class QOMFS(Operations): =20 =20 if __name__ =3D=3D '__main__': - fuse =3D FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])), - sys.argv[1], foreground=3DTrue) + sys.exit(QOMFuse.entry_point()) --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681307; cv=none; d=zohomail.com; s=zohoarc; b=DO5rINcbQdHCprTho/zINru53dTz3HSYKNN2CSSNwtr/fq/w7LX4qvrbDQWlWVM2AzaKjJD3qXFotCV+r47mD3Sph7UHYIwHp7TuzvM3HZh8WPAQ0sxyGj+FVpAMJQ1sZ4jAHQSK5YfiIfci6EocCKNK6ZeT1qiOdb9Uf+NK+Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681307; 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=wYk+tC89xupiZDiKU257+k8TP9iVyVoJVE8zvCtYKr0=; b=ROe+jnf56ACngv7PTHlbOLJUp/0CnDdMV6a2eaOMxOQ2HLF8bxpPV3lgb7mNHXnbLkmAwGs198YisyzqNZvTRDBkXYH2Q+IpHYbYzuDqnPMAurMUZs/jdmiThFAjFqALKk3cB8wQboVzhYq7ejOkRTpjyUWt4ZHpwdn+oMGYF6s= 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 1622681307543108.98639114999355; Wed, 2 Jun 2021 17:48:27 -0700 (PDT) Received: from localhost ([::1]:57728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobX7-00047G-UT for importer2@patchew.org; Wed, 02 Jun 2021 20:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMj-0004mp-5w for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMh-0004jt-Ed for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:40 -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-bxdpnZAENXSdDw-JwXyjdA-1; Wed, 02 Jun 2021 20:37:37 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AC46801107; Thu, 3 Jun 2021 00:37: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 CA4CA10013D6; Thu, 3 Jun 2021 00:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680658; 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=wYk+tC89xupiZDiKU257+k8TP9iVyVoJVE8zvCtYKr0=; b=Bgpb3msWm7V30eo0/2ZbCcLvd13f5KnEVdB/dl6UBimWOfi0x6Za5uvQvGZUR5cR2YgdSr TTD72bfLhqOv/7icdcJmNTBJfAfKeBW1my65T6lqS6sBhqDGdWni3xelLle2vIp8sFJZnY TVj1Or40gE1YN1zjy0d7NO3SMJ1eHzw= X-MC-Unique: bxdpnZAENXSdDw-JwXyjdA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 13/19] scripts/qom-fuse: use QOMCommand.qom_list() Date: Wed, 2 Jun 2021 20:37:13 -0400 Message-Id: <20210603003719.1321369-14-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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 qom_list method provides a type-safe object that's easier to type check, so switch to using it. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 1676fb78d99..703a97e75ff 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -94,7 +94,7 @@ class QOMFuse(QOMCommand, Operations): def is_object(self, path): """Is the given QOM path an object?""" try: - self.qmp.command('qom-list', path=3Dpath) + self.qom_list(path) return True except QMPResponseError: return False @@ -105,8 +105,8 @@ class QOMFuse(QOMCommand, Operations): if path =3D=3D '': path =3D '/' try: - for item in self.qmp.command('qom-list', path=3Dpath): - if item['name'] =3D=3D prop: + for item in self.qom_list(path): + if item.name =3D=3D prop: return True return False except QMPResponseError: @@ -118,11 +118,9 @@ class QOMFuse(QOMCommand, Operations): if path =3D=3D '': path =3D '/' try: - for item in self.qmp.command('qom-list', path=3Dpath): - if item['name'] =3D=3D prop: - if item['type'].startswith('link<'): - return True - return False + for item in self.qom_list(path): + if item.name =3D=3D prop and item.link: + return True return False except QMPResponseError: return False @@ -200,8 +198,8 @@ class QOMFuse(QOMCommand, Operations): def readdir(self, path, fh): yield '.' yield '..' - for item in self.qmp.command('qom-list', path=3Dpath): - yield str(item['name']) + for item in self.qom_list(path): + yield item.name =20 =20 if __name__ =3D=3D '__main__': --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681392; cv=none; d=zohomail.com; s=zohoarc; b=AW2AWODbn6uVT9Y7HTUBX6vHI6V3RsiGyu6fnVkfIeoWEVt8KXECCMWOhfkk3E3QSrNx8+0iFX33vAUAT5SN5YjtSw/T/r8a44iBrOm0Z4hZWdUwA5dXg3iFUOdLbyIcqJG8CAx9gcuy8mR+4G4QQtNXX/GwGFkceBUjZu2yHHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681392; 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=KDPQCe++FalqX5m9SAlH1/jXiEHGE6fFSaTALiVqxn0=; b=k269n34ALC1Su8exNNG4X2dDOqeaELndmPNYxPMJs6vckpLBLX6qLbF2Xq9SLD2V2YIOXyL2YN04S2ohNfRsOncApcWVa4zxhWONGTsgXI4ZYRdRn3QNg0iBbckdCZ3mqnDVv1T35H2yOZH0E3ZVLrQj/gMagh/LwuyksOikRD0= 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 1622681392658943.435175837133; Wed, 2 Jun 2021 17:49:52 -0700 (PDT) Received: from localhost ([::1]:60494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobYV-0005xB-An for importer2@patchew.org; Wed, 02 Jun 2021 20:49:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMk-0004rY-9H for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMi-0004kb-Jx for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:41 -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-421-rCNxHgfIM4KJ9OICH3RI8A-1; Wed, 02 Jun 2021 20:37:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8E96801817; Thu, 3 Jun 2021 00:37: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 B1CBA10013D6; Thu, 3 Jun 2021 00:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680660; 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=KDPQCe++FalqX5m9SAlH1/jXiEHGE6fFSaTALiVqxn0=; b=TlGturccKrTbRyji0KwRcTUggoNfpPilbF49CU8tqmuMbQr7OS+L4UN9M879iHxWS74sNg w7u9CsOLhJ6qdAI/AYuHuPHeQEBXObEw1T+nUKrA30Fww8+5fib+oX9zI7ZsuuqAOM30E1 SODSf88g162LJSklSfDVZsoo+0hqPTE= X-MC-Unique: rCNxHgfIM4KJ9OICH3RI8A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 14/19] scripts/qom-fuse: ensure QOMFuse.read always returns bytes Date: Wed, 2 Jun 2021 20:37:14 -0400 Message-Id: <20210603003719.1321369-15-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.371, 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: Eduardo Habkost , John Snow , Markus Armbruster , "Niteesh G . S ." , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) - Use FuseOSError to signal ENOENT instead of returning it - Wrap qom-get in str(), as we don't always know its type - The empty return should be b'', not ''. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 703a97e75ff..0d11f731526 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -127,19 +127,19 @@ class QOMFuse(QOMCommand, Operations): =20 def read(self, path, size, offset, fh): if not self.is_property(path): - return -ENOENT + raise FuseOSError(ENOENT) =20 path, prop =3D path.rsplit('/', 1) if path =3D=3D '': path =3D '/' try: - data =3D self.qmp.command('qom-get', path=3Dpath, property=3Dp= rop) + data =3D str(self.qmp.command('qom-get', path=3Dpath, property= =3Dprop)) data +=3D '\n' # make values shell friendly except QMPResponseError as err: raise FuseOSError(EPERM) from err =20 if offset > len(data): - return '' + return b'' =20 return bytes(data[offset:][:size], encoding=3D'utf-8') =20 --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622680980; cv=none; d=zohomail.com; s=zohoarc; b=JRJs5so3MiHQE/65UTUj1Y60BMl4KMjE7ve617nxmLd2Jnfuy5WHHlOtLpjytcVXoFHXF2EHhPmkdK5uRhW/NT7sVBn6elC4S/8hz5snADZPkjUtdaxabptrSfDUxpD1ms2btQdABGhhi7aeQNGiei2SgWZyxXQVuxXdtrxiFVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622680980; 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=HZ1UDK/3zQdTOKonKn7mNfwnxJXNgQYOuELcuEX9k90=; b=LZZvswLBe56LYajtddm2TLWrMGwV9dwjEvMBRndopQxbt4VehhNbA+y02kShCXhkkJdXVmFQcw7+cGkMQF3hbaTI89dIg+TWZbvuJpaDtouUZATvWKpDI4YOVIj+RgBUCAcO6Lgs/YQ4ePj8YZhi+4OvUxf1ZFTG3P9+PNUnQa8= 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 162268098035649.78216149204832; Wed, 2 Jun 2021 17:43:00 -0700 (PDT) Received: from localhost ([::1]:38618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobRr-0008BX-9O for importer2@patchew.org; Wed, 02 Jun 2021 20:42:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMm-000508-4t for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMk-0004mG-6c for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:43 -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-544-Xs3RRhx2MdeRcibfx_PRCQ-1; Wed, 02 Jun 2021 20:37:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 262BF180FD6D; Thu, 3 Jun 2021 00:37: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 1948A10013D6; Thu, 3 Jun 2021 00:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680661; 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=HZ1UDK/3zQdTOKonKn7mNfwnxJXNgQYOuELcuEX9k90=; b=A9N5wff+9DkwPlayuIA7qoEvLcF/gmLJn3kzEfwNwPjU3eSMthsBZMdUVTGblzOaHLLEdI 0b22En+QavB3wzFcpF8UGbhALYfYhTOuzZF4iESEx0RsF+NUDFLLgioeuJu7XjLbUEvF+t cNYHT67iG9dRWB4zeWaOcaLRnDcpgJk= X-MC-Unique: Xs3RRhx2MdeRcibfx_PRCQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 15/19] scripts/qom-fuse: add static type hints Date: Wed, 2 Jun 2021 20:37:15 -0400 Message-Id: <20210603003719.1321369-16-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" Because fusepy does not have type hints, add some targeted warning suppressions. Namely, we need to allow subclassing something of an unknown type (in qom_fuse.py), and we need to allow missing imports (recorded against fuse itself) because mypy will be unable to import fusepy (even when installed) as it has no types nor type stubs available. Note: Until now, it was possible to run invocations like 'mypy qemu/' from ./python and have that work. However, these targeted suppressions require that you run 'mypy -p qemu/' instead. The correct, canonical invocation is recorded in ./python/tests/mypy.sh and all of the various CI invocations always use this correct form. Signed-off-by: John Snow --- python/setup.cfg | 8 ++++++++ scripts/qmp/qom-fuse | 26 +++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/python/setup.cfg b/python/setup.cfg index c9b9445af98..ba8d29fd62d 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -57,6 +57,14 @@ python_version =3D 3.6 warn_unused_configs =3D True namespace_packages =3D True =20 +[mypy-qemu.qmp.qom_fuse] +# fusepy has no type stubs: +allow_subclassing_any =3D True + +[mypy-fuse] +# fusepy has no type stubs: +ignore_missing_imports =3D True + [pylint.messages control] # Disable the message, report, category or checker with the given id(s). Y= ou # can either give multiple identifiers separated by comma (,) or put this diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 0d11f731526..a5a7a304a3e 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -38,7 +38,14 @@ from errno import ENOENT, EPERM import os import stat import sys -from typing import Dict +from typing import ( + IO, + Dict, + Iterator, + Mapping, + Optional, + Union, +) =20 import fuse from fuse import FUSE, FuseOSError, Operations @@ -83,7 +90,7 @@ class QOMFuse(QOMCommand, Operations): self.fuse =3D FUSE(self, self.mount, foreground=3DTrue) return 0 =20 - def get_ino(self, path): + def get_ino(self, path: str) -> int: """Get an inode number for a given QOM path.""" if path in self.ino_map: return self.ino_map[path] @@ -91,7 +98,7 @@ class QOMFuse(QOMCommand, Operations): self.ino_count +=3D 1 return self.ino_map[path] =20 - def is_object(self, path): + def is_object(self, path: str) -> bool: """Is the given QOM path an object?""" try: self.qom_list(path) @@ -99,7 +106,7 @@ class QOMFuse(QOMCommand, Operations): except QMPResponseError: return False =20 - def is_property(self, path): + def is_property(self, path: str) -> bool: """Is the given QOM path a property?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': @@ -112,7 +119,7 @@ class QOMFuse(QOMCommand, Operations): except QMPResponseError: return False =20 - def is_link(self, path): + def is_link(self, path: str) -> bool: """Is the given QOM path a link?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': @@ -125,7 +132,7 @@ class QOMFuse(QOMCommand, Operations): except QMPResponseError: return False =20 - def read(self, path, size, offset, fh): + def read(self, path: str, size: int, offset: int, fh: IO[bytes]) -> by= tes: if not self.is_property(path): raise FuseOSError(ENOENT) =20 @@ -143,7 +150,7 @@ class QOMFuse(QOMCommand, Operations): =20 return bytes(data[offset:][:size], encoding=3D'utf-8') =20 - def readlink(self, path): + def readlink(self, path: str) -> Union[bool, str]: if not self.is_link(path): return False path, prop =3D path.rsplit('/', 1) @@ -151,7 +158,8 @@ class QOMFuse(QOMCommand, Operations): return prefix + str(self.qmp.command('qom-get', path=3Dpath, property=3Dprop)) =20 - def getattr(self, path, fh=3DNone): + def getattr(self, path: str, + fh: Optional[IO[bytes]] =3D None) -> Mapping[str, object]: if self.is_link(path): value =3D { 'st_mode': 0o755 | stat.S_IFLNK, @@ -195,7 +203,7 @@ class QOMFuse(QOMCommand, Operations): raise FuseOSError(ENOENT) return value =20 - def readdir(self, path, fh): + def readdir(self, path: str, fh: IO[bytes]) -> Iterator[str]: yield '.' yield '..' for item in self.qom_list(path): --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681094; cv=none; d=zohomail.com; s=zohoarc; b=hs7wMYuxK0Q2drydBj1ZcjHqq6DEZ22IkXub06/6lnfY1ecmv4vST/tt13/GO69059SDPIFTDDaFsXjAN5vgn+IElKfJ7UtsdMsorC+qIfygFIyeLy3vfvGnNr6nXXqI/oaKbJTxsX0eeLvXKgL5FBy7yLAPB15qsSNEuYtxrZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681094; 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=AzIulRTPQzYUJvspCQFmwoZtqKCpHFSHcbEXqeOXCJM=; b=AKPBCyHEmJ4fx31YB4OEEmXdWvBtAdjycXB7ldppfzW8DkmrDwlnMQlTMN4mvr+pDNqkKgPxYxZ7mccnrmzTXbP6xUYNImDHtt7CLFHX1LpEOrwQoQNqxacHgfoD/g1qpQL/CfpGFwU7PsQy+vvPUE1FgWWrKO3akcf/MeQiEKA= 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 1622681094217590.7023271431714; Wed, 2 Jun 2021 17:44:54 -0700 (PDT) Received: from localhost ([::1]:45010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobTh-00042S-7s for importer2@patchew.org; Wed, 02 Jun 2021 20:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMm-00052u-PU for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMk-0004oH-Ue for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37: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-84-OidnOUVIOrucv5saVoX5yw-1; Wed, 02 Jun 2021 20:37:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07D41801106; Thu, 3 Jun 2021 00:37: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 4B43410013D6; Thu, 3 Jun 2021 00:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680662; 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=AzIulRTPQzYUJvspCQFmwoZtqKCpHFSHcbEXqeOXCJM=; b=aJ4P92yatokElFG4tlHlw6ng9OCrWYuZczmeEk96j1G71UGkBMyE+TIj6+lXRgkDIkfK8w G2vNhf2ZSJAyMgNneebvhLdL4WepgDbkWCT5U+9bdF67q6Xg2cmq27LhZoUYiiJDQPv+zS slpSVtqVvXyuxTTgmJLnY1pIVsWOmTI= X-MC-Unique: OidnOUVIOrucv5saVoX5yw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 16/19] python: add optional FUSE dependencies Date: Wed, 2 Jun 2021 20:37:16 -0400 Message-Id: <20210603003719.1321369-17-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" In preparation for moving qom-fuse over to the python package, we need some new dependencies to support it. Add an optional 'fusepy' dependency that users of the package can opt into with e.g. "pip install qemu[fuse]" which installs the requirements necessary to obtain the additional functionality. Add the same fusepy dependency to the 'devel' extras group -- unfortunately I do not see a way for optional groups to imply other optional groups at present, so the dependency is repeated. The development group needs to include the full set of dependencies for the purpose of static analysis of all features offered by this library. Lastly, add the [fuse] extras group to tox's configuration as a workaround so that if a stale tox environment is found when running `make check-tox`, tox will know to rebuild its environments. Signed-off-by: John Snow --- python/Pipfile.lock | 6 ++++++ python/setup.cfg | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/python/Pipfile.lock b/python/Pipfile.lock index f2a3f91d0fa..5bb3f1b6351 100644 --- a/python/Pipfile.lock +++ b/python/Pipfile.lock @@ -67,6 +67,12 @@ "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "=3D=3D3.9.2" }, + "fusepy": { + "hashes": [ + "sha256:72ff783ec2f43de3ab394e3f7457605bf04c8cf288a2f4068b= 4cde141d4ee6bd" + ], + "version": "=3D=3D3.0.1" + }, "importlib-metadata": { "hashes": [ "sha256:8c501196e49fb9df5df43833bdb1e4328f64847763ec8a5070= 3148b73784d581", diff --git a/python/setup.cfg b/python/setup.cfg index ba8d29fd62d..aca6f311853 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -32,11 +32,16 @@ packages =3D devel =3D avocado-framework >=3D 87.0 flake8 >=3D 3.6.0 + fusepy >=3D 2.0.4 isort >=3D 5.1.2 mypy >=3D 0.770 pylint >=3D 2.8.0 tox >=3D 3.18.0 =20 +# Provides qom-fuse functionality +fuse =3D + fusepy >=3D 2.0.4 + [options.entry_points] console_scripts =3D qom =3D qemu.qmp.qom:main @@ -114,6 +119,8 @@ envlist =3D py36, py37, py38, py39, py310 =20 [testenv] allowlist_externals =3D make -deps =3D .[devel] +deps =3D + .[devel] + .[fuse] # Workaround to trigger tox venv rebuild commands =3D make check --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681200; cv=none; d=zohomail.com; s=zohoarc; b=XB+nw1bXYBnRM3yRBZq+Q3FfTVIsbNDv9o1Xntq2zcIHTdRcKwLsD5raGTJl8FIXhOUNupppI16kgJlswJxWNDdAzftyeK9Jv1Q2VjVQrO1mGReCRzru5AiEw1C2kCXJdkw7VowUztBZ7VEZkei0oS+ODtaMB2xNNLn4SgCLmAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681200; 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=ZIuZoRnfL3Jw3X8K/dU+kKaJLnkMfALKLUdcwhO9ZVg=; b=VoRetxnCpWc0uNOCmvrWs08rxfwJM/LlDBnCGHtQQfYqkp3UnnTct1xUs+lRGpdl4X2PnQvc42iUyjg+e1hM1m7GInNNJ0brQtIt0vksmdId7BD2gBXMbi/I+vutbJPQuvEdF6Dd+N4nlbABLrRT9Ny370RfYTRZ0TMw9dE9hxU= 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 1622681200521257.1985318683119; Wed, 2 Jun 2021 17:46:40 -0700 (PDT) Received: from localhost ([::1]:51480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobVP-0008Ob-Ho for importer2@patchew.org; Wed, 02 Jun 2021 20:46:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMn-00057D-Om for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42290) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMl-0004pD-S6 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:45 -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-194-f9E_RjpbOG2rlfiCZYADFQ-1; Wed, 02 Jun 2021 20:37:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2490107ACC7; Thu, 3 Jun 2021 00:37: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 2E48C10013D6; Thu, 3 Jun 2021 00:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680663; 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=ZIuZoRnfL3Jw3X8K/dU+kKaJLnkMfALKLUdcwhO9ZVg=; b=Rpk22Fq6wxqk7KW7TOG48YJgTfampfzfqfeYcZMMwhe+ikFJxJlh0D06E3aDV66mU3CFmu /DuSeH28zvEI06sSwl1YYP5SsUI+1kl3y8gpLKOeMnpOfGSvEN4Na89HK9PPJaeJVeFsru TS/QJ5iaoIIDJot9lrQd8qDvTktqtkI= X-MC-Unique: f9E_RjpbOG2rlfiCZYADFQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 17/19] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py Date: Wed, 2 Jun 2021 20:37:17 -0400 Message-Id: <20210603003719.1321369-18-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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" Move qom-fuse over to the python package now that it passes the linter. Update the import paradigms so that it continues to pass in the context of the Python package. Signed-off-by: John Snow --- scripts/qmp/qom-fuse =3D> python/qemu/qmp/qom_fuse.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) rename scripts/qmp/qom-fuse =3D> python/qemu/qmp/qom_fuse.py (95%) mode change 100755 =3D> 100644 diff --git a/scripts/qmp/qom-fuse b/python/qemu/qmp/qom_fuse.py old mode 100755 new mode 100644 similarity index 95% rename from scripts/qmp/qom-fuse rename to python/qemu/qmp/qom_fuse.py index a5a7a304a3e..43f4671fdb1 --- a/scripts/qmp/qom-fuse +++ b/python/qemu/qmp/qom_fuse.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """ QEMU Object Model FUSE filesystem tool =20 @@ -35,7 +34,6 @@ =20 import argparse from errno import ENOENT, EPERM -import os import stat import sys from typing import ( @@ -50,10 +48,8 @@ import fuse from fuse import FUSE, FuseOSError, Operations =20 - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QMPResponseError -from qemu.qmp.qom_common import QOMCommand +from . import QMPResponseError +from .qom_common import QOMCommand =20 =20 fuse.fuse_python_api =3D (0, 2) @@ -208,7 +204,3 @@ def readdir(self, path: str, fh: IO[bytes]) -> Iterator= [str]: yield '..' for item in self.qom_list(path): yield item.name - - -if __name__ =3D=3D '__main__': - sys.exit(QOMFuse.entry_point()) --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681445; cv=none; d=zohomail.com; s=zohoarc; b=QiEbk+6aJ2xIUd4fS53hGYLOIKlSvr4pPzsXBmLMcTmaS1Gzc7+UjarS21j7MwKvjfIHShbISZdP6pRAKwIjZgZ1064CKPuJ8MSEpPJYrCUEuH7MeNcOTQdT4eo+QgEPG8f2rDiG8Pf1mETMcvCnCmojzIxTjQ82u4ZLP2NY5rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681445; 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=KGw3Q1IpTgm6rZrTWdR2er3THuStBnbAeXGhHC7mJ8c=; b=SO5klllsHqMMW2Pp/wsFzBqf68h78NFBDQgW52wtm9EPLbWL3M8/YuUDS33tdVngQmuzRGfUEPDB/rO6CI4/yb/A7fhLRDQ5+jx7NY+z1AK3DGnxXonJ7mWy2WT6y+SMmWdHLC+sC+Nb2QXnkKlmvurXimr1rV9TyLHmCAP09xc= 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 1622681445754568.9386263444084; Wed, 2 Jun 2021 17:50:45 -0700 (PDT) Received: from localhost ([::1]:34402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobZM-0007Oa-Oy for importer2@patchew.org; Wed, 02 Jun 2021 20:50:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMs-0005Sn-Op for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMr-0004sh-3T for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37: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-560-6VxteDxeNBusshc42neg6w-1; Wed, 02 Jun 2021 20:37:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2791180FD6D; Thu, 3 Jun 2021 00:37: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 178EC10013D6; Thu, 3 Jun 2021 00:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680668; 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=KGw3Q1IpTgm6rZrTWdR2er3THuStBnbAeXGhHC7mJ8c=; b=BVbgdQe0E9hqeYtpIwXXm3c7gETENN/DqWKs38/y4RlCNrFsGCBF+zh3F6w20YOmjMF/7c bfXByn1hLfjGrpRQBgbMuiHL6+ZLDDEH0mFbym0nWurwID3r9axlsMHBq3lohksmCvNzSV mZAOePqa6JZtvkikiE3lu1IoS+BqO1M= X-MC-Unique: 6VxteDxeNBusshc42neg6w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 18/19] scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py Date: Wed, 2 Jun 2021 20:37:18 -0400 Message-Id: <20210603003719.1321369-19-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.371, 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: Eduardo Habkost , John Snow , Markus Armbruster , "Niteesh G . S ." , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) By leaving the script absent for a commit, git-blame travels to the new file instead of staying on the shim. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/qmp/qom-fuse diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse new file mode 100755 index 00000000000..a58c8ef9793 --- /dev/null +++ b/scripts/qmp/qom-fuse @@ -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.qom_fuse import QOMFuse + + +if __name__ =3D=3D '__main__': + sys.exit(QOMFuse.entry_point()) --=20 2.31.1 From nobody Fri May 3 00:29:36 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=1622681287; cv=none; d=zohomail.com; s=zohoarc; b=kUEo8/kAMBhadc3P0syz1Dfe8A4RfGy2LTAg4YXn+zoySb7l52LPwVz4+AdYqcmRaoK/HLULVijQH3C9CL2PqbnCEYIzLLrL7XOBxXa1bINHkgRZ0lXJifvkvPxWnT/iw/7de8LQy7QfeMFQKzx5pVfapgi4+cK/WfheEpprEso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622681287; 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=rXF4ZXaMMbLySO5l6Dq9d86icbMOjB0pb0H/AUQB23I=; b=byoxZhqOJOnde6a+RBtdem/aMaUSH6f6x/+sHurQHk79cNUng3a5HQpyaFHes9qPAOw7KuqB3U1pI1ipgCCAVED3vD8DanhFgQbbGTw/nYSGhqFvXASo7UmSyBlH1SqDUvHuzSe8XTJVZE/Rj5LxYoubk2X29fwNAhh7+epe/xM= 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 1622681287295384.82751351786055; Wed, 2 Jun 2021 17:48:07 -0700 (PDT) Received: from localhost ([::1]:56676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lobWo-0003Qd-8W for importer2@patchew.org; Wed, 02 Jun 2021 20:48:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMr-0005PD-W9 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lobMq-0004rQ-2v for qemu-devel@nongnu.org; Wed, 02 Jun 2021 20:37: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-455-dX0QTr6MN9qw7cFcDbJsRw-1; Wed, 02 Jun 2021 20:37:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 141388018A7; Thu, 3 Jun 2021 00:37: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 15B4010013D6; Thu, 3 Jun 2021 00:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622680667; 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=rXF4ZXaMMbLySO5l6Dq9d86icbMOjB0pb0H/AUQB23I=; b=efGIL7RKxSr176mV7MENpLOx4ZF4PRrDnN0MTFhS+1pzFu6wHrtOX+hEzLs6WBtrpHUI2L FSta8XIfPdiAZy/MTcCKUb3bXfc/lUd01jKmpTt6zLOK+tj52kudn3kd+amgSCzltLrrAO 2dTaYHUg/nbxowoRYDZEwFajHS2PSvg= X-MC-Unique: dX0QTr6MN9qw7cFcDbJsRw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 19/19] python/qmp: add fuse command to 'qom' tools Date: Wed, 2 Jun 2021 20:37:19 -0400 Message-Id: <20210603003719.1321369-20-jsnow@redhat.com> In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com> References: <20210603003719.1321369-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.371, 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 'fuse' command will be unavailable if 'fusepy' is not installed. It will simply not load and subsequently be unavailable as a subcommand. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qmp/qom.py | 14 ++++++++++++-- python/setup.cfg | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/python/qemu/qmp/qom.py b/python/qemu/qmp/qom.py index 7fe1448b5d9..7ec7843d57a 100644 --- a/python/qemu/qmp/qom.py +++ b/python/qemu/qmp/qom.py @@ -1,7 +1,7 @@ """ QEMU Object Model testing tools. =20 -usage: qom [-h] {set,get,list,tree} ... +usage: qom [-h] {set,get,list,tree,fuse} ... =20 Query and manipulate QOM data =20 @@ -9,11 +9,12 @@ -h, --help show this help message and exit =20 QOM commands: - {set,get,list,tree} + {set,get,list,tree,fuse} set Set a QOM property value get Get a QOM property value list List QOM properties at a given path tree Show QOM tree from a given path + fuse Mount a QOM tree as a FUSE filesystem """ ## # Copyright John Snow 2020, for Red Hat, Inc. @@ -35,6 +36,15 @@ from .qom_common import QOMCommand =20 =20 +try: + from .qom_fuse import QOMFuse +except ModuleNotFoundError as err: + if err.name !=3D 'fuse': + raise +else: + assert issubclass(QOMFuse, QOMCommand) + + class QOMSet(QOMCommand): """ QOM Command - Set a property to a given value. diff --git a/python/setup.cfg b/python/setup.cfg index aca6f311853..6b6be8b03c6 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -49,6 +49,7 @@ console_scripts =3D qom-get =3D qemu.qmp.qom:QOMGet.entry_point 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] =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's --=20 2.31.1