summaryrefslogtreecommitdiff
path: root/scripts/qmp
AgeCommit message (Collapse)AuthorFilesLines
2018-03-12qmp.py: Encode json data before sendingEduardo Habkost1-1/+1
On Python 3, json.dumps() return a str object, which can't be sent directly through a socket and must be encoded into a bytes object. Use .encode('utf-8'), which will work on both Python 2 and Python 3. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20180312185503.5746-3-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-11-21Use HTTPS for qemu.org and other domainsStefan Hajnoczi1-1/+1
qemu.org enabled HTTPS in 2017 and it should be used instead of HTTP. There are also URLs to json.org, openvpn.net, and other domains that support HTTPS. This patch updates the qemu.org domains everywhere and also third-party domains that I have checked. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20171121120435.28728-3-stefanha@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-11-21Use qemu.org domain nameStefan Hajnoczi1-1/+1
The owner of qemu.org has delegated authority to modify DNS records to the QEMU Project. This has allowed us to use the domain name without worries about IP address changes or technical issues disrupting service. The issues described in commit 859389810910f232188675d2f10b15f1aad77660 ("Use qemu-project.org domain name") have therefore been mitigated. This patch switches back to consistently using qemu.org instead of qemu-project.org in documentation, version.rc, and the Windows installer script. The git submodules and SeaBIOS still use qemu-project.org for the time being. This will be fixed in the QEMU 2.12 release cycle. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20171121120435.28728-2-stefanha@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-10-11scripts: Remove debug parameter from QEMUMonitorProtocolEduardo Habkost1-9/+7
Use logging module for the QMP debug messages. The only scripts that set debug=True are iotests.py and guestperf/engine.py, and they already call logging.basicConfig() to set up logging. Scripts that don't configure logging are safe as long as they don't need debugging output, because debug messages don't trigger the "No handlers could be found for logger" message from the Python logging module. Scripts that already configure logging but don't use debug=True (e.g. scripts/vm/basevm.py) will get QMP debugging enabled for free. Cc: "Alex Bennée" <alex.bennee@linaro.org> Cc: Fam Zheng <famz@redhat.com> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20171005172013.3098-3-ehabkost@redhat.com> Reviewed-by: Lukáš Doktor <ldoktor@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-09-15qmp.py: Avoid overriding a builtin objectLukáš Doktor1-4/+4
The "id" is a builtin method to get object's identity and should not be overridden. This might bring some issues in case someone was directly calling "cmd(..., id=id)" but I haven't found such usage on brief search for "cmd\(.*id=". Signed-off-by: Lukáš Doktor <ldoktor@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20170818142613.32394-10-ldoktor@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-09-15qmp.py: Avoid "has_key" usageLukáš Doktor1-1/+1
The "has_key" is deprecated in favor of "__in__" operator. Signed-off-by: Lukáš Doktor <ldoktor@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20170818142613.32394-9-ldoktor@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-09-15qmp.py: Use object-based class for QEMUMonitorProtocolLukáš Doktor2-3/+3
There is no need to define QEMUMonitorProtocol as old-style class. Signed-off-by: Lukáš Doktor <ldoktor@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20170818142613.32394-8-ldoktor@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-09-15qmp.py: Couple of pylint/style fixesLukáš Doktor1-13/+24
No actual code changes, just initializing attributes earlier to avoid AttributeError on early introspection, a few pylint/style fixes and docstring clarifications. Signed-off-by: Lukáš Doktor <ldoktor@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20170818142613.32394-7-ldoktor@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-05-23scripts/qmp/qom-set: fix the value argument passed to srv.command()Greg Kurz1-1/+1
When invoking the script with -s, we end up passing a bogus value to QEMU: $ ./scripts/qmp/qom-set -s /var/tmp/qmp-sock-exp /machine.accel kvm {} $ ./scripts/qmp/qom-get -s /var/tmp/qmp-sock-exp /machine.accel /var/tmp/qmp-sock-exp This happens because sys.argv[2] isn't necessarily the command line argument that holds the value. It is sys.argv[4] when -s was also passed. Actually, the code already has a variable to handle that. This patch simply uses it. Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <149373610338.5144.9635049015143453288.stgit@bahia.lan> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-05-09qmp-shell: improve helpMarc-André Lureau1-1/+5
Describe the arguments & fix the tool name. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170504125432.21653-5-marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-05-09qmp-shell: don't show version greeting if unavailableMarc-André Lureau1-0/+3
qemu-ga doesn't have greeting. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170504125432.21653-4-marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-05-09qmp-shell: Cope with query-commands errorMarc-André Lureau1-1/+4
qemu-ga doesn't implement it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170504125432.21653-3-marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-05-09qmp-shell: add -N option to skip negotiateMarc-André Lureau1-4/+7
qemu-ga doesn't have negotiate phase. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170504125432.21653-2-marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-05-09qmp-shell: add persistent command historyJohn Snow1-0/+21
Use the existing readline history function we are utilizing to provide persistent command history across instances of qmp-shell. This assists entering debug commands across sessions that may be interrupted by QEMU sessions terminating, where the qmp-shell has to be relaunched. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20170427223628.20893-1-jsnow@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com> Tested-by: Kashyap Chamarthy <kchamart@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-03-16qmp: allow setting properties to empty string in qmp-shellDaniel P. Berrange1-2/+2
The qmp-shell property parser currently rejects attempts to set string properties to the empty string eg (QEMU) migrate-set-parameters tls-hostname= Error while parsing command line: Expected a key=value pair, got 'tls-hostname=' command format: <command-name> [arg-name1=arg1] ... [arg-nameN=argN] This is caused by checking the wrong condition after splitting the parameter on '='. The "partition" method will return "" for the separator field, if the seperator was not present, so that is the correct thing to check for malformed syntax. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <20170302122429.7737-1-berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-22scripts: ensure monitor socket has SO_REUSEADDR setDaniel P. Berrange1-0/+1
If tests use a TCP based monitor socket, the connection will go into a TIMED_WAIT state when the test exits. This will randomly prevent the test from being re-run without a certain time period. Set the SO_REUSEADDR flag on the socket to ensure we can immediately re-run the tests Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1469020993-29426-6-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2016-07-22scripts: set timeout when waiting for qemu monitor connectionDaniel P. Berrange1-0/+1
If QEMU fails to launch for some reason, the QEMUMonitorProtocol class accept() method will wait forever in a socket accept call. Set a timeout of 15 seconds so that we fail more gracefully instead of hanging the test script forever Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1469020993-29426-5-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2016-07-22scripts: add a 'debug' parameter to QEMUMonitorProtocolDaniel P. Berrange1-2/+11
Add a 'debug' parameter to the QEMUMonitorProtocol class which will cause it to print out all JSON strings on sys.stderr Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1469020993-29426-3-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2016-07-22scripts: add __init__.py file to scripts/qmp/Daniel P. Berrange1-0/+0
When searching for modules to load, python will ignore any sub-directory which does not contain __init__.py. This means that both scripts and scripts/qmp/ have to be explicitly added to the python path. By adding a __init__.py file to scripts/qmp, we only need add scripts/ to the python path and can then simply do 'from qmp import qmp' to load scripts/qmp/qmp.py. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1469020993-29426-2-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2016-03-04qmp-shell: fix pretty printing of JSON responsesDaniel P. Berrange1-13/+10
Pretty printing of JSON responses is important to be able to understand large responses from query commands in particular. Unfortunately this was broken during the addition of the verbose flag in commit 1ceca07e48ead0dd2e41576c81d40e6a91cafefd Author: John Snow <jsnow@redhat.com> Date: Wed Apr 29 15:14:04 2015 -0400 scripts: qmp-shell: Add verbose flag This is because that change turned the python data structure into a formatted JSON string before the pretty print was given it. So we're just pretty printing a string, which is a no-op. The original pretty printer would output python objects. (QEMU) query-chardev { u'return': [ { u'filename': u'vc', u'frontend-open': False, u'label': u'parallel0'}, { u'filename': u'vc', u'frontend-open': True, u'label': u'serial0'}, { u'filename': u'unix:/tmp/qemp,server', u'frontend-open': True, u'label': u'compat_monitor0'}]} This fixes the problem by switching to outputting pretty formatted JSON text instead. This has the added benefit that the pretty printed output is now valid JSON text. Due to the way the verbose flag was handled, the pretty printing now applies to the command sent, as well as its response: (QEMU) query-chardev { "execute": "query-chardev", "arguments": {} } { "return": [ { "frontend-open": false, "label": "parallel0", "filename": "vc" }, { "frontend-open": true, "label": "serial0", "filename": "vc" }, { "frontend-open": true, "label": "compat_monitor0", "filename": "unix:/tmp/qmp,server" } ] } Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1456224706-1591-1-git-send-email-berrange@redhat.com> Tested-by: Kashyap Chamarthy <kchamart@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> [Bonus fix: multiple -p now work] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-02-08scripts/qmp: Use Python 2.6 "except E as ..." syntaxMarkus Armbruster4-6/+6
PEP 8 calls for it, because it's forward compatible with Python 3. Supported since Python 2.6, which we require (commit fec2103). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <1450425164-24969-3-git-send-email-armbru@redhat.com>
2015-09-04qmp-shell: add documentationJohn Snow1-0/+35
I should probably document the changes that were made. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <1435775149-17285-1-git-send-email-jsnow@redhat.com> Reviewed-By: Kashyap Chamarthy <kchamart@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-19scripts: Add support for path as argument of qom-treeMartin Cerveny1-2/+7
Add processing of optional argument path as "tree base". Signed-off-by: Martin Cerveny <M.Cerveny@computer.org> Signed-off-by: Andreas Färber <afaerber@suse.de>
2015-05-11scripts: qmp-shell: Add verbose flagJohn Snow1-6/+18
Add a verbose flag that shows the QMP command that was constructed, to allow for later copy/pasting, reference, debugging, etc. The QMP is converted from a Python literal to JSON first, to ensure that it is viable input to the actual QMP parser. As a side-effect, this JSON output will helpfully show all the necessary conversions that were performed on the input, illustrating that "True" was transformed back into "true", literal values are now escaped with "" instead of '', and so on. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Kashyap Chamarthy <kchamart@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-05-11scripts: qmp-shell: add transaction subshellJohn Snow1-1/+41
Add a special processing mode to craft transactions. By entering "transaction(" the shell will enter a special mode where each subsequent command will be saved as a transaction instead of executed as an individual command. The transaction can be submitted by entering ")" on a line by itself. Examples: Separate lines: (QEMU) transaction( TRANS> block-dirty-bitmap-add node=drive0 name=bitmap1 TRANS> block-dirty-bitmap-clear node=drive0 name=bitmap0 TRANS> ) With a transaction action included on the first line: (QEMU) transaction( block-dirty-bitmap-add node=drive0 name=bitmap2 TRANS> block-dirty-bitmap-add node=drive0 name=bitmap3 TRANS> ) As a one-liner, with just one transaction action: (QEMU) transaction( block-dirty-bitmap-add node=drive0 name=bitmap0 ) As a side-effect of this patch, blank lines are now parsed as no-ops, regardless of which shell mode you are in. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Kashyap Chamarthy <kchamart@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-05-11scripts: qmp-shell: Expand support for QMP expressionsJohn Snow1-16/+47
This includes support for [] expressions, single-quotes in QMP expressions (which is not strictly a part of JSON), and the ability to use "True", "False" and "None" literals instead of JSON's equivalent true, false, and null literals. qmp-shell currently allows you to describe values as JSON expressions: key={"key":{"key2":"val"}} But it does not currently support arrays, which are needed for serializing and deserializing transactions: key=[{"type":"drive-backup","data":{...}}] qmp-shell also only currently accepts doubly quoted strings as-per JSON spec, but QMP allows single quotes. Lastly, python allows you to utilize "True" or "False" as boolean literals, but JSON expects "true" or "false". Expand qmp-shell to allow the user to type either, converting to the correct type. As a consequence of the above, the key=val parsing is also improved to give better error messages if a key=val token is not provided. CAVEAT: The parser is still extremely rudimentary and does not expect to find spaces in {} nor [] expressions. This patch does not improve this functionality. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Kashyap Chamarthy <kchamart@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-05-11scripts: qmp-shell: refactor helpersJohn Snow1-11/+13
Refactor the qmp-shell command line processing function into two components. This will be used to allow sub-expressions, which will assist us in adding transactional support to qmp-shell. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Kashyap Chamarthy <kchamart@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-04-28iotests: add QMP event waiting queueJohn Snow1-30/+65
A filter is added to allow callers to request very specific events to be pulled from the event queue, while leaving undesired events still in the stream. This allows us to poll for completion data for multiple asynchronous events in any arbitrary order. A new timeout context is added to the qmp pull_event method's wait parameter to allow tests to fail if they do not complete within some expected period of time. Also fixed is a bug in qmp.pull_event where we try to retrieve an event from an empty list if we attempt to retrieve an event with wait=False but no events have occurred. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1429314609-29776-19-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-03-17scripts: Add qom-tree scriptAndreas Färber1-0/+70
Functionally it is a recursive qom-list with qom-get per non-child<> property. Some failures needed to be handled, such as trying to read a pointer property, which is not representable in QMP. Those print a literal "<EXCEPTION>". Tested-by: Alistair Francis <alistair.francis@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-02-28qmp: Check for returned data from __json_read in get_eventsFam Zheng1-1/+6
When QEMU process aborts and socket is closed, qmp client will not detect it. When this happens, some qemu-iotests scripts will enter an endless loop waiting for qmp events. It's better we raise an exception in qmp.py to catch this and make the test script stop. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28QMP: Allow dot separated dict path arguments in qmp-shellFam Zheng1-2/+18
As another convenience to allow using commands that expect a dict as argument, this patch adds support for foo.bar=value syntax, similar to command line argument style: (QEMU) blockdev-add options.driver=file options.id=drive1 options.filename=... Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-17QMP: allow JSON dict arguments in qmp-shellStefan Hajnoczi1-0/+3
qmp-shell hides the QMP wire protocol JSON encoding from the user. Most of the time this is helpful and makes the command-line human-friendly. Some QMP commands take a dict as an argument. In order to express this we need to revert back to JSON notation. This patch allows JSON dict arguments in qmp-shell so commands like blockdev-add and nbd-server-start can be invoked: (QEMU) blockdev-add options={"driver":"file","id":"drive1",...} Note that spaces are not allowed since str.split() is used to break up the command-line arguments first. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-10-11Use qemu-project.org domain nameStefan Hajnoczi1-1/+1
qemu.org is held by a third-party and no core community contributor has access to the DNS configuration. This leaves the website exposed to outages due to DNS issues or IP address changes. For example, if the web server IP address needs to change we cannot guarantee qemu.org will point to it! The newer qemu-project.org domain name is owned by Anthony Liguori <anthony@codemonkey.ws>. You can confirm this by querying the whois information. Also note that the #qemu IRC channel topic already references qemu-project.org. Short of having a dedicated legal entity to hold the domain name on behalf of the community, qemu-project.org seems like the safest bet. Let's replace references to qemu.org with qemu-project.org. Note that git-submodule(1) does not detect URL changes. The following commands clear out and re-initialize all submodules to ensure you are using the latest URLs: $ git submodule deinit . # you'll be warned if you have local changes $ rm -rf .git/modules # also clear cached .git/ directories $ git submodule update --init Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1381495958-8306-1-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@amazon.com>
2013-09-18QMP: add scripts/qmpLuiz Capitulino8-0/+1242
Populate it with all scripts stored in QMP/. Also fixes trailing whitespaces in qmp-shell and qmp.py. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>