3 # QEMU Object Model test tools
5 # Copyright IBM, Corp. 2011
8 # Anthony Liguori <aliguori@us.ibm.com>
10 # This work is licensed under the terms of the GNU GPL, version 2 or later. See
11 # the COPYING file in the top-level directory.
14 from __future__
import print_function
17 from qmp
import QEMUMonitorProtocol
19 cmd
, args
= sys
.argv
[0], sys
.argv
[1:]
26 return '''environment variables:
27 QMP_SOCKET=<path | addr:port>
29 %s [-h] [-s <QMP socket path | addr:port>] <path>.<property> <value>
32 def usage_error(error_msg
= "unspecified error"):
33 sys
.stderr
.write('%s\nERROR: %s\n' % (usage(), error_msg
))
44 usage_error("missing argument: QMP socket path or address");
48 if 'QMP_SOCKET' in os
.environ
:
49 socket_path
= os
.environ
['QMP_SOCKET']
51 usage_error("no QMP socket path or address given");
55 path
, prop
= args
[0].rsplit('.', 1)
57 usage_error("invalid format for path/property/value")
60 usage_error("not enough arguments")
62 srv
= QEMUMonitorProtocol(socket_path
)
65 print(srv
.command('qom-set', path
=path
, property=prop
, value
=value
))