e1000: Fixing the packet address filtering procedure
[qemu/ar7.git] / scripts / qmp / qom-set
blob54ecfecc531ea042665e6e44984dddcacba33b8f
1 #!/usr/bin/python
2 ##
3 # QEMU Object Model test tools
5 # Copyright IBM, Corp. 2011
7 # Authors:
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 import sys
15 import os
16 from qmp import QEMUMonitorProtocol
18 cmd, args = sys.argv[0], sys.argv[1:]
19 socket_path = None
20 path = None
21 prop = None
22 value = None
24 def usage():
25 return '''environment variables:
26 QMP_SOCKET=<path | addr:port>
27 usage:
28 %s [-h] [-s <QMP socket path | addr:port>] <path>.<property> <value>
29 ''' % cmd
31 def usage_error(error_msg = "unspecified error"):
32 sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg))
33 exit(1)
35 if len(args) > 0:
36 if args[0] == "-h":
37 print usage()
38 exit(0);
39 elif args[0] == "-s":
40 try:
41 socket_path = args[1]
42 except:
43 usage_error("missing argument: QMP socket path or address");
44 args = args[2:]
46 if not socket_path:
47 if os.environ.has_key('QMP_SOCKET'):
48 socket_path = os.environ['QMP_SOCKET']
49 else:
50 usage_error("no QMP socket path or address given");
52 if len(args) > 1:
53 try:
54 path, prop = args[0].rsplit('.', 1)
55 except:
56 usage_error("invalid format for path/property/value")
57 value = args[1]
58 else:
59 usage_error("not enough arguments")
61 srv = QEMUMonitorProtocol(socket_path)
62 srv.connect()
64 print srv.command('qom-set', path=path, property=prop, value=sys.argv[2])