python/qmp: switch qom tools to AQMP
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Beraldo Leal <bleal@redhat.com>
This commit is contained in:
parent
26db07516f
commit
8d6cdc5118
|
@ -32,7 +32,8 @@ QOM commands:
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from . import QMPResponseError
|
from qemu.aqmp import ExecuteError
|
||||||
|
|
||||||
from .qom_common import QOMCommand
|
from .qom_common import QOMCommand
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ class QOMTree(QOMCommand):
|
||||||
rsp = self.qmp.command('qom-get', path=path,
|
rsp = self.qmp.command('qom-get', path=path,
|
||||||
property=item.name)
|
property=item.name)
|
||||||
print(f" {item.name}: {rsp} ({item.type})")
|
print(f" {item.name}: {rsp} ({item.type})")
|
||||||
except QMPResponseError as err:
|
except ExecuteError as err:
|
||||||
print(f" {item.name}: <EXCEPTION: {err!s}> ({item.type})")
|
print(f" {item.name}: <EXCEPTION: {err!s}> ({item.type})")
|
||||||
print('')
|
print('')
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|
|
@ -27,7 +27,8 @@ from typing import (
|
||||||
TypeVar,
|
TypeVar,
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import QEMUMonitorProtocol, QMPError
|
from qemu.aqmp import QMPError
|
||||||
|
from qemu.aqmp.legacy import QEMUMonitorProtocol
|
||||||
|
|
||||||
|
|
||||||
class ObjectPropertyInfo:
|
class ObjectPropertyInfo:
|
||||||
|
|
|
@ -48,7 +48,8 @@ from typing import (
|
||||||
import fuse
|
import fuse
|
||||||
from fuse import FUSE, FuseOSError, Operations
|
from fuse import FUSE, FuseOSError, Operations
|
||||||
|
|
||||||
from . import QMPResponseError
|
from qemu.aqmp import ExecuteError
|
||||||
|
|
||||||
from .qom_common import QOMCommand
|
from .qom_common import QOMCommand
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ class QOMFuse(QOMCommand, Operations):
|
||||||
try:
|
try:
|
||||||
self.qom_list(path)
|
self.qom_list(path)
|
||||||
return True
|
return True
|
||||||
except QMPResponseError:
|
except ExecuteError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_property(self, path: str) -> bool:
|
def is_property(self, path: str) -> bool:
|
||||||
|
@ -112,7 +113,7 @@ class QOMFuse(QOMCommand, Operations):
|
||||||
if item.name == prop:
|
if item.name == prop:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
except QMPResponseError:
|
except ExecuteError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_link(self, path: str) -> bool:
|
def is_link(self, path: str) -> bool:
|
||||||
|
@ -125,7 +126,7 @@ class QOMFuse(QOMCommand, Operations):
|
||||||
if item.name == prop and item.link:
|
if item.name == prop and item.link:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
except QMPResponseError:
|
except ExecuteError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def read(self, path: str, size: int, offset: int, fh: IO[bytes]) -> bytes:
|
def read(self, path: str, size: int, offset: int, fh: IO[bytes]) -> bytes:
|
||||||
|
@ -138,7 +139,7 @@ class QOMFuse(QOMCommand, Operations):
|
||||||
try:
|
try:
|
||||||
data = str(self.qmp.command('qom-get', path=path, property=prop))
|
data = str(self.qmp.command('qom-get', path=path, property=prop))
|
||||||
data += '\n' # make values shell friendly
|
data += '\n' # make values shell friendly
|
||||||
except QMPResponseError as err:
|
except ExecuteError as err:
|
||||||
raise FuseOSError(EPERM) from err
|
raise FuseOSError(EPERM) from err
|
||||||
|
|
||||||
if offset > len(data):
|
if offset > len(data):
|
||||||
|
|
Loading…
Reference in New Issue