* [Qemu-devel] [PATCH 0/3] chardev: Add -qmp-pretty
@ 2014-11-11 13:34 Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 1/3] " Max Reitz
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Max Reitz @ 2014-11-11 13:34 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Markus Armbruster, Max Reitz, Stefan Hajnoczi,
Paolo Bonzini
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").
Patch 3 makes uses of the new option in qemu-iotest 067 to greatly
increase maintainability of its reference output. Patch 2 extends the
QMP filter for qemu-iotests so it is able to filter out the QMP version
object in pretty mode.
Max Reitz (3):
chardev: Add -qmp-pretty
iotests: _filter_qmp for pretty JSON output
iotests: Use -qmp-pretty in 067
qemu-options.hx | 8 +
tests/qemu-iotests/067 | 2 +-
tests/qemu-iotests/067.out | 779 ++++++++++++++++++++++++++++++++++++---
tests/qemu-iotests/common.filter | 16 +-
vl.c | 15 +-
5 files changed, 756 insertions(+), 64 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 1/3] chardev: Add -qmp-pretty
2014-11-11 13:34 [Qemu-devel] [PATCH 0/3] chardev: Add -qmp-pretty Max Reitz
@ 2014-11-11 13:34 ` Max Reitz
2014-11-12 4:41 ` Eric Blake
2014-11-11 13:34 ` [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067 Max Reitz
2 siblings, 1 reply; 11+ messages in thread
From: Max Reitz @ 2014-11-11 13:34 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Markus Armbruster, Max Reitz, Stefan Hajnoczi,
Paolo Bonzini
Add a command line option for adding a QMP monitor using pretty JSON
formatting.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
qemu-options.hx | 8 ++++++++
vl.c | 15 ++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index da9851d..bc7b4c2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2788,6 +2788,14 @@ STEXI
@findex -qmp
Like -monitor but opens in 'control' mode.
ETEXI
+DEF("qmp-pretty", HAS_ARG, QEMU_OPTION_qmp_pretty, \
+ "-qmp-pretty dev like -qmp but uses pretty JSON formatting\n",
+ QEMU_ARCH_ALL)
+STEXI
+@item -qmp-pretty @var{dev}
+@findex -qmp-pretty
+Like -qmp but uses pretty JSON formatting.
+ETEXI
DEF("mon", HAS_ARG, QEMU_OPTION_mon, \
"-mon [chardev=]name[,mode=readline|control][,default]\n", QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index f4a6e5e..c7bebad 100644
--- a/vl.c
+++ b/vl.c
@@ -2284,7 +2284,7 @@ static int mon_init_func(QemuOpts *opts, void *opaque)
return 0;
}
-static void monitor_parse(const char *optarg, const char *mode)
+static void monitor_parse(const char *optarg, const char *mode, bool pretty)
{
static int monitor_device_index = 0;
QemuOpts *opts;
@@ -2314,6 +2314,7 @@ static void monitor_parse(const char *optarg, const char *mode)
}
qemu_opt_set(opts, "mode", mode);
qemu_opt_set(opts, "chardev", label);
+ qemu_opt_set_bool(opts, "pretty", pretty);
if (def)
qemu_opt_set(opts, "default", "on");
monitor_device_index++;
@@ -3292,11 +3293,15 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_monitor:
default_monitor = 0;
if (strncmp(optarg, "none", 4)) {
- monitor_parse(optarg, "readline");
+ monitor_parse(optarg, "readline", false);
}
break;
case QEMU_OPTION_qmp:
- monitor_parse(optarg, "control");
+ monitor_parse(optarg, "control", false);
+ default_monitor = 0;
+ break;
+ case QEMU_OPTION_qmp_pretty:
+ monitor_parse(optarg, "control", true);
default_monitor = 0;
break;
case QEMU_OPTION_mon:
@@ -3994,7 +3999,7 @@ int main(int argc, char **argv, char **envp)
add_device_config(DEV_SCLP, "stdio");
}
if (default_monitor)
- monitor_parse("stdio", "readline");
+ monitor_parse("stdio", "readline", false);
}
} else {
if (default_serial)
@@ -4002,7 +4007,7 @@ int main(int argc, char **argv, char **envp)
if (default_parallel)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
if (default_monitor)
- monitor_parse("vc:80Cx24C", "readline");
+ monitor_parse("vc:80Cx24C", "readline", false);
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
if (default_sclp) {
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output
2014-11-11 13:34 [Qemu-devel] [PATCH 0/3] chardev: Add -qmp-pretty Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 1/3] " Max Reitz
@ 2014-11-11 13:34 ` Max Reitz
2014-11-12 4:47 ` Eric Blake
2014-11-11 13:34 ` [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067 Max Reitz
2 siblings, 1 reply; 11+ messages in thread
From: Max Reitz @ 2014-11-11 13:34 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Markus Armbruster, Max Reitz, Stefan Hajnoczi,
Paolo Bonzini
_filter_qmp should be able to correctly filter out the QMP version
object for pretty JSON output.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/common.filter | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 3acdb30..e24dab4 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -165,9 +165,23 @@ _filter_qemu()
# replace problematic QMP output like timestamps
_filter_qmp()
{
+ discard=0
+
_filter_win32 | \
sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
- -e 's#^{"QMP":.*}$#QMP_VERSION#'
+ -e 's#^{"QMP":.*}$#QMP_VERSION#' \
+ -e 's#\\#\\\\#g' | \
+ while IFS='' read line; do
+ if [[ $line == ' "QMP": {' ]]; then
+ discard=1
+ echo ' QMP_VERSION'
+ fi
+ if [[ $discard == 0 ]]; then
+ echo "$line"
+ elif [[ $discard == 1 && $line == ' }' ]]; then
+ discard=0
+ fi
+ done
}
# replace driver-specific options in the "Formatting..." line
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067
2014-11-11 13:34 [Qemu-devel] [PATCH 0/3] chardev: Add -qmp-pretty Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 1/3] " Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output Max Reitz
@ 2014-11-11 13:34 ` Max Reitz
2014-11-12 4:51 ` Eric Blake
2 siblings, 1 reply; 11+ messages in thread
From: Max Reitz @ 2014-11-11 13:34 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Markus Armbruster, Max Reitz, Stefan Hajnoczi,
Paolo Bonzini
067 invokes query-block, resulting in a reference output with really
long lines (which may pose a problem in email patches and always poses a
problem when the output changes, because it is hard to see what has
actually changed). Use -qmp-pretty to mitigate this issue.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/067 | 2 +-
tests/qemu-iotests/067.out | 779 +++++++++++++++++++++++++++++++++++++++++----
2 files changed, 723 insertions(+), 58 deletions(-)
diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067
index d025192..29cd6b5 100755
--- a/tests/qemu-iotests/067
+++ b/tests/qemu-iotests/067
@@ -39,7 +39,7 @@ _supported_os Linux
function do_run_qemu()
{
echo Testing: "$@"
- $QEMU -nographic -qmp stdio -serial none "$@"
+ $QEMU -nographic -qmp-pretty stdio -serial none "$@"
echo
}
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 0f72dcf..929dc74 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -4,77 +4,742 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
=== -drive/-device and device_del ===
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virtio-blk-pci,drive=disk,id=virtio0
-QMP_VERSION
-{"return": {}}
-{"return": [{"io-status": "ok", "device": "disk", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
+{
+ QMP_VERSION
+}
+{
+ "return": {
+ }
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "disk",
+ "locked": false,
+ "removable": false,
+ "inserted": {
+ "iops_rd": 0,
+ "detect_zeroes": "off",
+ "image": {
+ "virtual-size": 134217728,
+ "filename": "TEST_DIR/t.qcow2",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": SIZE,
+ "format-specific": {
+ "type": "qcow2",
+ "data": {
+ "compat": "1.1",
+ "lazy-refcounts": false,
+ "corrupt": false
+ }
+ },
+ "dirty-flag": false
+ },
+ "iops_wr": 0,
+ "ro": false,
+ "backing_file_depth": 0,
+ "drv": "qcow2",
+ "iops": 0,
+ "bps_wr": 0,
+ "encrypted": false,
+ "bps": 0,
+ "bps_rd": 0,
+ "file": "TEST_DIR/t.qcow2",
+ "encryption_key_missing": false
+ },
+ "type": "unknown"
+ },
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "path": "/machine/peripheral/virtio0/virtio-backend"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "device": "virtio0",
+ "path": "/machine/peripheral/virtio0"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "RESET"
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "SHUTDOWN"
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "ide1-cd0",
+ "tray-open": true
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "floppy0",
+ "tray-open": true
+ }
+}
=== -drive/device_add and device_del ===
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk
-QMP_VERSION
-{"return": {}}
-{"return": [{"device": "disk", "locked": false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"return": {}}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
+{
+ QMP_VERSION
+}
+{
+ "return": {
+ }
+}
+{
+ "return": [
+ {
+ "device": "disk",
+ "locked": false,
+ "removable": true,
+ "inserted": {
+ "iops_rd": 0,
+ "detect_zeroes": "off",
+ "image": {
+ "virtual-size": 134217728,
+ "filename": "TEST_DIR/t.qcow2",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": SIZE,
+ "format-specific": {
+ "type": "qcow2",
+ "data": {
+ "compat": "1.1",
+ "lazy-refcounts": false,
+ "corrupt": false
+ }
+ },
+ "dirty-flag": false
+ },
+ "iops_wr": 0,
+ "ro": false,
+ "backing_file_depth": 0,
+ "drv": "qcow2",
+ "iops": 0,
+ "bps_wr": 0,
+ "encrypted": false,
+ "bps": 0,
+ "bps_rd": 0,
+ "file": "TEST_DIR/t.qcow2",
+ "encryption_key_missing": false
+ },
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "path": "/machine/peripheral/virtio0/virtio-backend"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "device": "virtio0",
+ "path": "/machine/peripheral/virtio0"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "RESET"
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "SHUTDOWN"
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "ide1-cd0",
+ "tray-open": true
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "floppy0",
+ "tray-open": true
+ }
+}
=== drive_add/device_add and device_del ===
Testing:
-QMP_VERSION
-{"return": {}}
-{"return": "OK\r\n"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"return": {}}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
+{
+ QMP_VERSION
+}
+{
+ "return": {
+ }
+}
+{
+ "return": "OK\r\n"
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "disk",
+ "locked": false,
+ "removable": true,
+ "inserted": {
+ "iops_rd": 0,
+ "detect_zeroes": "off",
+ "image": {
+ "virtual-size": 134217728,
+ "filename": "TEST_DIR/t.qcow2",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": SIZE,
+ "format-specific": {
+ "type": "qcow2",
+ "data": {
+ "compat": "1.1",
+ "lazy-refcounts": false,
+ "corrupt": false
+ }
+ },
+ "dirty-flag": false
+ },
+ "iops_wr": 0,
+ "ro": false,
+ "backing_file_depth": 0,
+ "drv": "qcow2",
+ "iops": 0,
+ "bps_wr": 0,
+ "encrypted": false,
+ "bps": 0,
+ "bps_rd": 0,
+ "file": "TEST_DIR/t.qcow2",
+ "encryption_key_missing": false
+ },
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "path": "/machine/peripheral/virtio0/virtio-backend"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "device": "virtio0",
+ "path": "/machine/peripheral/virtio0"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "RESET"
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "SHUTDOWN"
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "ide1-cd0",
+ "tray-open": true
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "floppy0",
+ "tray-open": true
+ }
+}
=== blockdev_add/device_add and device_del ===
Testing:
-QMP_VERSION
-{"return": {}}
-{"return": {}}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"return": {}}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_DELETED", "data": {"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"io-status": "ok", "device": "disk", "locked": false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
+{
+ QMP_VERSION
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "disk",
+ "locked": false,
+ "removable": true,
+ "inserted": {
+ "iops_rd": 0,
+ "detect_zeroes": "off",
+ "image": {
+ "virtual-size": 134217728,
+ "filename": "TEST_DIR/t.qcow2",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": SIZE,
+ "format-specific": {
+ "type": "qcow2",
+ "data": {
+ "compat": "1.1",
+ "lazy-refcounts": false,
+ "corrupt": false
+ }
+ },
+ "dirty-flag": false
+ },
+ "iops_wr": 0,
+ "ro": false,
+ "backing_file_depth": 0,
+ "drv": "qcow2",
+ "iops": 0,
+ "bps_wr": 0,
+ "encrypted": false,
+ "bps": 0,
+ "bps_rd": 0,
+ "file": "TEST_DIR/t.qcow2",
+ "encryption_key_missing": false
+ },
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "path": "/machine/peripheral/virtio0/virtio-backend"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_DELETED",
+ "data": {
+ "device": "virtio0",
+ "path": "/machine/peripheral/virtio0"
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "RESET"
+}
+{
+ "return": [
+ {
+ "io-status": "ok",
+ "device": "ide1-cd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "floppy0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "device": "sd0",
+ "locked": false,
+ "removable": true,
+ "tray_open": false,
+ "type": "unknown"
+ },
+ {
+ "io-status": "ok",
+ "device": "disk",
+ "locked": false,
+ "removable": true,
+ "inserted": {
+ "iops_rd": 0,
+ "detect_zeroes": "off",
+ "image": {
+ "virtual-size": 134217728,
+ "filename": "TEST_DIR/t.qcow2",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": SIZE,
+ "format-specific": {
+ "type": "qcow2",
+ "data": {
+ "compat": "1.1",
+ "lazy-refcounts": false,
+ "corrupt": false
+ }
+ },
+ "dirty-flag": false
+ },
+ "iops_wr": 0,
+ "ro": false,
+ "backing_file_depth": 0,
+ "drv": "qcow2",
+ "iops": 0,
+ "bps_wr": 0,
+ "encrypted": false,
+ "bps": 0,
+ "bps_rd": 0,
+ "file": "TEST_DIR/t.qcow2",
+ "encryption_key_missing": false
+ },
+ "tray_open": false,
+ "type": "unknown"
+ }
+ ]
+}
+{
+ "return": {
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "SHUTDOWN"
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "ide1-cd0",
+ "tray-open": true
+ }
+}
+{
+ "timestamp": {
+ "seconds": TIMESTAMP,
+ "microseconds": TIMESTAMP
+ },
+ "event": "DEVICE_TRAY_MOVED",
+ "data": {
+ "device": "floppy0",
+ "tray-open": true
+ }
+}
*** done
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] chardev: Add -qmp-pretty
2014-11-11 13:34 ` [Qemu-devel] [PATCH 1/3] " Max Reitz
@ 2014-11-12 4:41 ` Eric Blake
2014-11-12 8:32 ` Max Reitz
0 siblings, 1 reply; 11+ messages in thread
From: Eric Blake @ 2014-11-12 4:41 UTC (permalink / raw)
To: Max Reitz, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]
On 11/11/2014 06:34 AM, Max Reitz wrote:
> Add a command line option for adding a QMP monitor using pretty JSON
> formatting.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> qemu-options.hx | 8 ++++++++
> vl.c | 15 ++++++++++-----
> 2 files changed, 18 insertions(+), 5 deletions(-)
>
Minor grammar suggestions:
> diff --git a/qemu-options.hx b/qemu-options.hx
> index da9851d..bc7b4c2 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2788,6 +2788,14 @@ STEXI
> @findex -qmp
> Like -monitor but opens in 'control' mode.
> ETEXI
> +DEF("qmp-pretty", HAS_ARG, QEMU_OPTION_qmp_pretty, \
> + "-qmp-pretty dev like -qmp but uses pretty JSON formatting\n",
maybe s/dev like -qmp/dev: like -qmp,/
> + QEMU_ARCH_ALL)
> +STEXI
> +@item -qmp-pretty @var{dev}
> +@findex -qmp-pretty
> +Like -qmp but uses pretty JSON formatting.
maybe s/-qmp/-qmp,/
Either way,
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output
2014-11-11 13:34 ` [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output Max Reitz
@ 2014-11-12 4:47 ` Eric Blake
2014-11-12 8:33 ` Max Reitz
0 siblings, 1 reply; 11+ messages in thread
From: Eric Blake @ 2014-11-12 4:47 UTC (permalink / raw)
To: Max Reitz, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]
On 11/11/2014 06:34 AM, Max Reitz wrote:
> _filter_qmp should be able to correctly filter out the QMP version
> object for pretty JSON output.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> tests/qemu-iotests/common.filter | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> index 3acdb30..e24dab4 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -165,9 +165,23 @@ _filter_qemu()
> # replace problematic QMP output like timestamps
> _filter_qmp()
> {
> + discard=0
> +
> _filter_win32 | \
> sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
> - -e 's#^{"QMP":.*}$#QMP_VERSION#'
> + -e 's#^{"QMP":.*}$#QMP_VERSION#' \
> + -e 's#\\#\\\\#g' | \
> + while IFS='' read line; do
> + if [[ $line == ' "QMP": {' ]]; then
Good that this is a /bin/bash script and not /bin/sh :)
But - is it really worth doing this in shell? Why not just do it in sed?
sed -e ... \
-e 's#\\#\\\\#g' \
-e '/ "QMP": {/,/ }/ c\' \
-e ' QMP_VERSION'
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067
2014-11-11 13:34 ` [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067 Max Reitz
@ 2014-11-12 4:51 ` Eric Blake
2014-11-12 8:34 ` Max Reitz
0 siblings, 1 reply; 11+ messages in thread
From: Eric Blake @ 2014-11-12 4:51 UTC (permalink / raw)
To: Max Reitz, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]
On 11/11/2014 06:34 AM, Max Reitz wrote:
> 067 invokes query-block, resulting in a reference output with really
> long lines (which may pose a problem in email patches and always poses a
> problem when the output changes, because it is hard to see what has
> actually changed). Use -qmp-pretty to mitigate this issue.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> tests/qemu-iotests/067 | 2 +-
> tests/qemu-iotests/067.out | 779 +++++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 723 insertions(+), 58 deletions(-)
Large, but mechanical. I'm trusting this one is correct (if the
testsuite still passes, you did it right) rather than actually reading it :)
Reviewed-by: Eric Blake <eblake@redhat.com>
>
> diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067
> index d025192..29cd6b5 100755
> --- a/tests/qemu-iotests/067
> +++ b/tests/qemu-iotests/067
> @@ -39,7 +39,7 @@ _supported_os Linux
> function do_run_qemu()
> {
> echo Testing: "$@"
> - $QEMU -nographic -qmp stdio -serial none "$@"
> + $QEMU -nographic -qmp-pretty stdio -serial none "$@"
Such a trivial change for inducing over 700 lines of change in the
expected output :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] chardev: Add -qmp-pretty
2014-11-12 4:41 ` Eric Blake
@ 2014-11-12 8:32 ` Max Reitz
0 siblings, 0 replies; 11+ messages in thread
From: Max Reitz @ 2014-11-12 8:32 UTC (permalink / raw)
To: Eric Blake, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
On 2014-11-12 at 05:41, Eric Blake wrote:
> On 11/11/2014 06:34 AM, Max Reitz wrote:
>> Add a command line option for adding a QMP monitor using pretty JSON
>> formatting.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> qemu-options.hx | 8 ++++++++
>> vl.c | 15 ++++++++++-----
>> 2 files changed, 18 insertions(+), 5 deletions(-)
>>
> Minor grammar suggestions:
>
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index da9851d..bc7b4c2 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -2788,6 +2788,14 @@ STEXI
>> @findex -qmp
>> Like -monitor but opens in 'control' mode.
>> ETEXI
>> +DEF("qmp-pretty", HAS_ARG, QEMU_OPTION_qmp_pretty, \
>> + "-qmp-pretty dev like -qmp but uses pretty JSON formatting\n",
> maybe s/dev like -qmp/dev: like -qmp,/
>
>> + QEMU_ARCH_ALL)
>> +STEXI
>> +@item -qmp-pretty @var{dev}
>> +@findex -qmp-pretty
>> +Like -qmp but uses pretty JSON formatting.
> maybe s/-qmp/-qmp,/
That's what I wrote at first, but then I saw the entry above: "Like
-monitor but opens in 'control' mode" and decided to stay consistent.
> Either way,
> Reviewed-by: Eric Blake <eblake@redhat.com>
Thanks!
Max
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output
2014-11-12 4:47 ` Eric Blake
@ 2014-11-12 8:33 ` Max Reitz
2014-11-12 13:19 ` Eric Blake
0 siblings, 1 reply; 11+ messages in thread
From: Max Reitz @ 2014-11-12 8:33 UTC (permalink / raw)
To: Eric Blake, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
On 2014-11-12 at 05:47, Eric Blake wrote:
> On 11/11/2014 06:34 AM, Max Reitz wrote:
>> _filter_qmp should be able to correctly filter out the QMP version
>> object for pretty JSON output.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> tests/qemu-iotests/common.filter | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
>> index 3acdb30..e24dab4 100644
>> --- a/tests/qemu-iotests/common.filter
>> +++ b/tests/qemu-iotests/common.filter
>> @@ -165,9 +165,23 @@ _filter_qemu()
>> # replace problematic QMP output like timestamps
>> _filter_qmp()
>> {
>> + discard=0
>> +
>> _filter_win32 | \
>> sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
>> - -e 's#^{"QMP":.*}$#QMP_VERSION#'
>> + -e 's#^{"QMP":.*}$#QMP_VERSION#' \
>> + -e 's#\\#\\\\#g' | \
>> + while IFS='' read line; do
>> + if [[ $line == ' "QMP": {' ]]; then
> Good that this is a /bin/bash script and not /bin/sh :)
Ah, right, yes, I just copied the code I had written for filtering out
the image-specific information from the qemu-img info output.
> But - is it really worth doing this in shell? Why not just do it in sed?
Because I don't know sed well enough. ;-)
> sed -e ... \
> -e 's#\\#\\\\#g' \
> -e '/ "QMP": {/,/ }/ c\' \
> -e ' QMP_VERSION'
Will do, thanks.
Max
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067
2014-11-12 4:51 ` Eric Blake
@ 2014-11-12 8:34 ` Max Reitz
0 siblings, 0 replies; 11+ messages in thread
From: Max Reitz @ 2014-11-12 8:34 UTC (permalink / raw)
To: Eric Blake, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
On 2014-11-12 at 05:51, Eric Blake wrote:
> On 11/11/2014 06:34 AM, Max Reitz wrote:
>> 067 invokes query-block, resulting in a reference output with really
>> long lines (which may pose a problem in email patches and always poses a
>> problem when the output changes, because it is hard to see what has
>> actually changed). Use -qmp-pretty to mitigate this issue.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> tests/qemu-iotests/067 | 2 +-
>> tests/qemu-iotests/067.out | 779 +++++++++++++++++++++++++++++++++++++++++----
>> 2 files changed, 723 insertions(+), 58 deletions(-)
> Large, but mechanical. I'm trusting this one is correct (if the
> testsuite still passes, you did it right) rather than actually reading it :)
Yes, for me "Passes before and the output afterwards still makes sense
when skipping through" was enough.
Max
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
>> diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067
>> index d025192..29cd6b5 100755
>> --- a/tests/qemu-iotests/067
>> +++ b/tests/qemu-iotests/067
>> @@ -39,7 +39,7 @@ _supported_os Linux
>> function do_run_qemu()
>> {
>> echo Testing: "$@"
>> - $QEMU -nographic -qmp stdio -serial none "$@"
>> + $QEMU -nographic -qmp-pretty stdio -serial none "$@"
> Such a trivial change for inducing over 700 lines of change in the
> expected output :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output
2014-11-12 8:33 ` Max Reitz
@ 2014-11-12 13:19 ` Eric Blake
0 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2014-11-12 13:19 UTC (permalink / raw)
To: Max Reitz, qemu-devel
Cc: Kevin Wolf, Paolo Bonzini, Markus Armbruster, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 929 bytes --]
On 11/12/2014 01:33 AM, Max Reitz wrote:
>>> + -e 's#^{"QMP":.*}$#QMP_VERSION#' \
>>> + -e 's#\\#\\\\#g' | \
>>> + while IFS='' read line; do
>>> + if [[ $line == ' "QMP": {' ]]; then
>> Good that this is a /bin/bash script and not /bin/sh :)
>
> Ah, right, yes, I just copied the code I had written for filtering out
> the image-specific information from the qemu-img info output.
>
>> But - is it really worth doing this in shell? Why not just do it in sed?
>
> Because I don't know sed well enough. ;-)
>
>> sed -e ... \
>> -e 's#\\#\\\\#g' \
>> -e '/ "QMP": {/,/ }/ c\' \
Better make this line anchored in its searching:
-e '/^ "QMP": {$/,/^ }$/ c\' \
>> -e ' QMP_VERSION'
>
> Will do, thanks.
>
> Max
>
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-11-12 13:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 13:34 [Qemu-devel] [PATCH 0/3] chardev: Add -qmp-pretty Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 1/3] " Max Reitz
2014-11-12 4:41 ` Eric Blake
2014-11-12 8:32 ` Max Reitz
2014-11-11 13:34 ` [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output Max Reitz
2014-11-12 4:47 ` Eric Blake
2014-11-12 8:33 ` Max Reitz
2014-11-12 13:19 ` Eric Blake
2014-11-11 13:34 ` [Qemu-devel] [PATCH 3/3] iotests: Use -qmp-pretty in 067 Max Reitz
2014-11-12 4:51 ` Eric Blake
2014-11-12 8:34 ` Max Reitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).