Max Reitz <mre...@redhat.com> writes: > On 2014-11-28 at 16:55, Markus Armbruster wrote: >> Copying Luiz. >> >> Max Reitz <mre...@redhat.com> writes: >> >>> This series does not add new functionality. Adding a QMP monitor with >>> prettily formatted JSON output can be done as follows: >>> >>> $ qemu -chardev stdio,id=mon0 -mon chardev=mon0,mode=control,pretty=on >>> >>> However, this is rather cumbersome, so this series (its first patch) >>> adds a shortcut in the form of the new command line option -qmp-pretty. >>> >>> Since the argument given to a monitor command line option (such as -qmp) >>> is parsed depending on its prefix and probably also depending on the >>> current phase of the moon, this is cleaner than trying to add a "switch" >>> to -qmp itself (in the form of "-qmp stdio,pretty=on"). >> Yet another "convenience" option *groan* >> >> Why can't we simply make -qmp set pretty=on and be done with it? >> It's a convenience option, i.e. meant for humans, and why would humans >> *not* want pretty=on? > > Well, pretty=on produces really long output. I prefer short output if > I don't expect to run commands like query-block which are completely > unreadable with pretty=off. > > I personally had a really bad taste when I saw that I couldn't modify > -qmp somehow to get it to set pretty=on optionally. But then, after > having implemented -qmp-pretty in basically five lines (the "case" > statement for that option and the qemu_opt_set_bool() in > monitor_parse()), I could send the series with a clear > conscience. It's not that there's a new convenience option which is > really bad to maintain and will break after the first gentle blow, as > it reuses all the code paths from -qmp, which we will keep anyway.
The implementation complexity doesn't worry me. I dislike the interface complexity. We're stuck with two sugar options around -mon, but adding a *third* is pushing it too far for me. > Since this is only in block-next, I wouldn't object to it being > dropped and making pretty=on the default for -qmp, in principle. But I > personally like having a convenience pretty=off option, too, because I > as a human often actually don't want pretty=on. -set mon.compat_monitor0.pretty=off ;-P Alternatively, define a pretty and an ugly monitor in a configuration file, and connect to the one you want: [chardev "qmp"] backend = "socket" path = "sock-qmp" server = "on" wait = "off" [mon "qmp"] mode = "control" chardev = "qmp" pretty = "off" [chardev "qmp-pretty"] backend = "socket" path = "sock-qmp-pretty" server = "on" wait = "off" [mon "qmp-pretty"] mode = "control" chardev = "qmp-pretty" pretty = "on" Alternatively^2, create a QMP command to toggle prettiness.