scripts/qmp/qom-fuse: Fix getattr(), read() for files in /
authorMarkus Armbruster <armbru@redhat.com>
Thu, 23 Jul 2020 14:27:38 +0000 (16:27 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 3 Sep 2020 07:44:33 +0000 (09:44 +0200)
path, prop = "type".rsplit('/', 1) sets path to "", which doesn't
work.  Correct to "/".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200723142738.1868568-4-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
scripts/qmp/qom-fuse

index 405e6ebd6719abacaf5050e06482bfda5defd1b9..7c7cff8edfba1dd75aaf56f0b69c6341662f87e4 100755 (executable)
@@ -45,8 +45,10 @@ class QOMFS(Operations):
             return False
 
     def is_property(self, path):
+        path, prop = path.rsplit('/', 1)
+        if path == '':
+            path = '/'
         try:
-            path, prop = path.rsplit('/', 1)
             for item in self.qmp.command('qom-list', path=path):
                 if item['name'] == prop:
                     return True
@@ -55,8 +57,10 @@ class QOMFS(Operations):
             return False
 
     def is_link(self, path):
+        path, prop = path.rsplit('/', 1)
+        if path == '':
+            path = '/'
         try:
-            path, prop = path.rsplit('/', 1)
             for item in self.qmp.command('qom-list', path=path):
                 if item['name'] == prop:
                     if item['type'].startswith('link<'):
@@ -71,6 +75,8 @@ class QOMFS(Operations):
             return -ENOENT
 
         path, prop = path.rsplit('/', 1)
+        if path == '':
+            path = '/'
         try:
             data = self.qmp.command('qom-get', path=path, property=prop)
             data += '\n' # make values shell friendly