All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/qmp: delete 'qmp' script
@ 2020-10-19 21:04 John Snow
  2020-10-19 21:29 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: John Snow @ 2020-10-19 21:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, Markus Armbruster, Eduardo Habkost

This script has not seen a patch that was specifically for this script
since it was moved to this location in 2013, and I doubt it is used. It
uses "man qmp" for its help message, which does not exist. It also
presumes there is a manual page for qmp-XXX, for each defined qmp
command XXX. I don't think that's true.

The format it expects arguments in is something like:

block-dirty-bitmap-add --node=foo --name=bar

and has no capacity to support nested JSON arguments, either.

Most developers use either qmp-shell or socat (or pasting JSON directly
into qmp stdio), so this duplication and additional alternate syntax is
not helpful.

Remove it. Leave a breadcrumb script just in case, to be removed next
release cycle.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qmp/qmp | 131 +++---------------------------------------------
 1 file changed, 7 insertions(+), 124 deletions(-)

diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp
index 8e52e4a54d..0f12307c87 100755
--- a/scripts/qmp/qmp
+++ b/scripts/qmp/qmp
@@ -1,128 +1,11 @@
 #!/usr/bin/env python3
-#
-# QMP command line tool
-#
-# Copyright IBM, Corp. 2011
-#
-# Authors:
-#  Anthony Liguori <aliguori@us.ibm.com>
-#
-# This work is licensed under the terms of the GNU GPLv2 or later.
-# See the COPYING file in the top-level directory.
 
-import sys, os
+import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+print('''This unmaintained and undocumented script was removed in preference
+for qmp-shell. The assumption is that most users are using either
+qmp-shell, socat, or pasting/piping JSON into stdio. The duplication of
+facilities here is unwanted, and the divergence of syntax harmful.''',
+      file=sys.stderr)
 
-def print_response(rsp, prefix=[]):
-    if type(rsp) == list:
-        i = 0
-        for item in rsp:
-            if prefix == []:
-                prefix = ['item']
-            print_response(item, prefix[:-1] + ['%s[%d]' % (prefix[-1], i)])
-            i += 1
-    elif type(rsp) == dict:
-        for key in rsp.keys():
-            print_response(rsp[key], prefix + [key])
-    else:
-        if len(prefix):
-            print('%s: %s' % ('.'.join(prefix), rsp))
-        else:
-            print('%s' % (rsp))
-
-def main(args):
-    path = None
-
-    # Use QMP_PATH if it's set
-    if 'QMP_PATH' in os.environ:
-        path = os.environ['QMP_PATH']
-
-    while len(args):
-        arg = args[0]
-
-        if arg.startswith('--'):
-            arg = arg[2:]
-            if arg.find('=') == -1:
-                value = True
-            else:
-                arg, value = arg.split('=', 1)
-
-            if arg in ['path']:
-                if type(value) == str:
-                    path = value
-            elif arg in ['help']:
-                os.execlp('man', 'man', 'qmp')
-            else:
-                print('Unknown argument "%s"' % arg)
-
-            args = args[1:]
-        else:
-            break
-
-    if not path:
-        print("QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH")
-        return 1
-
-    if len(args):
-        command, args = args[0], args[1:]
-    else:
-        print('No command found')
-        print('Usage: "qmp [--path=qmp-monitor-address] qmp-cmd arguments"')
-        return 1
-
-    if command in ['help']:
-        os.execlp('man', 'man', 'qmp')
-
-    srv = QEMUMonitorProtocol(path)
-    srv.connect()
-
-    def do_command(srv, cmd, **kwds):
-        rsp = srv.cmd(cmd, kwds)
-        if 'error' in rsp:
-            raise Exception(rsp['error']['desc'])
-        return rsp['return']
-
-    commands = map(lambda x: x['name'], do_command(srv, 'query-commands'))
-
-    srv.close()
-
-    if command not in commands:
-        fullcmd = 'qmp-%s' % command
-        try:
-            os.environ['QMP_PATH'] = path
-            os.execvp(fullcmd, [fullcmd] + args)
-        except OSError as exc:
-            if exc.errno == 2:
-                print('Command "%s" not found.' % (fullcmd))
-                return 1
-            raise
-        return 0
-
-    srv = QEMUMonitorProtocol(path)
-    srv.connect()
-
-    arguments = {}
-    for arg in args:
-        if not arg.startswith('--'):
-            print('Unknown argument "%s"' % arg)
-            return 1
-
-        arg = arg[2:]
-        if arg.find('=') == -1:
-            value = True
-        else:
-            arg, value = arg.split('=', 1)
-
-        if arg in ['help']:
-            os.execlp('man', 'man', 'qmp-%s' % command)
-            return 1
-
-        arguments[arg] = value
-
-    rsp = do_command(srv, command, **arguments)
-    print_response(rsp)
-
-if __name__ == '__main__':
-    sys.exit(main(sys.argv[1:]))
+sys.exit(1)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/qmp: delete 'qmp' script
  2020-10-19 21:04 [PATCH] scripts/qmp: delete 'qmp' script John Snow
@ 2020-10-19 21:29 ` Eric Blake
  2020-10-20  5:44 ` Thomas Huth
  2020-10-20  6:44 ` Markus Armbruster
  2 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2020-10-19 21:29 UTC (permalink / raw)
  To: John Snow, qemu-devel; +Cc: Markus Armbruster, Eduardo Habkost

On 10/19/20 4:04 PM, John Snow wrote:
> This script has not seen a patch that was specifically for this script
> since it was moved to this location in 2013, and I doubt it is used. It
> uses "man qmp" for its help message, which does not exist. It also
> presumes there is a manual page for qmp-XXX, for each defined qmp
> command XXX. I don't think that's true.
> 
> The format it expects arguments in is something like:
> 
> block-dirty-bitmap-add --node=foo --name=bar
> 
> and has no capacity to support nested JSON arguments, either.
> 
> Most developers use either qmp-shell or socat (or pasting JSON directly
> into qmp stdio), so this duplication and additional alternate syntax is
> not helpful.
> 
> Remove it. Leave a breadcrumb script just in case, to be removed next
> release cycle.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>   scripts/qmp/qmp | 131 +++---------------------------------------------
>   1 file changed, 7 insertions(+), 124 deletions(-)
> 
> -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
> -from qemu.qmp import QEMUMonitorProtocol
> +print('''This unmaintained and undocumented script was removed in preference
> +for qmp-shell. The assumption is that most users are using either
> +qmp-shell, socat, or pasting/piping JSON into stdio. The duplication of
> +facilities here is unwanted, and the divergence of syntax harmful.''',
> +      file=sys.stderr)
>   

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/qmp: delete 'qmp' script
  2020-10-19 21:04 [PATCH] scripts/qmp: delete 'qmp' script John Snow
  2020-10-19 21:29 ` Eric Blake
@ 2020-10-20  5:44 ` Thomas Huth
  2020-10-26 19:29   ` Laurent Vivier
  2020-10-20  6:44 ` Markus Armbruster
  2 siblings, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2020-10-20  5:44 UTC (permalink / raw)
  To: John Snow, qemu-devel; +Cc: QEMU Trivial, Markus Armbruster, Eduardo Habkost

On 19/10/2020 23.04, John Snow wrote:
> This script has not seen a patch that was specifically for this script
> since it was moved to this location in 2013, and I doubt it is used. It
> uses "man qmp" for its help message, which does not exist. It also
> presumes there is a manual page for qmp-XXX, for each defined qmp
> command XXX. I don't think that's true.
> 
> The format it expects arguments in is something like:
> 
> block-dirty-bitmap-add --node=foo --name=bar
> 
> and has no capacity to support nested JSON arguments, either.
> 
> Most developers use either qmp-shell or socat (or pasting JSON directly
> into qmp stdio), so this duplication and additional alternate syntax is
> not helpful.
> 
> Remove it. Leave a breadcrumb script just in case, to be removed next
> release cycle.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  scripts/qmp/qmp | 131 +++---------------------------------------------
>  1 file changed, 7 insertions(+), 124 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/qmp: delete 'qmp' script
  2020-10-19 21:04 [PATCH] scripts/qmp: delete 'qmp' script John Snow
  2020-10-19 21:29 ` Eric Blake
  2020-10-20  5:44 ` Thomas Huth
@ 2020-10-20  6:44 ` Markus Armbruster
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2020-10-20  6:44 UTC (permalink / raw)
  To: John Snow; +Cc: qemu-devel, Eduardo Habkost

John Snow <jsnow@redhat.com> writes:

> This script has not seen a patch that was specifically for this script
> since it was moved to this location in 2013, and I doubt it is used. It
> uses "man qmp" for its help message, which does not exist. It also
> presumes there is a manual page for qmp-XXX, for each defined qmp
> command XXX. I don't think that's true.
>
> The format it expects arguments in is something like:
>
> block-dirty-bitmap-add --node=foo --name=bar
>
> and has no capacity to support nested JSON arguments, either.
>
> Most developers use either qmp-shell or socat (or pasting JSON directly
> into qmp stdio), so this duplication and additional alternate syntax is
> not helpful.
>
> Remove it. Leave a breadcrumb script just in case, to be removed next
> release cycle.
>
> Signed-off-by: John Snow <jsnow@redhat.com>

Queued, thanks!



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/qmp: delete 'qmp' script
  2020-10-20  5:44 ` Thomas Huth
@ 2020-10-26 19:29   ` Laurent Vivier
  0 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2020-10-26 19:29 UTC (permalink / raw)
  To: Thomas Huth, John Snow, qemu-devel
  Cc: QEMU Trivial, Markus Armbruster, Eduardo Habkost

Le 20/10/2020 à 07:44, Thomas Huth a écrit :
> On 19/10/2020 23.04, John Snow wrote:
>> This script has not seen a patch that was specifically for this script
>> since it was moved to this location in 2013, and I doubt it is used. It
>> uses "man qmp" for its help message, which does not exist. It also
>> presumes there is a manual page for qmp-XXX, for each defined qmp
>> command XXX. I don't think that's true.
>>
>> The format it expects arguments in is something like:
>>
>> block-dirty-bitmap-add --node=foo --name=bar
>>
>> and has no capacity to support nested JSON arguments, either.
>>
>> Most developers use either qmp-shell or socat (or pasting JSON directly
>> into qmp stdio), so this duplication and additional alternate syntax is
>> not helpful.
>>
>> Remove it. Leave a breadcrumb script just in case, to be removed next
>> release cycle.
>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>> ---
>>  scripts/qmp/qmp | 131 +++---------------------------------------------
>>  1 file changed, 7 insertions(+), 124 deletions(-)
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-26 19:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 21:04 [PATCH] scripts/qmp: delete 'qmp' script John Snow
2020-10-19 21:29 ` Eric Blake
2020-10-20  5:44 ` Thomas Huth
2020-10-26 19:29   ` Laurent Vivier
2020-10-20  6:44 ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.