qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
	John Snow <jsnow@redhat.com>,
	"Niteesh G . S ." <niteesh.gs@gmail.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Cleber Rosa <crosa@redhat.com>
Subject: [PATCH v3 13/19] scripts/qom-fuse: use QOMCommand.qom_list()
Date: Wed,  2 Jun 2021 20:37:13 -0400	[thread overview]
Message-ID: <20210603003719.1321369-14-jsnow@redhat.com> (raw)
In-Reply-To: <20210603003719.1321369-1-jsnow@redhat.com>

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 <jsnow@redhat.com>
---
 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=path)
+            self.qom_list(path)
             return True
         except QMPResponseError:
             return False
@@ -105,8 +105,8 @@ class QOMFuse(QOMCommand, Operations):
         if path == '':
             path = '/'
         try:
-            for item in self.qmp.command('qom-list', path=path):
-                if item['name'] == prop:
+            for item in self.qom_list(path):
+                if item.name == prop:
                     return True
             return False
         except QMPResponseError:
@@ -118,11 +118,9 @@ class QOMFuse(QOMCommand, Operations):
         if path == '':
             path = '/'
         try:
-            for item in self.qmp.command('qom-list', path=path):
-                if item['name'] == prop:
-                    if item['type'].startswith('link<'):
-                        return True
-                    return False
+            for item in self.qom_list(path):
+                if item.name == 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=path):
-            yield str(item['name'])
+        for item in self.qom_list(path):
+            yield item.name
 
 
 if __name__ == '__main__':
-- 
2.31.1



  parent reply	other threads:[~2021-06-03  0:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  0:37 [PATCH v3 00/19] Python: move /scripts/qmp/qom* to /python/qemu/qmp/qom* John Snow
2021-06-03  0:37 ` [PATCH v3 01/19] python/pipenv: Update Pipfile.lock John Snow
2021-06-03  0:37 ` [PATCH v3 02/19] python/qmp: Fix type of SocketAddrT John Snow
2021-06-03  7:07   ` Philippe Mathieu-Daudé
2021-06-03  0:37 ` [PATCH v3 03/19] python/qmp: add parse_address classmethod John Snow
2021-06-03  0:37 ` [PATCH v3 04/19] python/qmp: Add qom script rewrites John Snow
2021-06-03  0:37 ` [PATCH v3 05/19] python/qmp: add qom script entry points John Snow
2021-06-03  0:37 ` [PATCH v3 06/19] scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/ John Snow
2021-06-03  0:37 ` [PATCH v3 07/19] scripts/qom-fuse: apply isort rules John Snow
2021-06-03  0:37 ` [PATCH v3 08/19] scripts/qom-fuse: apply flake8 rules John Snow
2021-06-03  7:08   ` Philippe Mathieu-Daudé
2021-06-03  0:37 ` [PATCH v3 09/19] python: Add 'fh' to known-good variable names John Snow
2021-06-03  0:37 ` [PATCH v3 10/19] scripts/qom-fuse: Apply pylint rules John Snow
2021-06-03  0:37 ` [PATCH v3 11/19] scripts/qom-fuse: Add docstrings John Snow
2021-06-03  0:37 ` [PATCH v3 12/19] scripts/qom-fuse: Convert to QOMCommand John Snow
2021-06-03  0:37 ` John Snow [this message]
2021-06-03  7:09   ` [PATCH v3 13/19] scripts/qom-fuse: use QOMCommand.qom_list() Philippe Mathieu-Daudé
2021-06-03  0:37 ` [PATCH v3 14/19] scripts/qom-fuse: ensure QOMFuse.read always returns bytes John Snow
2021-06-03  0:37 ` [PATCH v3 15/19] scripts/qom-fuse: add static type hints John Snow
2021-06-03  0:37 ` [PATCH v3 16/19] python: add optional FUSE dependencies John Snow
2021-06-03  0:37 ` [PATCH v3 17/19] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py John Snow
2021-06-03  0:37 ` [PATCH v3 18/19] scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py John Snow
2021-06-03  0:37 ` [PATCH v3 19/19] python/qmp: add fuse command to 'qom' tools John Snow
2021-06-03  7:11   ` Philippe Mathieu-Daudé
2021-06-09 20:32 ` [PATCH v3 00/19] Python: move /scripts/qmp/qom* to /python/qemu/qmp/qom* John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210603003719.1321369-14-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=niteesh.gs@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).